Merge commit 'origin/256_backward_word_fix'
[free-mc.git] / vfs / vfs-impl.h
blob00c752f7841a108ed69a1eb9e63af869ac2ad833
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 <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 /* Flags of VFS classes */
23 #define VFSF_LOCAL 1 /* Class is local (not virtual) filesystem */
24 #define VFSF_NOLINKS 2 /* Hard links not supported */
26 /**
27 * This is the type of callback function passed to vfs_fill_names.
28 * It gets the name of the virtual file system as its first argument.
29 * See also:
30 * vfs_fill_names().
32 typedef void (*fill_names_f) (const char *);
34 struct vfs_class {
35 struct vfs_class *next;
36 const char *name; /* "FIles over SHell" */
37 int flags;
38 const char *prefix; /* "fish:" */
39 void *data; /* this is for filesystem's own use */
40 int verrno; /* can't use errno because glibc2 might define errno as function */
42 int (*init) (struct vfs_class *me);
43 void (*done) (struct vfs_class *me);
45 /**
46 * The fill_names method shall call the callback function for every
47 * filesystem name that this vfs module supports.
49 void (*fill_names) (struct vfs_class *me, fill_names_f);
51 /**
52 * The which() method shall return the index of the vfs subsystem
53 * or -1 if this vfs cannot handle the given pathname.
55 int (*which) (struct vfs_class *me, const char *path);
57 void *(*open) (struct vfs_class *me, const char *fname, int flags,
58 int mode);
59 int (*close) (void *vfs_info);
60 ssize_t (*read) (void *vfs_info, char *buffer, int count);
61 ssize_t (*write) (void *vfs_info, const char *buf, int count);
63 void *(*opendir) (struct vfs_class *me, const char *dirname);
64 void *(*readdir) (void *vfs_info);
65 int (*closedir) (void *vfs_info);
67 int (*stat) (struct vfs_class *me, const char *path, struct stat * buf);
68 int (*lstat) (struct vfs_class *me, const char *path, struct stat * buf);
69 int (*fstat) (void *vfs_info, struct stat * buf);
71 int (*chmod) (struct vfs_class *me, const char *path, int mode);
72 int (*chown) (struct vfs_class *me, const char *path, int owner, int group);
73 int (*utime) (struct vfs_class *me, const char *path,
74 struct utimbuf * times);
76 int (*readlink) (struct vfs_class *me, const char *path, char *buf,
77 size_t size);
78 int (*symlink) (struct vfs_class *me, const char *n1, const char *n2);
79 int (*link) (struct vfs_class *me, const char *p1, const char *p2);
80 int (*unlink) (struct vfs_class *me, const char *path);
81 int (*rename) (struct vfs_class *me, const char *p1, const char *p2);
82 int (*chdir) (struct vfs_class *me, const char *path);
83 int (*ferrno) (struct vfs_class *me);
84 off_t (*lseek) (void *vfs_info, off_t offset, int whence);
85 int (*mknod) (struct vfs_class *me, const char *path, int mode, int dev);
87 vfsid (*getid) (struct vfs_class *me, const char *path);
89 int (*nothingisopen) (vfsid id);
90 void (*free) (vfsid id);
92 char *(*getlocalcopy) (struct vfs_class *me, const char *filename);
93 int (*ungetlocalcopy) (struct vfs_class *me, const char *filename,
94 const char *local, int has_changed);
96 int (*mkdir) (struct vfs_class *me, const char *path, mode_t mode);
97 int (*rmdir) (struct vfs_class *me, const char *path);
99 int (*ctl) (void *vfs_info, int ctlop, void *arg);
100 int (*setctl) (struct vfs_class *me, const char *path, int ctlop,
101 void *arg);
105 * This union is used to ensure that there is enough space for the
106 * filename (d_name) when the dirent structure is created.
108 union vfs_dirent {
109 struct dirent dent;
110 char _extra_buffer[offsetof(struct dirent, d_name) + MC_MAXPATHLEN + 1];
113 /* Register a file system class */
114 int vfs_register_class (struct vfs_class *vfs);
116 #ifdef WITH_SMBFS
117 /* Interface for requesting SMB credentials. */
118 struct smb_authinfo {
119 char *host;
120 char *share;
121 char *domain;
122 char *user;
123 char *password;
126 struct smb_authinfo *vfs_smb_get_authinfo (const char *host,
127 const char *share,
128 const char *domain,
129 const char *user);
130 #endif /* WITH_SMBFS */
132 struct vfs_class *vfs_get_class (const char *path);
133 struct vfs_class *vfs_split (char *path, char **inpath, char **op);
134 char *vfs_path (const char *path);
135 int vfs_file_class_flags (const char *filename);
137 void vfs_fill_names (fill_names_f);
139 /* vfs/direntry.c: */
140 void *vfs_s_open (struct vfs_class *, const char *, int, int);
142 #ifdef USE_NETCODE
143 extern int use_netrc;
144 #endif
146 void init_cpiofs (void);
147 void init_extfs (void);
148 void init_fish (void);
149 void init_sfs (void);
150 void init_tarfs (void);
151 void init_undelfs (void);
153 #endif /* USE_VFS */
155 #endif /* MC_VFS_IMPL_H */