diff options
Diffstat (limited to 'fs/overlayfs/overlayfs.h')
-rw-r--r-- | fs/overlayfs/overlayfs.h | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 7538b9b56237..f61839e1054c 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/uuid.h> | 11 | #include <linux/uuid.h> |
12 | #include <linux/fs.h> | ||
12 | #include "ovl_entry.h" | 13 | #include "ovl_entry.h" |
13 | 14 | ||
14 | enum ovl_path_type { | 15 | enum ovl_path_type { |
@@ -28,6 +29,7 @@ enum ovl_path_type { | |||
28 | #define OVL_XATTR_IMPURE OVL_XATTR_PREFIX "impure" | 29 | #define OVL_XATTR_IMPURE OVL_XATTR_PREFIX "impure" |
29 | #define OVL_XATTR_NLINK OVL_XATTR_PREFIX "nlink" | 30 | #define OVL_XATTR_NLINK OVL_XATTR_PREFIX "nlink" |
30 | #define OVL_XATTR_UPPER OVL_XATTR_PREFIX "upper" | 31 | #define OVL_XATTR_UPPER OVL_XATTR_PREFIX "upper" |
32 | #define OVL_XATTR_METACOPY OVL_XATTR_PREFIX "metacopy" | ||
31 | 33 | ||
32 | enum ovl_inode_flag { | 34 | enum ovl_inode_flag { |
33 | /* Pure upper dir that may contain non pure upper entries */ | 35 | /* Pure upper dir that may contain non pure upper entries */ |
@@ -35,6 +37,9 @@ enum ovl_inode_flag { | |||
35 | /* Non-merge dir that may contain whiteout entries */ | 37 | /* Non-merge dir that may contain whiteout entries */ |
36 | OVL_WHITEOUTS, | 38 | OVL_WHITEOUTS, |
37 | OVL_INDEX, | 39 | OVL_INDEX, |
40 | OVL_UPPERDATA, | ||
41 | /* Inode number will remain constant over copy up. */ | ||
42 | OVL_CONST_INO, | ||
38 | }; | 43 | }; |
39 | 44 | ||
40 | enum ovl_entry_flag { | 45 | enum ovl_entry_flag { |
@@ -190,6 +195,14 @@ static inline struct dentry *ovl_do_tmpfile(struct dentry *dentry, umode_t mode) | |||
190 | return ret; | 195 | return ret; |
191 | } | 196 | } |
192 | 197 | ||
198 | static inline bool ovl_open_flags_need_copy_up(int flags) | ||
199 | { | ||
200 | if (!flags) | ||
201 | return false; | ||
202 | |||
203 | return ((OPEN_FMODE(flags) & FMODE_WRITE) || (flags & O_TRUNC)); | ||
204 | } | ||
205 | |||
193 | /* util.c */ | 206 | /* util.c */ |
194 | int ovl_want_write(struct dentry *dentry); | 207 | int ovl_want_write(struct dentry *dentry); |
195 | void ovl_drop_write(struct dentry *dentry); | 208 | void ovl_drop_write(struct dentry *dentry); |
@@ -206,15 +219,19 @@ bool ovl_dentry_weird(struct dentry *dentry); | |||
206 | enum ovl_path_type ovl_path_type(struct dentry *dentry); | 219 | enum ovl_path_type ovl_path_type(struct dentry *dentry); |
207 | void ovl_path_upper(struct dentry *dentry, struct path *path); | 220 | void ovl_path_upper(struct dentry *dentry, struct path *path); |
208 | void ovl_path_lower(struct dentry *dentry, struct path *path); | 221 | void ovl_path_lower(struct dentry *dentry, struct path *path); |
222 | void ovl_path_lowerdata(struct dentry *dentry, struct path *path); | ||
209 | enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path); | 223 | enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path); |
210 | struct dentry *ovl_dentry_upper(struct dentry *dentry); | 224 | struct dentry *ovl_dentry_upper(struct dentry *dentry); |
211 | struct dentry *ovl_dentry_lower(struct dentry *dentry); | 225 | struct dentry *ovl_dentry_lower(struct dentry *dentry); |
226 | struct dentry *ovl_dentry_lowerdata(struct dentry *dentry); | ||
212 | struct ovl_layer *ovl_layer_lower(struct dentry *dentry); | 227 | struct ovl_layer *ovl_layer_lower(struct dentry *dentry); |
213 | struct dentry *ovl_dentry_real(struct dentry *dentry); | 228 | struct dentry *ovl_dentry_real(struct dentry *dentry); |
214 | struct dentry *ovl_i_dentry_upper(struct inode *inode); | 229 | struct dentry *ovl_i_dentry_upper(struct inode *inode); |
215 | struct inode *ovl_inode_upper(struct inode *inode); | 230 | struct inode *ovl_inode_upper(struct inode *inode); |
216 | struct inode *ovl_inode_lower(struct inode *inode); | 231 | struct inode *ovl_inode_lower(struct inode *inode); |
232 | struct inode *ovl_inode_lowerdata(struct inode *inode); | ||
217 | struct inode *ovl_inode_real(struct inode *inode); | 233 | struct inode *ovl_inode_real(struct inode *inode); |
234 | struct inode *ovl_inode_realdata(struct inode *inode); | ||
218 | struct ovl_dir_cache *ovl_dir_cache(struct inode *inode); | 235 | struct ovl_dir_cache *ovl_dir_cache(struct inode *inode); |
219 | void ovl_set_dir_cache(struct inode *inode, struct ovl_dir_cache *cache); | 236 | void ovl_set_dir_cache(struct inode *inode, struct ovl_dir_cache *cache); |
220 | void ovl_dentry_set_flag(unsigned long flag, struct dentry *dentry); | 237 | void ovl_dentry_set_flag(unsigned long flag, struct dentry *dentry); |
@@ -225,18 +242,23 @@ bool ovl_dentry_is_whiteout(struct dentry *dentry); | |||
225 | void ovl_dentry_set_opaque(struct dentry *dentry); | 242 | void ovl_dentry_set_opaque(struct dentry *dentry); |
226 | bool ovl_dentry_has_upper_alias(struct dentry *dentry); | 243 | bool ovl_dentry_has_upper_alias(struct dentry *dentry); |
227 | void ovl_dentry_set_upper_alias(struct dentry *dentry); | 244 | void ovl_dentry_set_upper_alias(struct dentry *dentry); |
245 | bool ovl_dentry_needs_data_copy_up(struct dentry *dentry, int flags); | ||
246 | bool ovl_dentry_needs_data_copy_up_locked(struct dentry *dentry, int flags); | ||
247 | bool ovl_has_upperdata(struct inode *inode); | ||
248 | void ovl_set_upperdata(struct inode *inode); | ||
228 | bool ovl_redirect_dir(struct super_block *sb); | 249 | bool ovl_redirect_dir(struct super_block *sb); |
229 | const char *ovl_dentry_get_redirect(struct dentry *dentry); | 250 | const char *ovl_dentry_get_redirect(struct dentry *dentry); |
230 | void ovl_dentry_set_redirect(struct dentry *dentry, const char *redirect); | 251 | void ovl_dentry_set_redirect(struct dentry *dentry, const char *redirect); |
231 | void ovl_inode_init(struct inode *inode, struct dentry *upperdentry, | 252 | void ovl_inode_init(struct inode *inode, struct dentry *upperdentry, |
232 | struct dentry *lowerdentry); | 253 | struct dentry *lowerdentry, struct dentry *lowerdata); |
233 | void ovl_inode_update(struct inode *inode, struct dentry *upperdentry); | 254 | void ovl_inode_update(struct inode *inode, struct dentry *upperdentry); |
234 | void ovl_dentry_version_inc(struct dentry *dentry, bool impurity); | 255 | void ovl_dir_modified(struct dentry *dentry, bool impurity); |
235 | u64 ovl_dentry_version_get(struct dentry *dentry); | 256 | u64 ovl_dentry_version_get(struct dentry *dentry); |
236 | bool ovl_is_whiteout(struct dentry *dentry); | 257 | bool ovl_is_whiteout(struct dentry *dentry); |
237 | struct file *ovl_path_open(struct path *path, int flags); | 258 | struct file *ovl_path_open(struct path *path, int flags); |
238 | int ovl_copy_up_start(struct dentry *dentry); | 259 | int ovl_copy_up_start(struct dentry *dentry, int flags); |
239 | void ovl_copy_up_end(struct dentry *dentry); | 260 | void ovl_copy_up_end(struct dentry *dentry); |
261 | bool ovl_already_copied_up(struct dentry *dentry, int flags); | ||
240 | bool ovl_check_origin_xattr(struct dentry *dentry); | 262 | bool ovl_check_origin_xattr(struct dentry *dentry); |
241 | bool ovl_check_dir_xattr(struct dentry *dentry, const char *name); | 263 | bool ovl_check_dir_xattr(struct dentry *dentry, const char *name); |
242 | int ovl_check_setxattr(struct dentry *dentry, struct dentry *upperdentry, | 264 | int ovl_check_setxattr(struct dentry *dentry, struct dentry *upperdentry, |
@@ -252,6 +274,9 @@ bool ovl_need_index(struct dentry *dentry); | |||
252 | int ovl_nlink_start(struct dentry *dentry, bool *locked); | 274 | int ovl_nlink_start(struct dentry *dentry, bool *locked); |
253 | void ovl_nlink_end(struct dentry *dentry, bool locked); | 275 | void ovl_nlink_end(struct dentry *dentry, bool locked); |
254 | int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir); | 276 | int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir); |
277 | int ovl_check_metacopy_xattr(struct dentry *dentry); | ||
278 | bool ovl_is_metacopy_dentry(struct dentry *dentry); | ||
279 | char *ovl_get_redirect_xattr(struct dentry *dentry, int padding); | ||
255 | 280 | ||
256 | static inline bool ovl_is_impuredir(struct dentry *dentry) | 281 | static inline bool ovl_is_impuredir(struct dentry *dentry) |
257 | { | 282 | { |
@@ -324,7 +349,6 @@ int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name, | |||
324 | void *value, size_t size); | 349 | void *value, size_t size); |
325 | ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); | 350 | ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); |
326 | struct posix_acl *ovl_get_acl(struct inode *inode, int type); | 351 | struct posix_acl *ovl_get_acl(struct inode *inode, int type); |
327 | int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags); | ||
328 | int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags); | 352 | int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags); |
329 | bool ovl_is_private_xattr(const char *name); | 353 | bool ovl_is_private_xattr(const char *name); |
330 | 354 | ||
@@ -334,6 +358,8 @@ struct ovl_inode_params { | |||
334 | struct ovl_path *lowerpath; | 358 | struct ovl_path *lowerpath; |
335 | struct dentry *index; | 359 | struct dentry *index; |
336 | unsigned int numlower; | 360 | unsigned int numlower; |
361 | char *redirect; | ||
362 | struct dentry *lowerdata; | ||
337 | }; | 363 | }; |
338 | struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, dev_t rdev); | 364 | struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, dev_t rdev); |
339 | struct inode *ovl_lookup_inode(struct super_block *sb, struct dentry *real, | 365 | struct inode *ovl_lookup_inode(struct super_block *sb, struct dentry *real, |
@@ -348,6 +374,14 @@ static inline void ovl_copyattr(struct inode *from, struct inode *to) | |||
348 | to->i_atime = from->i_atime; | 374 | to->i_atime = from->i_atime; |
349 | to->i_mtime = from->i_mtime; | 375 | to->i_mtime = from->i_mtime; |
350 | to->i_ctime = from->i_ctime; | 376 | to->i_ctime = from->i_ctime; |
377 | i_size_write(to, i_size_read(from)); | ||
378 | } | ||
379 | |||
380 | static inline void ovl_copyflags(struct inode *from, struct inode *to) | ||
381 | { | ||
382 | unsigned int mask = S_SYNC | S_IMMUTABLE | S_APPEND | S_NOATIME; | ||
383 | |||
384 | inode_set_flags(to, from->i_flags & mask, mask); | ||
351 | } | 385 | } |
352 | 386 | ||
353 | /* dir.c */ | 387 | /* dir.c */ |
@@ -368,9 +402,14 @@ struct dentry *ovl_create_real(struct inode *dir, struct dentry *newdentry, | |||
368 | int ovl_cleanup(struct inode *dir, struct dentry *dentry); | 402 | int ovl_cleanup(struct inode *dir, struct dentry *dentry); |
369 | struct dentry *ovl_create_temp(struct dentry *workdir, struct ovl_cattr *attr); | 403 | struct dentry *ovl_create_temp(struct dentry *workdir, struct ovl_cattr *attr); |
370 | 404 | ||
405 | /* file.c */ | ||
406 | extern const struct file_operations ovl_file_operations; | ||
407 | |||
371 | /* copy_up.c */ | 408 | /* copy_up.c */ |
372 | int ovl_copy_up(struct dentry *dentry); | 409 | int ovl_copy_up(struct dentry *dentry); |
410 | int ovl_copy_up_with_data(struct dentry *dentry); | ||
373 | int ovl_copy_up_flags(struct dentry *dentry, int flags); | 411 | int ovl_copy_up_flags(struct dentry *dentry, int flags); |
412 | int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags); | ||
374 | int ovl_copy_xattr(struct dentry *old, struct dentry *new); | 413 | int ovl_copy_xattr(struct dentry *old, struct dentry *new); |
375 | int ovl_set_attr(struct dentry *upper, struct kstat *stat); | 414 | int ovl_set_attr(struct dentry *upper, struct kstat *stat); |
376 | struct ovl_fh *ovl_encode_real_fh(struct dentry *real, bool is_upper); | 415 | struct ovl_fh *ovl_encode_real_fh(struct dentry *real, bool is_upper); |