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