vfs-impl.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. /**
  16. * This is the type of callback function passed to vfs_fill_names.
  17. * It gets the name of the virtual file system as its first argument.
  18. * See also:
  19. * vfs_fill_names().
  20. */
  21. typedef void (*fill_names_f) (const char *);
  22. struct vfs_class {
  23. struct vfs_class *next;
  24. const char *name; /* "FIles over SHell" */
  25. int 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,
  42. int mode);
  43. int (*close) (void *vfs_info);
  44. ssize_t (*read) (void *vfs_info, char *buffer, int count);
  45. ssize_t (*write) (void *vfs_info, const char *buf, int count);
  46. void *(*opendir) (struct vfs_class *me, const char *dirname);
  47. void *(*readdir) (void *vfs_info);
  48. int (*closedir) (void *vfs_info);
  49. int (*stat) (struct vfs_class *me, const char *path, struct stat * buf);
  50. int (*lstat) (struct vfs_class *me, const char *path, struct stat * buf);
  51. int (*fstat) (void *vfs_info, struct stat * buf);
  52. int (*chmod) (struct vfs_class *me, const char *path, int mode);
  53. int (*chown) (struct vfs_class *me, const char *path, int owner, int group);
  54. int (*utime) (struct vfs_class *me, const char *path,
  55. struct utimbuf * times);
  56. int (*readlink) (struct vfs_class *me, const char *path, char *buf,
  57. size_t size);
  58. int (*symlink) (struct vfs_class *me, const char *n1, const char *n2);
  59. int (*link) (struct vfs_class *me, const char *p1, const char *p2);
  60. int (*unlink) (struct vfs_class *me, const char *path);
  61. int (*rename) (struct vfs_class *me, const char *p1, const char *p2);
  62. int (*chdir) (struct vfs_class *me, const char *path);
  63. int (*ferrno) (struct vfs_class *me);
  64. off_t (*lseek) (void *vfs_info, off_t offset, int whence);
  65. int (*mknod) (struct vfs_class *me, const char *path, int mode, int dev);
  66. vfsid (*getid) (struct vfs_class *me, const char *path);
  67. int (*nothingisopen) (vfsid id);
  68. void (*free) (vfsid id);
  69. char *(*getlocalcopy) (struct vfs_class *me, const char *filename);
  70. int (*ungetlocalcopy) (struct vfs_class *me, const char *filename,
  71. const char *local, int has_changed);
  72. int (*mkdir) (struct vfs_class *me, const char *path, mode_t mode);
  73. int (*rmdir) (struct vfs_class *me, const char *path);
  74. int (*ctl) (void *vfs_info, int ctlop, void *arg);
  75. int (*setctl) (struct vfs_class *me, const char *path, int ctlop,
  76. void *arg);
  77. };
  78. /*
  79. * This union is used to ensure that there is enough space for the
  80. * filename (d_name) when the dirent structure is created.
  81. */
  82. union vfs_dirent {
  83. struct dirent dent;
  84. char _extra_buffer[offsetof(struct dirent, d_name) + MC_MAXPATHLEN + 1];
  85. };
  86. /* Register a file system class */
  87. int vfs_register_class (struct vfs_class *vfs);
  88. #ifdef ENABLE_VFS_SMB
  89. /* Interface for requesting SMB credentials. */
  90. struct smb_authinfo {
  91. char *host;
  92. char *share;
  93. char *domain;
  94. char *user;
  95. char *password;
  96. };
  97. struct smb_authinfo *vfs_smb_get_authinfo (const char *host,
  98. const char *share,
  99. const char *domain,
  100. const char *user);
  101. #endif /* ENABLE_VFS_SMB */
  102. struct vfs_class *vfs_get_class (const char *path);
  103. struct vfs_class *vfs_split (char *path, char **inpath, char **op);
  104. char *vfs_path (const char *path);
  105. int vfs_file_class_flags (const char *filename);
  106. void vfs_fill_names (fill_names_f);
  107. /* vfs/direntry.c: */
  108. void *vfs_s_open (struct vfs_class *, const char *, int, int);
  109. #ifdef USE_NETCODE
  110. extern int use_netrc;
  111. #endif
  112. void init_cpiofs (void);
  113. void init_extfs (void);
  114. void init_fish (void);
  115. void init_sfs (void);
  116. void init_tarfs (void);
  117. void init_undelfs (void);
  118. #endif /* ENABLE_VFS */
  119. #endif /* MC_VFS_IMPL_H */