vfs-impl.h 4.5 KB

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