vfs-impl.h 4.4 KB

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