4 * \brief Header: Virtual File System directory structure
8 #ifndef MC_VFS_XDIRENTRY_H
9 #define MC_VFS_XDIRENTRY_H
13 #include <sys/types.h>
15 #define LINK_FOLLOW 15
16 #define LINK_NO_FOLLOW -1
18 /* For vfs_s_find_entry */
27 /* For vfs_s_entry_from_path */
31 /* For vfs_s_subclass->flags */
32 #define VFS_S_REMOTE 1
33 #define VFS_S_READONLY 2
36 /* Single connection or archive */
38 struct vfs_s_super
**prevp
, *next
;
40 struct vfs_s_inode
*root
;
41 char *name
; /* My name, whatever it means */
42 int fd_usage
; /* Number of open files */
43 int ino_usage
; /* Usage count of this superblock */
44 int want_stale
; /* If set, we do not flush cache properly */
61 char *proxy
; /* proxy server, NULL if no proxy */
62 int failed_on_login
; /* used to pass the failure reason to upper levels */
63 int use_passive_connection
;
64 int remote_is_amiga
; /* No leading slash allowed for AmiTCP (Amiga) */
66 int cwd_deferred
; /* current_directory was changed but CWD command hasn't
68 int strict
; /* ftp server doesn't understand
69 "LIST -la <path>"; use "CWD <path>"/
71 int ctl_connection_busy
;
76 int type
; /* Type of the archive */
77 struct defer_inode
*deferred
; /* List of inodes for which another entries may appear */
83 * Single virtual file - directory entry. The same inode can have many
84 * entries (i.e. hard links), but usually has only one.
87 struct vfs_s_entry
**prevp
, *next
; /* Pointers in the entry list */
88 struct vfs_s_inode
*dir
; /* Directory we are in, i.e. our parent */
89 char *name
; /* Name of this entry */
90 struct vfs_s_inode
*ino
; /* ... and its inode */
93 /* Single virtual file - inode */
95 struct vfs_s_super
*super
; /* Archive the file is on */
96 struct vfs_s_entry
*ent
; /* Our entry in the parent directory -
97 use only for directories because they
98 cannot be hardlinked */
99 struct vfs_s_entry
*subdir
; /* If this is a directory, its entry */
100 struct stat st
; /* Parameters of this inode */
101 char *linkname
; /* Symlink's contents */
102 char *localname
; /* Filename of local file, if we have one */
103 struct timeval timestamp
; /* Subclass specific */
104 long data_offset
; /* Subclass specific */
107 /* Data associated with an open file */
109 struct vfs_s_inode
*ino
;
110 long pos
; /* This is for module's use */
111 int handle
; /* This is for module's use, but if != -1, will be mc_close()d */
112 int changed
; /* Did this file change? */
113 int linear
; /* Is that file open with O_LINEAR? */
126 * One of our subclasses (tar, cpio, fish, ftpfs) with data and methods.
127 * Extends vfs_class. Stored in the "data" field of vfs_class.
129 struct vfs_s_subclass
{
130 struct vfs_s_super
*supers
;
132 int flags
; /* whether the subclass is remove, read-only etc */
135 int flush
; /* if set to 1, invalidate directory cache */
137 int (*init_inode
) (struct vfs_class
*me
, struct vfs_s_inode
*ino
); /* optional */
138 void (*free_inode
) (struct vfs_class
*me
, struct vfs_s_inode
*ino
); /* optional */
139 int (*init_entry
) (struct vfs_class
*me
, struct vfs_s_entry
*entry
); /* optional */
141 void *(*archive_check
) (struct vfs_class
*me
, const char *name
, char *op
); /* optional */
142 int (*archive_same
) (struct vfs_class
*me
, struct vfs_s_super
*psup
,
143 const char *archive_name
, char *op
, void *cookie
);
144 int (*open_archive
) (struct vfs_class
*me
, struct vfs_s_super
*psup
,
145 const char *archive_name
, char *op
);
146 void (*free_archive
) (struct vfs_class
*me
,
147 struct vfs_s_super
*psup
);
149 int (*fh_open
) (struct vfs_class
*me
, struct vfs_s_fh
*fh
, int flags
,
151 int (*fh_close
) (struct vfs_class
*me
, struct vfs_s_fh
*fh
);
153 struct vfs_s_entry
*(*find_entry
) (struct vfs_class
*me
,
154 struct vfs_s_inode
*root
,
155 const char *path
, int follow
, int flags
);
156 int (*dir_load
) (struct vfs_class
*me
, struct vfs_s_inode
*ino
,
158 int (*dir_uptodate
) (struct vfs_class
*me
, struct vfs_s_inode
*ino
);
159 int (*file_store
) (struct vfs_class
*me
, struct vfs_s_fh
*fh
,
160 char *path
, char *localname
);
162 int (*linear_start
) (struct vfs_class
*me
, struct vfs_s_fh
*fh
,
164 int (*linear_read
) (struct vfs_class
*me
, struct vfs_s_fh
*fh
,
166 void (*linear_close
) (struct vfs_class
*me
, struct vfs_s_fh
*fh
);
170 /* entries and inodes */
171 struct vfs_s_inode
*vfs_s_new_inode (struct vfs_class
*me
,
172 struct vfs_s_super
*super
,
173 struct stat
*initstat
);
174 struct vfs_s_entry
*vfs_s_new_entry (struct vfs_class
*me
, const char *name
,
175 struct vfs_s_inode
*inode
);
176 void vfs_s_free_entry (struct vfs_class
*me
, struct vfs_s_entry
*ent
);
177 void vfs_s_insert_entry (struct vfs_class
*me
, struct vfs_s_inode
*dir
,
178 struct vfs_s_entry
*ent
);
179 struct stat
*vfs_s_default_stat (struct vfs_class
*me
, mode_t mode
);
181 struct vfs_s_entry
*vfs_s_generate_entry (struct vfs_class
*me
, const char *name
,
182 struct vfs_s_inode
*parent
,
184 struct vfs_s_inode
*vfs_s_find_inode (struct vfs_class
*me
,
185 const struct vfs_s_super
*super
,
186 const char *path
, int follow
, int flags
);
187 struct vfs_s_inode
*vfs_s_find_root (struct vfs_class
*me
,
188 struct vfs_s_entry
*entry
);
190 /* outside interface */
191 void vfs_s_init_class (struct vfs_class
*vclass
,
192 struct vfs_s_subclass
*sub
);
193 const char *vfs_s_get_path_mangle (struct vfs_class
*me
, char *inname
,
194 struct vfs_s_super
**archive
, int flags
);
195 void vfs_s_invalidate (struct vfs_class
*me
, struct vfs_s_super
*super
);
196 char *vfs_s_fullpath (struct vfs_class
*me
, struct vfs_s_inode
*ino
);
198 /* network filesystems support */
199 int vfs_s_select_on_two (int fd1
, int fd2
);
200 int vfs_s_get_line (struct vfs_class
*me
, int sock
, char *buf
, int buf_len
,
202 int vfs_s_get_line_interruptible (struct vfs_class
*me
, char *buffer
,
206 int vfs_s_retrieve_file (struct vfs_class
*me
, struct vfs_s_inode
*ino
);
208 #define ERRNOR(a, b) do { me->verrno = a; return b; } while (0)
210 #define MEDATA ((struct vfs_s_subclass *) me->data)
212 #define FH ((struct vfs_s_fh *) fh)
213 #define FH_SUPER FH->ino->super
215 #define LS_NOT_LINEAR 0
216 #define LS_LINEAR_CLOSED 1
217 #define LS_LINEAR_OPEN 2
218 #define LS_LINEAR_PREOPEN 3