db_files.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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
  17. * "file:" or "dir:".
  18. */
  19. #include "pal_defs.h"
  20. #include "pal.h"
  21. #include "pal_internal.h"
  22. #include "pal_debug.h"
  23. #include "pal_error.h"
  24. #include "api.h"
  25. /* 'open' operation for file streams */
  26. static int file_open (PAL_HANDLE * handle, const char * type, const char * uri,
  27. int access, int share, int create, int options)
  28. {
  29. return -PAL_ERROR_NOTIMPLEMENTED;
  30. }
  31. /* 'read' operation for file streams. */
  32. static int64_t file_read (PAL_HANDLE handle, uint64_t offset, uint64_t count,
  33. void * buffer)
  34. {
  35. return -PAL_ERROR_NOTIMPLEMENTED;
  36. }
  37. /* 'write' operation for file streams. */
  38. static int64_t file_write (PAL_HANDLE handle, uint64_t offset, uint64_t count,
  39. const void * buffer)
  40. {
  41. return -PAL_ERROR_NOTIMPLEMENTED;
  42. }
  43. /* 'close' operation for file streams. In this case, it will only
  44. close the file withou deleting it. */
  45. static int file_close (PAL_HANDLE handle)
  46. {
  47. return -PAL_ERROR_NOTIMPLEMENTED;
  48. }
  49. /* 'delete' operation for file streams. It will actually delete
  50. the file if we can successfully close it. */
  51. static int file_delete (PAL_HANDLE handle, int access)
  52. {
  53. return -PAL_ERROR_NOTIMPLEMENTED;
  54. }
  55. /* 'map' operation for file stream. */
  56. static int file_map (PAL_HANDLE handle, void ** addr, int prot,
  57. uint64_t offset, uint64_t size)
  58. {
  59. return -PAL_ERROR_NOTIMPLEMENTED;
  60. }
  61. /* 'setlength' operation for file stream. */
  62. static int64_t file_setlength (PAL_HANDLE handle, uint64_t length)
  63. {
  64. return -PAL_ERROR_NOTIMPLEMENTED;
  65. }
  66. /* 'flush' operation for file stream. */
  67. static int file_flush (PAL_HANDLE handle)
  68. {
  69. return -PAL_ERROR_NOTIMPLEMENTED;
  70. }
  71. /* 'attrquery' operation for file streams */
  72. static int file_attrquery (const char * type, const char * uri,
  73. PAL_STREAM_ATTR * attr)
  74. {
  75. return -PAL_ERROR_NOTIMPLEMENTED;
  76. }
  77. /* 'attrquerybyhdl' operation for file streams */
  78. static int file_attrquerybyhdl (PAL_HANDLE handle,
  79. PAL_STREAM_ATTR * attr)
  80. {
  81. return -PAL_ERROR_NOTIMPLEMENTED;
  82. }
  83. static int file_rename (PAL_HANDLE handle, const char * type,
  84. const char * uri)
  85. {
  86. return -PAL_ERROR_NOTIMPLEMENTED;
  87. }
  88. static int file_getname (PAL_HANDLE handle, char * buffer, size_t count)
  89. {
  90. return -PAL_ERROR_NOTIMPLEMENTED;
  91. }
  92. const char * file_getrealpath (PAL_HANDLE handle)
  93. {
  94. return NULL;
  95. }
  96. struct handle_ops file_ops = {
  97. .getname = &file_getname,
  98. .getrealpath = &file_getrealpath,
  99. .open = &file_open,
  100. .read = &file_read,
  101. .write = &file_write,
  102. .close = &file_close,
  103. .delete = &file_delete,
  104. .map = &file_map,
  105. .setlength = &file_setlength,
  106. .flush = &file_flush,
  107. .attrquery = &file_attrquery,
  108. .attrquerybyhdl = &file_attrquerybyhdl,
  109. .rename = &file_rename,
  110. };
  111. /* 'open' operation for directory stream. Directory stream does not have a
  112. specific type prefix, its URI looks the same file streams, plus it
  113. ended with slashes. dir_open will be called by file_open. */
  114. static int dir_open (PAL_HANDLE * handle, const char * type, const char * uri,
  115. int access, int share, int create, int options)
  116. {
  117. return -PAL_ERROR_NOTIMPLEMENTED;
  118. }
  119. /* 'read' operation for directory stream. Directory stream will not
  120. need a 'write' operation. */
  121. int64_t dir_read (PAL_HANDLE handle, uint64_t offset, uint64_t count, void * buf)
  122. {
  123. return -PAL_ERROR_NOTIMPLEMENTED;
  124. }
  125. /* 'close' operation of directory streams */
  126. static int dir_close (PAL_HANDLE handle)
  127. {
  128. return -PAL_ERROR_NOTIMPLEMENTED;
  129. }
  130. /* 'delete' operation of directoy streams */
  131. static int dir_delete (PAL_HANDLE handle, int access)
  132. {
  133. return -PAL_ERROR_NOTIMPLEMENTED;
  134. }
  135. /* 'attrquerybyhdl' operation of directory streams */
  136. static int dir_attrquerybyhdl (PAL_HANDLE handle,
  137. PAL_STREAM_ATTR * attr)
  138. {
  139. return -PAL_ERROR_NOTIMPLEMENTED;
  140. }
  141. static int dir_rename (PAL_HANDLE handle, const char * type,
  142. const char * uri)
  143. {
  144. return -PAL_ERROR_NOTIMPLEMENTED;
  145. }
  146. static int dir_getname (PAL_HANDLE handle, char * buffer, size_t count)
  147. {
  148. return -PAL_ERROR_NOTIMPLEMENTED;
  149. }
  150. static const char * dir_getrealpath (PAL_HANDLE handle)
  151. {
  152. return NULL;
  153. }
  154. struct handle_ops dir_ops = {
  155. .getname = &dir_getname,
  156. .getrealpath = &dir_getrealpath,
  157. .open = &dir_open,
  158. .read = &dir_read,
  159. .close = &dir_close,
  160. .delete = &dir_delete,
  161. .attrquery = &file_attrquery,
  162. .attrquerybyhdl = &dir_attrquerybyhdl,
  163. .rename = &dir_rename,
  164. };