vfs-impl.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /**
  2. * \file
  3. * \brief Header: VFS implemntation (?)
  4. */
  5. #ifndef MC_VFS_IMPL_H
  6. #define MC_VFS_IMPL_H
  7. #ifdef ENABLE_VFS
  8. #include <sys/types.h>
  9. #include <dirent.h>
  10. #include <stddef.h>
  11. #include <utime.h>
  12. #include "../src/fs.h" /* MC_MAXPATHLEN */
  13. typedef void *vfsid;
  14. struct vfs_stamping;
  15. /* Flags of VFS classes */
  16. #define VFSF_LOCAL 1 /* Class is local (not virtual) filesystem */
  17. #define VFSF_NOLINKS 2 /* Hard links not supported */
  18. /**
  19. * This is the type of callback function passed to vfs_fill_names.
  20. * It gets the name of the virtual file system as its first argument.
  21. * See also:
  22. * vfs_fill_names().
  23. */
  24. typedef void (*fill_names_f) (const char *);
  25. struct vfs_class {
  26. struct vfs_class *next;
  27. const char *name; /* "FIles over SHell" */
  28. int flags;
  29. const char *prefix; /* "fish:" */
  30. void *data; /* this is for filesystem's own use */
  31. int verrno; /* can't use errno because glibc2 might define errno as function */
  32. int (*init) (struct vfs_class *me);
  33. void (*done) (struct vfs_class *me);
  34. /**
  35. * The fill_names method shall call the callback function for every
  36. * filesystem name that this vfs module supports.
  37. */
  38. void (*fill_names) (struct vfs_class *me, fill_names_f);
  39. /**
  40. * The which() method shall return the index of the vfs subsystem
  41. * or -1 if this vfs cannot handle the given pathname.
  42. */
  43. int (*which) (struct vfs_class *me, const char *path);
  44. void *(*open) (struct vfs_class *me, const char *fname, int flags,
  45. int mode);
  46. int (*close) (void *vfs_info);
  47. ssize_t (*read) (void *vfs_info, char *buffer, int count);
  48. ssize_t (*write) (void *vfs_info, const char *buf, int count);
  49. void *(*opendir) (struct vfs_class *me, const char *dirname);
  50. void *(*readdir) (void *vfs_info);
  51. int (*closedir) (void *vfs_info);
  52. int (*stat) (struct vfs_class *me, const char *path, struct stat * buf);
  53. int (*lstat) (struct vfs_class *me, const char *path, struct stat * buf);
  54. int (*fstat) (void *vfs_info, struct stat * buf);
  55. int (*chmod) (struct vfs_class *me, const char *path, int mode);
  56. int (*chown) (struct vfs_class *me, const char *path, int owner, int group);
  57. int (*utime) (struct vfs_class *me, const char *path,
  58. struct utimbuf * times);
  59. int (*readlink) (struct vfs_class *me, const char *path, char *buf,
  60. size_t size);
  61. int (*symlink) (struct vfs_class *me, const char *n1, const char *n2);
  62. int (*link) (struct vfs_class *me, const char *p1, const char *p2);
  63. int (*unlink) (struct vfs_class *me, const char *path);
  64. int (*rename) (struct vfs_class *me, const char *p1, const char *p2);
  65. int (*chdir) (struct vfs_class *me, const char *path);
  66. int (*ferrno) (struct vfs_class *me);
  67. off_t (*lseek) (void *vfs_info, off_t offset, int whence);
  68. int (*mknod) (struct vfs_class *me, const char *path, int mode, int dev);
  69. vfsid (*getid) (struct vfs_class *me, const char *path);
  70. int (*nothingisopen) (vfsid id);
  71. void (*free) (vfsid id);
  72. char *(*getlocalcopy) (struct vfs_class *me, const char *filename);
  73. int (*ungetlocalcopy) (struct vfs_class *me, const char *filename,
  74. const char *local, int has_changed);
  75. int (*mkdir) (struct vfs_class *me, const char *path, mode_t mode);
  76. int (*rmdir) (struct vfs_class *me, const char *path);
  77. int (*ctl) (void *vfs_info, int ctlop, void *arg);
  78. int (*setctl) (struct vfs_class *me, const char *path, int ctlop,
  79. void *arg);
  80. };
  81. /*
  82. * This union is used to ensure that there is enough space for the
  83. * filename (d_name) when the dirent structure is created.
  84. */
  85. union vfs_dirent {
  86. struct dirent dent;
  87. char _extra_buffer[offsetof(struct dirent, d_name) + MC_MAXPATHLEN + 1];
  88. };
  89. /* Register a file system class */
  90. int vfs_register_class (struct vfs_class *vfs);
  91. #ifdef ENABLE_VFS_SMB
  92. /* Interface for requesting SMB credentials. */
  93. struct smb_authinfo {
  94. char *host;
  95. char *share;
  96. char *domain;
  97. char *user;
  98. char *password;
  99. };
  100. struct smb_authinfo *vfs_smb_get_authinfo (const char *host,
  101. const char *share,
  102. const char *domain,
  103. const char *user);
  104. #endif /* ENABLE_VFS_SMB */
  105. struct vfs_class *vfs_get_class (const char *path);
  106. struct vfs_class *vfs_split (char *path, char **inpath, char **op);
  107. char *vfs_path (const char *path);
  108. int vfs_file_class_flags (const char *filename);
  109. void vfs_fill_names (fill_names_f);
  110. /* vfs/direntry.c: */
  111. void *vfs_s_open (struct vfs_class *, const char *, int, int);
  112. #ifdef USE_NETCODE
  113. extern int use_netrc;
  114. #endif
  115. void init_cpiofs (void);
  116. void init_extfs (void);
  117. void init_fish (void);
  118. void init_sfs (void);
  119. void init_tarfs (void);
  120. void init_undelfs (void);
  121. #endif /* ENABLE_VFS */
  122. #endif /* MC_VFS_IMPL_H */