10 #include <sys/types.h>
22 #define LINK_FOLLOW 15
23 #define LINK_NO_FOLLOW -1
25 /* For vfs_s_find_entry */
34 /* For vfs_s_entry_from_path */
38 typedef struct vfs_s_entry
{
39 struct vfs_s_entry
**prevp
, *next
;
40 struct vfs_s_inode
*dir
; /* Directory we are in - needed for invalidating directory when file in it changes */
41 char *name
; /* Name of this entry */
42 struct vfs_s_inode
*ino
; /* ... and its inode */
44 #define ENTRY_MAGIC 0x014512563
47 typedef struct vfs_s_inode
{
48 struct vfs_s_entry
*subdir
;
49 struct vfs_s_super
*super
;
50 struct stat st
; /* Parameters of this inode */
51 char *linkname
; /* Symlink's contents */
52 char *localname
; /* Filename of local file, if we have one */
55 vfs_s_entry
*ent
; /* ftp needs this backpointer; don't use if you can avoid it */
65 struct timeval timestamp
;
66 struct stat local_stat
;
69 struct timeval timestamp
;
73 #define INODE_MAGIC 0x93451656
76 typedef struct vfs_s_super
{
77 struct vfs_s_super
**prevp
, *next
;
80 char *name
; /* My name, whatever it means */
81 int fd_usage
; /* Number of open files */
82 int ino_usage
; /* Usage count of this superblock */
83 int want_stale
; /* If set, we do not flush cache properly */
104 char *proxy
; /* proxy server, NULL if no proxy */
105 int failed_on_login
; /* used to pass the failure reason to upper levels */
106 int use_source_route
;
107 int use_passive_connection
;
108 int remote_is_amiga
; /* No leading slash allowed for AmiTCP (Amiga) */
110 int cwd_defered
; /* current_directory was changed but CWD command hasn't
112 int strict
; /* ftp server doesn't understand
113 "LIST -la <path>"; use "CWD <path>"/
115 int control_connection_buzy
;
116 #define RFC_AUTODETECT 0
123 int type
; /* Type of the archive */
124 /*int pos; In case reentrancy will be needed */
125 struct defer_inode
*defered
; /* List of inodes for which another entries may appear */
129 #define SUPER_MAGIC 0x915ac312
132 typedef struct vfs_s_fh
{
133 struct vfs_s_inode
*ino
;
134 long pos
; /* This is for module's use */
135 int handle
; /* This is for module's use, but if != -1, will be mc_close()d */
136 int changed
; /* Did this file change? */
137 int linear
; /* Is that file open with O_LINEAR? */
140 int got
, total
, append
;
147 #define FH_MAGIC 0x91324682
151 struct vfs_s_super
*supers
;
156 int (*init_inode
) (vfs
*me
, vfs_s_inode
*ino
); /* optional */
157 void (*free_inode
) (vfs
*me
, vfs_s_inode
*ino
); /* optional */
158 int (*init_entry
) (vfs
*me
, vfs_s_entry
*entry
); /* optional */
160 void* (*archive_check
) (vfs
*me
, char *name
, char *op
); /* optional */
161 int (*archive_same
) (vfs
*me
, vfs_s_super
*psup
, char *archive_name
, char *op
, void *cookie
);
162 int (*open_archive
) (vfs
*me
, vfs_s_super
*psup
, char *archive_name
, char *op
);
163 void (*free_archive
) (vfs
*me
, vfs_s_super
*psup
);
165 int (*fh_open
) (vfs
*me
, vfs_s_fh
*fh
, int flags
, int mode
);
166 int (*fh_close
) (vfs
*me
, vfs_s_fh
*fh
);
168 vfs_s_entry
* (*find_entry
) (vfs
*me
, vfs_s_inode
*root
, char *path
, int follow
, int flags
);
169 int (*dir_load
) (vfs
*me
, vfs_s_inode
*ino
, char *path
);
170 int (*dir_uptodate
) (vfs
*me
, vfs_s_inode
*ino
);
171 int (*file_store
) (vfs
*me
, vfs_s_fh
*fh
, char *path
, char *localname
);
173 int (*linear_start
) (vfs
*me
, vfs_s_fh
*fh
, int from
);
174 int (*linear_read
) (vfs
*me
, vfs_s_fh
*fh
, void *buf
, int len
);
175 void (*linear_close
) (vfs
*me
, vfs_s_fh
*fh
);
178 /* entries and inodes */
179 vfs_s_inode
*vfs_s_new_inode (vfs
*me
, vfs_s_super
*super
,
180 struct stat
*initstat
);
181 vfs_s_entry
*vfs_s_new_entry (vfs
*me
, char *name
, vfs_s_inode
*inode
);
182 void vfs_s_free_entry (vfs
*me
, vfs_s_entry
*ent
);
183 void vfs_s_insert_entry (vfs
*me
, vfs_s_inode
*dir
,
185 struct stat
*vfs_s_default_stat (vfs
*me
, mode_t mode
);
187 void vfs_s_add_dots (vfs
*me
, vfs_s_inode
*dir
,
188 vfs_s_inode
*parent
);
189 vfs_s_entry
*vfs_s_generate_entry (vfs
*me
, char *name
,
190 struct vfs_s_inode
*parent
, mode_t mode
);
191 vfs_s_entry
*vfs_s_automake (vfs
*me
, vfs_s_inode
*dir
, char *path
,
193 vfs_s_entry
*vfs_s_find_entry_tree (vfs
*me
, vfs_s_inode
*root
, char *path
,
194 int follow
, int flags
);
195 vfs_s_entry
*vfs_s_find_entry_linear (vfs
*me
, vfs_s_inode
*root
, char *path
,
196 int follow
, int flags
);
197 vfs_s_inode
*vfs_s_find_inode (vfs
*me
, vfs_s_inode
*root
, char *path
,
198 int follow
, int flags
);
199 vfs_s_inode
*vfs_s_find_root (vfs
*me
, vfs_s_entry
*entry
);
200 vfs_s_entry
*vfs_s_resolve_symlink (vfs
*me
, vfs_s_entry
*entry
, char *path
,
203 /* superblock games */
204 vfs_s_super
*vfs_s_new_super (vfs
*me
);
205 void vfs_s_free_super (vfs
*me
, vfs_s_super
*super
);
207 /* outside interface */
208 char *vfs_s_get_path_mangle (vfs
*me
, char *inname
, vfs_s_super
**archive
,
210 char *vfs_s_get_path (vfs
*me
, char *inname
, vfs_s_super
**archive
,
212 void vfs_s_invalidate (vfs
*me
, vfs_s_super
*super
);
213 char *vfs_s_fullpath (vfs
*me
, vfs_s_inode
*ino
);
215 /* readdir & friends */
216 vfs_s_super
*vfs_s_super_from_path (vfs
*me
, char *name
);
217 vfs_s_inode
*vfs_s_inode_from_path (vfs
*me
, char *name
, int flags
);
218 void *vfs_s_opendir (vfs
*me
, char *dirname
);
219 void *vfs_s_readdir (void *data
);
220 int vfs_s_telldir (void *data
);
221 void vfs_s_seekdir (void *data
, int offset
);
222 int vfs_s_closedir (void *data
);
223 int vfs_s_chdir (vfs
*me
, char *path
);
226 int vfs_s_stat (vfs
*me
, char *path
, struct stat
*buf
);
227 int vfs_s_lstat (vfs
*me
, char *path
, struct stat
*buf
);
228 int vfs_s_fstat (void *fh
, struct stat
*buf
);
229 int vfs_s_readlink (vfs
*me
, char *path
, char *buf
, int size
);
230 void *vfs_s_open (vfs
*me
, char *file
, int flags
, int mode
);
231 int vfs_s_read (void *fh
, char *buffer
, int count
);
232 int vfs_s_write (void *fh
, char *buffer
, int count
);
233 int vfs_s_lseek (void *fh
, off_t offset
, int whence
);
234 int vfs_s_close (void *fh
);
237 void vfs_s_fill_names (vfs
*me
, void (*func
)(char *));
238 int vfs_s_ferrno(vfs
*me
);
239 void vfs_s_dump(vfs
*me
, char *prefix
, vfs_s_inode
*ino
);
240 char *vfs_s_getlocalcopy (vfs
*me
, char *path
);
242 /* stamping support */
243 vfsid
vfs_s_getid (vfs
*me
, char *path
, struct vfs_stamping
**parent
);
244 int vfs_s_nothingisopen (vfsid id
);
245 void vfs_s_free (vfsid id
);
246 int vfs_s_setctl (vfs
*me
, char *path
, int ctlop
, char *arg
);
248 /* network filesystems support */
249 int vfs_s_select_on_two (int fd1
, int fd2
);
250 int vfs_s_get_line (vfs
*me
, int sock
, char *buf
, int buf_len
, char term
);
251 int vfs_s_get_line_interruptible (vfs
*me
, char *buffer
, int size
, int fd
);
254 int vfs_s_retrieve_file (vfs
*me
, struct vfs_s_inode
*ino
);
257 #define ERRNOR(a, b) do { me->verrno = a; return b; } while (0)
259 #define ERRNOR(a, b) { me->verrno = a; return b; }
262 #define MEDATA ((struct vfs_s_data *) me->data)
264 #define FH ((struct vfs_s_fh *) fh)
265 #define FH_SUPER FH->ino->super
267 #define LS_NOT_LINEAR 0
268 #define LS_LINEAR_CLOSED 1
269 #define LS_LINEAR_OPEN 2