VFS: moved functions from src/vfsdummy.h to vfs/vfs.h
[midnight-commander.git] / vfs / vfs-impl.h
blob055eb2afd3a245fef22d227e085287aaa5b2e128
2 /**
3 * \file
4 * \brief Header: VFS implemntation (?)
5 */
7 #ifndef MC_VFS_IMPL_H
8 #define MC_VFS_IMPL_H
10 #ifdef ENABLE_VFS
12 #include <sys/types.h>
13 #include <dirent.h>
14 #include <stddef.h>
15 #include <utime.h>
17 #include "../src/fs.h" /* MC_MAXPATHLEN */
19 typedef void *vfsid;
20 struct vfs_stamping;
22 /**
23 * This is the type of callback function passed to vfs_fill_names.
24 * It gets the name of the virtual file system as its first argument.
25 * See also:
26 * vfs_fill_names().
28 typedef void (*fill_names_f) (const char *);
30 struct vfs_class {
31 struct vfs_class *next;
32 const char *name; /* "FIles over SHell" */
33 int flags;
34 const char *prefix; /* "fish:" */
35 void *data; /* this is for filesystem's own use */
36 int verrno; /* can't use errno because glibc2 might define errno as function */
38 int (*init) (struct vfs_class *me);
39 void (*done) (struct vfs_class *me);
41 /**
42 * The fill_names method shall call the callback function for every
43 * filesystem name that this vfs module supports.
45 void (*fill_names) (struct vfs_class *me, fill_names_f);
47 /**
48 * The which() method shall return the index of the vfs subsystem
49 * or -1 if this vfs cannot handle the given pathname.
51 int (*which) (struct vfs_class *me, const char *path);
53 void *(*open) (struct vfs_class *me, const char *fname, int flags,
54 int mode);
55 int (*close) (void *vfs_info);
56 ssize_t (*read) (void *vfs_info, char *buffer, int count);
57 ssize_t (*write) (void *vfs_info, const char *buf, int count);
59 void *(*opendir) (struct vfs_class *me, const char *dirname);
60 void *(*readdir) (void *vfs_info);
61 int (*closedir) (void *vfs_info);
63 int (*stat) (struct vfs_class *me, const char *path, struct stat * buf);
64 int (*lstat) (struct vfs_class *me, const char *path, struct stat * buf);
65 int (*fstat) (void *vfs_info, struct stat * buf);
67 int (*chmod) (struct vfs_class *me, const char *path, int mode);
68 int (*chown) (struct vfs_class *me, const char *path, int owner, int group);
69 int (*utime) (struct vfs_class *me, const char *path,
70 struct utimbuf * times);
72 int (*readlink) (struct vfs_class *me, const char *path, char *buf,
73 size_t size);
74 int (*symlink) (struct vfs_class *me, const char *n1, const char *n2);
75 int (*link) (struct vfs_class *me, const char *p1, const char *p2);
76 int (*unlink) (struct vfs_class *me, const char *path);
77 int (*rename) (struct vfs_class *me, const char *p1, const char *p2);
78 int (*chdir) (struct vfs_class *me, const char *path);
79 int (*ferrno) (struct vfs_class *me);
80 off_t (*lseek) (void *vfs_info, off_t offset, int whence);
81 int (*mknod) (struct vfs_class *me, const char *path, int mode, int dev);
83 vfsid (*getid) (struct vfs_class *me, const char *path);
85 int (*nothingisopen) (vfsid id);
86 void (*free) (vfsid id);
88 char *(*getlocalcopy) (struct vfs_class *me, const char *filename);
89 int (*ungetlocalcopy) (struct vfs_class *me, const char *filename,
90 const char *local, int has_changed);
92 int (*mkdir) (struct vfs_class *me, const char *path, mode_t mode);
93 int (*rmdir) (struct vfs_class *me, const char *path);
95 int (*ctl) (void *vfs_info, int ctlop, void *arg);
96 int (*setctl) (struct vfs_class *me, const char *path, int ctlop,
97 void *arg);
101 * This union is used to ensure that there is enough space for the
102 * filename (d_name) when the dirent structure is created.
104 union vfs_dirent {
105 struct dirent dent;
106 char _extra_buffer[offsetof(struct dirent, d_name) + MC_MAXPATHLEN + 1];
109 /* Register a file system class */
110 int vfs_register_class (struct vfs_class *vfs);
112 #ifdef ENABLE_VFS_SMB
113 /* Interface for requesting SMB credentials. */
114 struct smb_authinfo {
115 char *host;
116 char *share;
117 char *domain;
118 char *user;
119 char *password;
122 struct smb_authinfo *vfs_smb_get_authinfo (const char *host,
123 const char *share,
124 const char *domain,
125 const char *user);
126 #endif /* ENABLE_VFS_SMB */
128 struct vfs_class *vfs_get_class (const char *path);
129 struct vfs_class *vfs_split (char *path, char **inpath, char **op);
130 char *vfs_path (const char *path);
131 int vfs_file_class_flags (const char *filename);
133 void vfs_fill_names (fill_names_f);
135 /* vfs/direntry.c: */
136 void *vfs_s_open (struct vfs_class *, const char *, int, int);
138 #ifdef USE_NETCODE
139 extern int use_netrc;
140 #endif
142 void init_cpiofs (void);
143 void init_extfs (void);
144 void init_fish (void);
145 void init_sfs (void);
146 void init_tarfs (void);
147 void init_undelfs (void);
149 #endif /* ENABLE_VFS */
151 #endif /* MC_VFS_IMPL_H */