db_files.c 5.7 KB

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