This source file includes following definitions.
- vfs_s_store_filename_leading_spaces
1
2
3
4
5
6
7
8 #ifndef MC__VFS_XDIRENTRY_H
9 #define MC__VFS_XDIRENTRY_H
10
11 #include <stdio.h>
12 #include <sys/types.h>
13
14 #include "lib/global.h"
15 #include "lib/vfs/path.h"
16
17
18
19 #define LINK_FOLLOW 15
20 #define LINK_NO_FOLLOW -1
21
22
23 #define FL_NONE 0
24 #define FL_MKDIR 1
25 #define FL_MKFILE 2
26 #define FL_DIR 4
27
28
29 #define FL_NO_OPEN 1
30
31
32 #define FL_FOLLOW 1
33 #define FL_DIR 4
34
35 #define ERRNOR(a, b) do { me->verrno = a; return b; } while (0)
36
37 #define VFS_SUBCLASS(a) ((struct vfs_s_subclass *) (a))
38
39 #define VFS_SUPER(a) ((struct vfs_s_super *) (a))
40 #define VFS_ENTRY(a) ((struct vfs_s_entry *) (a))
41 #define VFS_INODE(a) ((struct vfs_s_inode *) (a))
42
43 #define VFS_FILE_HANDLER(a) ((vfs_file_handler_t *) a)
44 #define VFS_FILE_HANDLER_SUPER(a) VFS_FILE_HANDLER (a)->ino->super
45
46
47
48 typedef enum
49 {
50 LS_NOT_LINEAR = 0,
51 LS_LINEAR_CLOSED = 1,
52 LS_LINEAR_OPEN = 2,
53 LS_LINEAR_PREOPEN = 3
54 } vfs_linear_state_t;
55
56
57
58
59 struct vfs_s_super
60 {
61 struct vfs_class *me;
62 struct vfs_s_inode *root;
63 char *name;
64 int fd_usage;
65 int ino_usage;
66 gboolean want_stale;
67 #ifdef ENABLE_VFS_NET
68 vfs_path_element_t *path_element;
69 #endif
70 };
71
72
73
74
75
76 struct vfs_s_entry
77 {
78 struct vfs_s_inode *dir;
79 char *name;
80 struct vfs_s_inode *ino;
81 };
82
83
84 struct vfs_s_inode
85 {
86 struct vfs_s_super *super;
87 struct vfs_s_entry *ent;
88
89
90 GQueue *subdir;
91 struct stat st;
92 char *linkname;
93 char *localname;
94 gint64 timestamp;
95 off_t data_offset;
96 };
97
98
99 typedef struct
100 {
101 struct vfs_s_inode *ino;
102 off_t pos;
103 int handle;
104 gboolean changed;
105 vfs_linear_state_t linear;
106 } vfs_file_handler_t;
107
108
109
110
111
112 struct vfs_s_subclass
113 {
114 struct vfs_class base;
115
116 GList *supers;
117 int inode_counter;
118 dev_t rdev;
119
120
121 int (*init_inode) (struct vfs_class * me, struct vfs_s_inode * ino);
122 void (*free_inode) (struct vfs_class * me, struct vfs_s_inode * ino);
123 int (*init_entry) (struct vfs_class * me, struct vfs_s_entry * entry);
124
125 void *(*archive_check) (const vfs_path_t * vpath);
126 int (*archive_same) (const vfs_path_element_t * vpath_element, struct vfs_s_super * psup,
127 const vfs_path_t * vpath, void *cookie);
128 struct vfs_s_super *(*new_archive) (struct vfs_class * me);
129 int (*open_archive) (struct vfs_s_super * psup,
130 const vfs_path_t * vpath, const vfs_path_element_t * vpath_element);
131 void (*free_archive) (struct vfs_class * me, struct vfs_s_super * psup);
132
133 vfs_file_handler_t *(*fh_new) (struct vfs_s_inode * ino, gboolean changed);
134 int (*fh_open) (struct vfs_class * me, vfs_file_handler_t * fh, int flags, mode_t mode);
135 int (*fh_close) (struct vfs_class * me, vfs_file_handler_t * fh);
136 void (*fh_free) (vfs_file_handler_t * fh);
137
138 struct vfs_s_entry *(*find_entry) (struct vfs_class * me,
139 struct vfs_s_inode * root,
140 const char *path, int follow, int flags);
141 int (*dir_load) (struct vfs_class * me, struct vfs_s_inode * ino, char *path);
142 gboolean (*dir_uptodate) (struct vfs_class * me, struct vfs_s_inode * ino);
143 int (*file_store) (struct vfs_class * me, vfs_file_handler_t * fh, char *path, char *localname);
144
145 int (*linear_start) (struct vfs_class * me, vfs_file_handler_t * fh, off_t from);
146 ssize_t (*linear_read) (struct vfs_class * me, vfs_file_handler_t * fh, void *buf, size_t len);
147 void (*linear_close) (struct vfs_class * me, vfs_file_handler_t * fh);
148
149 };
150
151
152
153
154
155
156 struct vfs_s_inode *vfs_s_new_inode (struct vfs_class *me,
157 struct vfs_s_super *super, struct stat *initstat);
158 void vfs_s_free_inode (struct vfs_class *me, struct vfs_s_inode *ino);
159
160 struct vfs_s_entry *vfs_s_new_entry (struct vfs_class *me, const char *name,
161 struct vfs_s_inode *inode);
162 void vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent);
163 void vfs_s_insert_entry (struct vfs_class *me, struct vfs_s_inode *dir, struct vfs_s_entry *ent);
164 int vfs_s_entry_compare (const void *a, const void *b);
165 struct stat *vfs_s_default_stat (struct vfs_class *me, mode_t mode);
166
167 struct vfs_s_entry *vfs_s_generate_entry (struct vfs_class *me, const char *name,
168 struct vfs_s_inode *parent, mode_t mode);
169 struct vfs_s_inode *vfs_s_find_inode (struct vfs_class *me,
170 const struct vfs_s_super *super,
171 const char *path, int follow, int flags);
172 struct vfs_s_inode *vfs_s_find_root (struct vfs_class *me, struct vfs_s_entry *entry);
173
174
175 void vfs_init_subclass (struct vfs_s_subclass *sub, const char *name, vfs_flags_t flags,
176 const char *prefix);
177 const char *vfs_s_get_path (const vfs_path_t * vpath, struct vfs_s_super **archive, int flags);
178 struct vfs_s_super *vfs_get_super_by_vpath (const vfs_path_t * vpath);
179
180 void vfs_s_invalidate (struct vfs_class *me, struct vfs_s_super *super);
181 char *vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino);
182
183 void vfs_s_init_fh (vfs_file_handler_t * fh, struct vfs_s_inode *ino, gboolean changed);
184
185
186 int vfs_s_select_on_two (int fd1, int fd2);
187 int vfs_s_get_line (struct vfs_class *me, int sock, char *buf, int buf_len, char term);
188 int vfs_s_get_line_interruptible (struct vfs_class *me, char *buffer, int size, int fd);
189
190 int vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino);
191
192 void vfs_s_normalize_filename_leading_spaces (struct vfs_s_inode *root_inode, size_t final_filepos);
193
194
195
196 static inline void
197 vfs_s_store_filename_leading_spaces (struct vfs_s_entry *entry, size_t position)
198 {
199 entry->ino->data_offset = (off_t) position;
200 }
201
202 #endif