vfs-impl.h 4.6 KB

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