changed the HQ to http://www.midnight-commander.org/
[midnight-commander.git] / vfs / vfs-impl.h
blob21752ebcd65b1aed8e378cb390d267403f65dad9
1 #ifndef MC_VFS_IMPL_H
2 #define MC_VFS_IMPL_H
4 #ifdef USE_VFS
6 #include <stddef.h>
8 typedef void *vfsid;
9 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 */
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().
21 typedef void (*fill_names_f) (const char *);
23 struct vfs_class {
24 struct vfs_class *next;
25 const char *name; /* "FIles over SHell" */
26 int flags;
27 const char *prefix; /* "fish:" */
28 void *data; /* this is for filesystem's own use */
29 int verrno; /* can't use errno because glibc2 might define errno as function */
31 int (*init) (struct vfs_class *me);
32 void (*done) (struct vfs_class *me);
34 /**
35 * The fill_names method shall call the callback function for every
36 * filesystem name that this vfs module supports.
38 void (*fill_names) (struct vfs_class *me, fill_names_f);
40 /**
41 * The which() method shall return the index of the vfs subsystem
42 * or -1 if this vfs cannot handle the given pathname.
44 int (*which) (struct vfs_class *me, const char *path);
46 void *(*open) (struct vfs_class *me, const char *fname, int flags,
47 int mode);
48 int (*close) (void *vfs_info);
49 int (*read) (void *vfs_info, char *buffer, int count);
50 int (*write) (void *vfs_info, const char *buf, int count);
52 void *(*opendir) (struct vfs_class *me, const char *dirname);
53 void *(*readdir) (void *vfs_info);
54 int (*closedir) (void *vfs_info);
56 int (*stat) (struct vfs_class *me, const char *path, struct stat * buf);
57 int (*lstat) (struct vfs_class *me, const char *path, struct stat * buf);
58 int (*fstat) (void *vfs_info, struct stat * buf);
60 int (*chmod) (struct vfs_class *me, const char *path, int mode);
61 int (*chown) (struct vfs_class *me, const char *path, int owner, int group);
62 int (*utime) (struct vfs_class *me, const char *path,
63 struct utimbuf * times);
65 int (*readlink) (struct vfs_class *me, const char *path, char *buf,
66 size_t size);
67 int (*symlink) (struct vfs_class *me, const char *n1, const char *n2);
68 int (*link) (struct vfs_class *me, const char *p1, const char *p2);
69 int (*unlink) (struct vfs_class *me, const char *path);
70 int (*rename) (struct vfs_class *me, const char *p1, const char *p2);
71 int (*chdir) (struct vfs_class *me, const char *path);
72 int (*ferrno) (struct vfs_class *me);
73 int (*lseek) (void *vfs_info, off_t offset, int whence);
74 int (*mknod) (struct vfs_class *me, const char *path, int mode, int dev);
76 vfsid (*getid) (struct vfs_class *me, const char *path);
78 int (*nothingisopen) (vfsid id);
79 void (*free) (vfsid id);
81 char *(*getlocalcopy) (struct vfs_class *me, const char *filename);
82 int (*ungetlocalcopy) (struct vfs_class *me, const char *filename,
83 const char *local, int has_changed);
85 int (*mkdir) (struct vfs_class *me, const char *path, mode_t mode);
86 int (*rmdir) (struct vfs_class *me, const char *path);
88 int (*ctl) (void *vfs_info, int ctlop, void *arg);
89 int (*setctl) (struct vfs_class *me, const char *path, int ctlop,
90 void *arg);
94 * This union is used to ensure that there is enough space for the
95 * filename (d_name) when the dirent structure is created.
97 union vfs_dirent {
98 struct dirent dent;
99 char _extra_buffer[offsetof(struct dirent, d_name) + MC_MAXPATHLEN + 1];
102 /* Register a file system class */
103 int vfs_register_class (struct vfs_class *vfs);
105 #ifdef WITH_SMBFS
106 /* Interface for requesting SMB credentials. */
107 struct smb_authinfo {
108 char *host;
109 char *share;
110 char *domain;
111 char *user;
112 char *password;
115 struct smb_authinfo *vfs_smb_get_authinfo (const char *host,
116 const char *share,
117 const char *domain,
118 const char *user);
119 #endif /* WITH_SMBFS */
121 struct vfs_class *vfs_get_class (const char *path);
122 struct vfs_class *vfs_split (char *path, char **inpath, char **op);
123 char *vfs_path (const char *path);
124 int vfs_file_class_flags (const char *filename);
126 void vfs_fill_names (fill_names_f);
127 char *vfs_translate_url (const char *);
129 #ifdef USE_NETCODE
130 extern int use_netrc;
131 #endif
133 void init_cpiofs (void);
134 void init_extfs (void);
135 void init_fish (void);
136 void init_sfs (void);
137 void init_tarfs (void);
138 void init_undelfs (void);
140 #endif /* USE_VFS */
142 #endif /* MC_VFS_IMPL_H */