db_files.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* Copyright (C) 2014 Stony Brook University
  2. This file is part of Graphene Library OS.
  3. Graphene Library OS is free software: you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public License
  5. as published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. Graphene Library OS is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /*
  14. * db_files.c
  15. *
  16. * This file contains operands to handle streams with URIs that start with "file:" or "dir:".
  17. */
  18. #include "api.h"
  19. #include "pal.h"
  20. #include "pal_debug.h"
  21. #include "pal_defs.h"
  22. #include "pal_error.h"
  23. #include "pal_internal.h"
  24. /* 'open' operation for file streams */
  25. static int file_open(PAL_HANDLE* handle, const char* type, const char* uri, int access, int share,
  26. int create, int options) {
  27. return -PAL_ERROR_NOTIMPLEMENTED;
  28. }
  29. /* 'read' operation for file streams. */
  30. static int64_t file_read(PAL_HANDLE handle, uint64_t offset, uint64_t count, void* buffer) {
  31. return -PAL_ERROR_NOTIMPLEMENTED;
  32. }
  33. /* 'write' operation for file streams. */
  34. static int64_t file_write(PAL_HANDLE handle, uint64_t offset, uint64_t count, const void* buffer) {
  35. return -PAL_ERROR_NOTIMPLEMENTED;
  36. }
  37. /* 'close' operation for file streams. In this case, it will only close the file withou deleting it.
  38. */
  39. static int file_close(PAL_HANDLE handle) {
  40. return -PAL_ERROR_NOTIMPLEMENTED;
  41. }
  42. /* 'delete' operation for file streams. It will actually delete the file if we can successfully
  43. * close it. */
  44. static int file_delete(PAL_HANDLE handle, int access) {
  45. return -PAL_ERROR_NOTIMPLEMENTED;
  46. }
  47. /* 'map' operation for file stream. */
  48. static int file_map(PAL_HANDLE handle, void** addr, int prot, uint64_t offset, uint64_t size) {
  49. return -PAL_ERROR_NOTIMPLEMENTED;
  50. }
  51. /* 'setlength' operation for file stream. */
  52. static int64_t file_setlength(PAL_HANDLE handle, uint64_t length) {
  53. return -PAL_ERROR_NOTIMPLEMENTED;
  54. }
  55. /* 'flush' operation for file stream. */
  56. static int file_flush(PAL_HANDLE handle) {
  57. return -PAL_ERROR_NOTIMPLEMENTED;
  58. }
  59. /* 'attrquery' operation for file streams */
  60. static int file_attrquery(const char* type, const char* uri, PAL_STREAM_ATTR* attr) {
  61. return -PAL_ERROR_NOTIMPLEMENTED;
  62. }
  63. /* 'attrquerybyhdl' operation for file streams */
  64. static int file_attrquerybyhdl(PAL_HANDLE handle, PAL_STREAM_ATTR* attr) {
  65. return -PAL_ERROR_NOTIMPLEMENTED;
  66. }
  67. static int file_rename(PAL_HANDLE handle, const char* type, const char* uri) {
  68. return -PAL_ERROR_NOTIMPLEMENTED;
  69. }
  70. static int file_getname(PAL_HANDLE handle, char* buffer, size_t count) {
  71. return -PAL_ERROR_NOTIMPLEMENTED;
  72. }
  73. const char* file_getrealpath(PAL_HANDLE handle) {
  74. return NULL;
  75. }
  76. struct handle_ops file_ops = {
  77. .getname = &file_getname,
  78. .getrealpath = &file_getrealpath,
  79. .open = &file_open,
  80. .read = &file_read,
  81. .write = &file_write,
  82. .close = &file_close,
  83. .delete = &file_delete,
  84. .map = &file_map,
  85. .setlength = &file_setlength,
  86. .flush = &file_flush,
  87. .attrquery = &file_attrquery,
  88. .attrquerybyhdl = &file_attrquerybyhdl,
  89. .rename = &file_rename,
  90. };
  91. /* 'open' operation for directory stream. Directory stream does not have a specific type prefix, its
  92. * URI looks the same file streams, plus it ended with slashes. dir_open will be called by
  93. * file_open. */
  94. static int dir_open(PAL_HANDLE* handle, const char* type, const char* uri, int access, int share,
  95. int create, int options) {
  96. return -PAL_ERROR_NOTIMPLEMENTED;
  97. }
  98. /* 'read' operation for directory stream. Directory stream will not need a 'write' operation. */
  99. int64_t dir_read(PAL_HANDLE handle, uint64_t offset, uint64_t count, void* buf) {
  100. return -PAL_ERROR_NOTIMPLEMENTED;
  101. }
  102. /* 'close' operation of directory streams */
  103. static int dir_close(PAL_HANDLE handle) {
  104. return -PAL_ERROR_NOTIMPLEMENTED;
  105. }
  106. /* 'delete' operation of directoy streams */
  107. static int dir_delete(PAL_HANDLE handle, int access) {
  108. return -PAL_ERROR_NOTIMPLEMENTED;
  109. }
  110. /* 'attrquerybyhdl' operation of directory streams */
  111. static int dir_attrquerybyhdl(PAL_HANDLE handle, PAL_STREAM_ATTR* attr) {
  112. return -PAL_ERROR_NOTIMPLEMENTED;
  113. }
  114. static int dir_rename(PAL_HANDLE handle, const char* type, const char* uri) {
  115. return -PAL_ERROR_NOTIMPLEMENTED;
  116. }
  117. static int dir_getname(PAL_HANDLE handle, char* buffer, size_t count) {
  118. return -PAL_ERROR_NOTIMPLEMENTED;
  119. }
  120. static const char* dir_getrealpath(PAL_HANDLE handle) {
  121. return NULL;
  122. }
  123. struct handle_ops dir_ops = {
  124. .getname = &dir_getname,
  125. .getrealpath = &dir_getrealpath,
  126. .open = &dir_open,
  127. .read = &dir_read,
  128. .close = &dir_close,
  129. .delete = &dir_delete,
  130. .attrquery = &file_attrquery,
  131. .attrquerybyhdl = &dir_attrquerybyhdl,
  132. .rename = &dir_rename,
  133. };