vfs-impl.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. * \file
  3. * \brief Header: VFS implemntation (?)
  4. */
  5. #ifndef MC__VFS_IMPL_H
  6. #define MC__VFS_IMPL_H
  7. #include <sys/types.h>
  8. #include <sys/stat.h>
  9. #include <fcntl.h>
  10. #include <unistd.h>
  11. #include <dirent.h>
  12. #include <stddef.h>
  13. #include <utime.h>
  14. #include "vfs.h"
  15. #include "lib/fs.h" /* MC_MAXPATHLEN */
  16. /*** typedefs(not structures) and defined constants **********************************************/
  17. typedef void *vfsid;
  18. /*** enums ***************************************************************************************/
  19. /*** structures declarations (and typedefs of structures)*****************************************/
  20. struct vfs_stamping;
  21. struct vfs_class
  22. {
  23. struct vfs_class *next;
  24. const char *name; /* "FIles over SHell" */
  25. vfs_class_flags_t flags;
  26. const char *prefix; /* "fish:" */
  27. void *data; /* this is for filesystem's own use */
  28. int verrno; /* can't use errno because glibc2 might define errno as function */
  29. int (*init) (struct vfs_class * me);
  30. void (*done) (struct vfs_class * me);
  31. /**
  32. * The fill_names method shall call the callback function for every
  33. * filesystem name that this vfs module supports.
  34. */
  35. void (*fill_names) (struct vfs_class * me, fill_names_f);
  36. /**
  37. * The which() method shall return the index of the vfs subsystem
  38. * or -1 if this vfs cannot handle the given pathname.
  39. */
  40. int (*which) (struct vfs_class * me, const char *path);
  41. void *(*open) (struct vfs_class * me, const char *fname, int flags, mode_t mode);
  42. int (*close) (void *vfs_info);
  43. ssize_t (*read) (void *vfs_info, char *buffer, size_t count);
  44. ssize_t (*write) (void *vfs_info, const char *buf, size_t count);
  45. void *(*opendir) (struct vfs_class * me, const char *dirname);
  46. void *(*readdir) (void *vfs_info);
  47. int (*closedir) (void *vfs_info);
  48. int (*stat) (struct vfs_class * me, const char *path, struct stat * buf);
  49. int (*lstat) (struct vfs_class * me, const char *path, struct stat * buf);
  50. int (*fstat) (void *vfs_info, struct stat * buf);
  51. int (*chmod) (struct vfs_class * me, const char *path, int mode);
  52. int (*chown) (struct vfs_class * me, const char *path, uid_t owner, gid_t group);
  53. int (*utime) (struct vfs_class * me, const char *path, struct utimbuf * times);
  54. int (*readlink) (struct vfs_class * me, const char *path, char *buf, size_t size);
  55. int (*symlink) (struct vfs_class * me, const char *n1, const char *n2);
  56. int (*link) (struct vfs_class * me, const char *p1, const char *p2);
  57. int (*unlink) (struct vfs_class * me, const char *path);
  58. int (*rename) (struct vfs_class * me, const char *p1, const char *p2);
  59. int (*chdir) (struct vfs_class * me, const char *path);
  60. int (*ferrno) (struct vfs_class * me);
  61. off_t (*lseek) (void *vfs_info, off_t offset, int whence);
  62. int (*mknod) (struct vfs_class * me, const char *path, mode_t mode, dev_t dev);
  63. vfsid (*getid) (struct vfs_class * me, const char *path);
  64. int (*nothingisopen) (vfsid id);
  65. void (*free) (vfsid id);
  66. char *(*getlocalcopy) (struct vfs_class * me, const char *filename);
  67. int (*ungetlocalcopy) (struct vfs_class * me, const char *filename,
  68. const char *local, int has_changed);
  69. int (*mkdir) (struct vfs_class * me, const char *path, mode_t mode);
  70. int (*rmdir) (struct vfs_class * me, const char *path);
  71. int (*ctl) (void *vfs_info, int ctlop, void *arg);
  72. int (*setctl) (struct vfs_class * me, const char *path, int ctlop, void *arg);
  73. };
  74. /*
  75. * This union is used to ensure that there is enough space for the
  76. * filename (d_name) when the dirent structure is created.
  77. */
  78. union vfs_dirent
  79. {
  80. struct dirent dent;
  81. char _extra_buffer[offsetof (struct dirent, d_name) + MC_MAXPATHLEN + 1];
  82. };
  83. /*** global variables defined in .c file *********************************************************/
  84. /*** declarations of public functions ************************************************************/
  85. /* Register a file system class */
  86. int vfs_register_class (struct vfs_class *vfs);
  87. struct vfs_class *vfs_split (char *path, char **inpath, char **op);
  88. char *vfs_path (const char *path);
  89. /* vfs/direntry.c: */
  90. void *vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode);
  91. vfsid vfs_getid (struct vfs_class *vclass, const char *dir);
  92. #ifdef ENABLE_VFS_CPIO
  93. void init_cpiofs (void);
  94. #endif
  95. #ifdef ENABLE_VFS_TAR
  96. void init_tarfs (void);
  97. #endif
  98. #ifdef ENABLE_VFS_SFS
  99. void init_sfs (void);
  100. #endif
  101. #ifdef ENABLE_VFS_EXTFS
  102. void init_extfs (void);
  103. #endif
  104. #ifdef ENABLE_VFS_UNDELFS
  105. void init_undelfs (void);
  106. #endif
  107. #ifdef ENABLE_VFS_FTP
  108. void init_ftpfs (void);
  109. #endif
  110. #ifdef ENABLE_VFS_FISH
  111. void init_fish (void);
  112. #endif
  113. /*** inline functions ****************************************************************************/
  114. #endif /* MC_VFS_IMPL_H */