11 #include <sys/types.h>
23 #define LINK_FOLLOW 15
24 #define LINK_NO_FOLLOW -1
26 /* For vfs_s_find_entry */
35 /* For vfs_s_entry_from_path */
39 typedef struct vfs_s_entry
{
40 struct vfs_s_entry
**prevp
, *next
;
41 struct vfs_s_inode
*dir
; /* Directory we are in - needed for invalidating directory when file in it changes */
42 char *name
; /* Name of this entry */
43 struct vfs_s_inode
*ino
; /* ... and its inode */
45 #define ENTRY_MAGIC 0x014512563
48 typedef struct vfs_s_inode
{
49 struct vfs_s_entry
*subdir
;
50 struct vfs_s_super
*super
;
51 struct stat st
; /* Parameters of this inode */
52 char *linkname
; /* Symlink's contents */
53 char *localname
; /* Filename of local file, if we have one */
56 vfs_s_entry
*ent
; /* ftp needs this backpointer; don't use if you can avoid it */
66 struct timeval timestamp
;
67 struct stat local_stat
;
70 struct timeval timestamp
;
74 #define INODE_MAGIC 0x93451656
77 typedef struct vfs_s_super
{
78 struct vfs_s_super
**prevp
, *next
;
81 char *name
; /* My name, whatever it means */
82 int fd_usage
; /* Number of open files */
83 int ino_usage
; /* Usage count of this superblock */
84 int want_stale
; /* If set, we do not flush cache properly */
106 int failed_on_login
; /* used to pass the failure reason to upper levels */
107 int use_proxy
; /* use a proxy server */
109 int use_source_route
;
110 int use_passive_connection
;
111 int remote_is_amiga
; /* No leading slash allowed for AmiTCP (Amiga) */
113 int cwd_defered
; /* current_directory was changed but CWD command hasn't
115 int strict
; /* ftp server doesn't understand
116 "LIST -la <path>"; use "CWD <path>"/
118 #define RFC_AUTODETECT 0
125 int type
; /* Type of the archive */
126 /*int pos; In case reentrancy will be needed */
127 struct defer_inode
*defered
; /* List of inodes for which another entries may appear */
131 #define SUPER_MAGIC 0x915ac312
134 typedef struct vfs_s_fh
{
135 struct vfs_s_inode
*ino
;
136 long pos
; /* This is for module's use */
137 int handle
; /* This is for module's use, but if != -1, will be mc_close()d */
138 int changed
; /* Did this file change? */
139 int linear
; /* Is that file open with O_LINEAR? */
149 #define FH_MAGIC 0x91324682
153 struct vfs_s_super
*supers
;
158 int (*init_inode
) (vfs
*me
, vfs_s_inode
*ino
); /* optional */
159 void (*free_inode
) (vfs
*me
, vfs_s_inode
*ino
); /* optional */
160 int (*init_entry
) (vfs
*me
, vfs_s_entry
*entry
); /* optional */
162 void* (*archive_check
) (vfs
*me
, char *name
, char *op
); /* optional */
163 int (*archive_same
) (vfs
*me
, vfs_s_super
*psup
, char *archive_name
, char *op
, void *cookie
);
164 int (*open_archive
) (vfs
*me
, vfs_s_super
*psup
, char *archive_name
, char *op
);
165 void (*free_archive
) (vfs
*me
, vfs_s_super
*psup
);
167 int (*fh_open
) (vfs
*me
, vfs_s_fh
*fh
, int flags
, int mode
);
168 int (*fh_close
) (vfs
*me
, vfs_s_fh
*fh
);
170 vfs_s_entry
* (*find_entry
) (vfs
*me
, vfs_s_inode
*root
, char *path
, int follow
, int flags
);
171 int (*dir_load
) (vfs
*me
, vfs_s_inode
*ino
, char *path
);
172 int (*dir_uptodate
) (vfs
*me
, vfs_s_inode
*ino
);
173 int (*file_store
) (vfs
*me
, vfs_s_super
*super
, char *path
, char *localname
);
175 int (*linear_start
) (vfs
*me
, vfs_s_fh
*fh
, int from
);
176 int (*linear_read
) (vfs
*me
, vfs_s_fh
*fh
, void *buf
, int len
);
177 void (*linear_close
) (vfs
*me
, vfs_s_fh
*fh
);
180 /* entries and inodes */
181 vfs_s_inode
*vfs_s_new_inode (vfs
*me
, vfs_s_super
*super
,
182 struct stat
*initstat
);
183 vfs_s_entry
*vfs_s_new_entry (vfs
*me
, char *name
, vfs_s_inode
*inode
);
184 void vfs_s_free_entry (vfs
*me
, vfs_s_entry
*ent
);
185 void vfs_s_insert_entry (vfs
*me
, vfs_s_inode
*dir
,
187 struct stat
*vfs_s_default_stat (vfs
*me
, mode_t mode
);
189 void vfs_s_add_dots (vfs
*me
, vfs_s_inode
*dir
,
190 vfs_s_inode
*parent
);
191 vfs_s_entry
*vfs_s_generate_entry (vfs
*me
, char *name
,
192 struct vfs_s_inode
*parent
, mode_t mode
);
193 vfs_s_entry
*vfs_s_automake (vfs
*me
, vfs_s_inode
*dir
, char *path
,
195 vfs_s_entry
*vfs_s_find_entry_tree (vfs
*me
, vfs_s_inode
*root
, char *path
,
196 int follow
, int flags
);
197 vfs_s_entry
*vfs_s_find_entry_linear (vfs
*me
, vfs_s_inode
*root
, char *path
,
198 int follow
, int flags
);
199 vfs_s_inode
*vfs_s_find_inode (vfs
*me
, vfs_s_inode
*root
, char *path
,
200 int follow
, int flags
);
201 vfs_s_inode
*vfs_s_find_root (vfs
*me
, vfs_s_entry
*entry
);
202 vfs_s_entry
*vfs_s_resolve_symlink (vfs
*me
, vfs_s_entry
*entry
, char *path
,
205 /* superblock games */
206 vfs_s_super
*vfs_s_new_super (vfs
*me
);
207 void vfs_s_free_super (vfs
*me
, vfs_s_super
*super
);
209 /* outside interface */
210 char *vfs_s_get_path_mangle (vfs
*me
, char *inname
, vfs_s_super
**archive
,
212 char *vfs_s_get_path (vfs
*me
, char *inname
, vfs_s_super
**archive
,
214 void vfs_s_invalidate (vfs
*me
, vfs_s_super
*super
);
215 char *vfs_s_fullpath (vfs
*me
, vfs_s_inode
*ino
);
217 /* readdir & friends */
218 vfs_s_super
*vfs_s_super_from_path (vfs
*me
, char *name
);
219 vfs_s_inode
*vfs_s_inode_from_path (vfs
*me
, char *name
, int flags
);
220 void *vfs_s_opendir (vfs
*me
, char *dirname
);
221 void *vfs_s_readdir (void *data
);
222 int vfs_s_telldir (void *data
);
223 void vfs_s_seekdir (void *data
, int offset
);
224 int vfs_s_closedir (void *data
);
225 int vfs_s_chdir (vfs
*me
, char *path
);
228 int vfs_s_stat (vfs
*me
, char *path
, struct stat
*buf
);
229 int vfs_s_lstat (vfs
*me
, char *path
, struct stat
*buf
);
230 int vfs_s_fstat (void *fh
, struct stat
*buf
);
231 int vfs_s_readlink (vfs
*me
, char *path
, char *buf
, int size
);
232 void *vfs_s_open (vfs
*me
, char *file
, int flags
, int mode
);
233 int vfs_s_read (void *fh
, char *buffer
, int count
);
234 int vfs_s_write (void *fh
, char *buffer
, int count
);
235 int vfs_s_lseek (void *fh
, off_t offset
, int whence
);
236 int vfs_s_close (void *fh
);
239 void vfs_s_fill_names (vfs
*me
, void (*func
)(char *));
240 int vfs_s_ferrno(vfs
*me
);
241 void vfs_s_dump(vfs
*me
, char *prefix
, vfs_s_inode
*ino
);
242 char *vfs_s_getlocalcopy (vfs
*me
, char *path
);
244 /* stamping support */
245 vfsid
vfs_s_getid (vfs
*me
, char *path
, struct vfs_stamping
**parent
);
246 int vfs_s_nothingisopen (vfsid id
);
247 void vfs_s_free (vfsid id
);
248 int vfs_s_setctl (vfs
*me
, char *path
, int ctlop
, char *arg
);
250 /* network filesystems support */
251 int vfs_s_select_on_two (int fd1
, int fd2
);
252 int vfs_s_get_line (vfs
*me
, int sock
, char *buf
, int buf_len
, char term
);
253 int vfs_s_get_line_interruptible (vfs
*me
, char *buffer
, int size
, int fd
);
256 int vfs_s_retrieve_file (vfs
*me
, struct vfs_s_inode
*ino
);
259 /* If non-null, FREE */
260 #define ifree(ptr) do { if (ptr) g_free(ptr); } while (0)
261 #define ERRNOR(a, b) do { me->verrno = a; return b; } while (0)
263 #define ifree(ptr) { if (ptr) g_free(ptr); }
264 #define ERRNOR(a, b) { me->verrno = a; return b; }
267 #define MEDATA ((struct vfs_s_data *) me->data)
269 #define FH ((struct vfs_s_fh *) fh)
270 #define FH_SUPER FH->ino->super
272 #define LS_NOT_LINEAR 0
273 #define LS_LINEAR_CLOSED 1
274 #define LS_LINEAR_OPEN 2