| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (C) 2011 Novell Inc. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms of the GNU General Public License version 2 as published by |
|---|
| 7 | | - * the Free Software Foundation. |
|---|
| 8 | 5 | */ |
|---|
| 9 | 6 | |
|---|
| 10 | 7 | #include <linux/kernel.h> |
|---|
| 11 | 8 | #include <linux/uuid.h> |
|---|
| 12 | 9 | #include <linux/fs.h> |
|---|
| 13 | 10 | #include "ovl_entry.h" |
|---|
| 11 | + |
|---|
| 12 | +#undef pr_fmt |
|---|
| 13 | +#define pr_fmt(fmt) "overlayfs: " fmt |
|---|
| 14 | 14 | |
|---|
| 15 | 15 | enum ovl_path_type { |
|---|
| 16 | 16 | __OVL_PATH_UPPER = (1 << 0), |
|---|
| .. | .. |
|---|
| 23 | 23 | #define OVL_TYPE_ORIGIN(type) ((type) & __OVL_PATH_ORIGIN) |
|---|
| 24 | 24 | |
|---|
| 25 | 25 | #define OVL_XATTR_PREFIX XATTR_TRUSTED_PREFIX "overlay." |
|---|
| 26 | | -#define OVL_XATTR_OPAQUE OVL_XATTR_PREFIX "opaque" |
|---|
| 27 | | -#define OVL_XATTR_REDIRECT OVL_XATTR_PREFIX "redirect" |
|---|
| 28 | | -#define OVL_XATTR_ORIGIN OVL_XATTR_PREFIX "origin" |
|---|
| 29 | | -#define OVL_XATTR_IMPURE OVL_XATTR_PREFIX "impure" |
|---|
| 30 | | -#define OVL_XATTR_NLINK OVL_XATTR_PREFIX "nlink" |
|---|
| 31 | | -#define OVL_XATTR_UPPER OVL_XATTR_PREFIX "upper" |
|---|
| 32 | | -#define OVL_XATTR_METACOPY OVL_XATTR_PREFIX "metacopy" |
|---|
| 26 | + |
|---|
| 27 | +enum ovl_xattr { |
|---|
| 28 | + OVL_XATTR_OPAQUE, |
|---|
| 29 | + OVL_XATTR_REDIRECT, |
|---|
| 30 | + OVL_XATTR_ORIGIN, |
|---|
| 31 | + OVL_XATTR_IMPURE, |
|---|
| 32 | + OVL_XATTR_NLINK, |
|---|
| 33 | + OVL_XATTR_UPPER, |
|---|
| 34 | + OVL_XATTR_METACOPY, |
|---|
| 35 | +}; |
|---|
| 33 | 36 | |
|---|
| 34 | 37 | enum ovl_inode_flag { |
|---|
| 35 | 38 | /* Pure upper dir that may contain non pure upper entries */ |
|---|
| .. | .. |
|---|
| 46 | 49 | OVL_E_UPPER_ALIAS, |
|---|
| 47 | 50 | OVL_E_OPAQUE, |
|---|
| 48 | 51 | OVL_E_CONNECTED, |
|---|
| 52 | +}; |
|---|
| 53 | + |
|---|
| 54 | +enum { |
|---|
| 55 | + OVL_XINO_OFF, |
|---|
| 56 | + OVL_XINO_AUTO, |
|---|
| 57 | + OVL_XINO_ON, |
|---|
| 49 | 58 | }; |
|---|
| 50 | 59 | |
|---|
| 51 | 60 | /* |
|---|
| .. | .. |
|---|
| 74 | 83 | #error Endianness not defined |
|---|
| 75 | 84 | #endif |
|---|
| 76 | 85 | |
|---|
| 77 | | -/* The type returned by overlay exportfs ops when encoding an ovl_fh handle */ |
|---|
| 78 | | -#define OVL_FILEID 0xfb |
|---|
| 86 | +/* The type used to be returned by overlay exportfs for misaligned fid */ |
|---|
| 87 | +#define OVL_FILEID_V0 0xfb |
|---|
| 88 | +/* The type returned by overlay exportfs for 32bit aligned fid */ |
|---|
| 89 | +#define OVL_FILEID_V1 0xf8 |
|---|
| 79 | 90 | |
|---|
| 80 | | -/* On-disk and in-memeory format for redirect by file handle */ |
|---|
| 81 | | -struct ovl_fh { |
|---|
| 91 | +/* On-disk format for "origin" file handle */ |
|---|
| 92 | +struct ovl_fb { |
|---|
| 82 | 93 | u8 version; /* 0 */ |
|---|
| 83 | 94 | u8 magic; /* 0xfb */ |
|---|
| 84 | 95 | u8 len; /* size of this header + size of fid */ |
|---|
| 85 | 96 | u8 flags; /* OVL_FH_FLAG_* */ |
|---|
| 86 | 97 | u8 type; /* fid_type of fid */ |
|---|
| 87 | 98 | uuid_t uuid; /* uuid of filesystem */ |
|---|
| 88 | | - u8 fid[0]; /* file identifier */ |
|---|
| 99 | + u32 fid[]; /* file identifier should be 32bit aligned in-memory */ |
|---|
| 89 | 100 | } __packed; |
|---|
| 101 | + |
|---|
| 102 | +/* In-memory and on-wire format for overlay file handle */ |
|---|
| 103 | +struct ovl_fh { |
|---|
| 104 | + u8 padding[3]; /* make sure fb.fid is 32bit aligned */ |
|---|
| 105 | + union { |
|---|
| 106 | + struct ovl_fb fb; |
|---|
| 107 | + u8 buf[0]; |
|---|
| 108 | + }; |
|---|
| 109 | +} __packed; |
|---|
| 110 | + |
|---|
| 111 | +#define OVL_FH_WIRE_OFFSET offsetof(struct ovl_fh, fb) |
|---|
| 112 | +#define OVL_FH_LEN(fh) (OVL_FH_WIRE_OFFSET + (fh)->fb.len) |
|---|
| 113 | +#define OVL_FH_FID_OFFSET (OVL_FH_WIRE_OFFSET + \ |
|---|
| 114 | + offsetof(struct ovl_fb, fid)) |
|---|
| 115 | + |
|---|
| 116 | +extern const char *ovl_xattr_table[]; |
|---|
| 117 | +static inline const char *ovl_xattr(struct ovl_fs *ofs, enum ovl_xattr ox) |
|---|
| 118 | +{ |
|---|
| 119 | + return ovl_xattr_table[ox]; |
|---|
| 120 | +} |
|---|
| 90 | 121 | |
|---|
| 91 | 122 | static inline int ovl_do_rmdir(struct inode *dir, struct dentry *dentry) |
|---|
| 92 | 123 | { |
|---|
| .. | .. |
|---|
| 148 | 179 | return err; |
|---|
| 149 | 180 | } |
|---|
| 150 | 181 | |
|---|
| 151 | | -static inline int ovl_do_setxattr(struct dentry *dentry, const char *name, |
|---|
| 152 | | - const void *value, size_t size, int flags) |
|---|
| 182 | +static inline ssize_t ovl_do_getxattr(struct ovl_fs *ofs, struct dentry *dentry, |
|---|
| 183 | + enum ovl_xattr ox, void *value, |
|---|
| 184 | + size_t size) |
|---|
| 153 | 185 | { |
|---|
| 154 | | - int err = vfs_setxattr(dentry, name, value, size, flags); |
|---|
| 155 | | - pr_debug("setxattr(%pd2, \"%s\", \"%*pE\", %zu, 0x%x) = %i\n", |
|---|
| 156 | | - dentry, name, min((int)size, 48), value, size, flags, err); |
|---|
| 186 | + const char *name = ovl_xattr(ofs, ox); |
|---|
| 187 | + struct inode *ip = d_inode(dentry); |
|---|
| 188 | + |
|---|
| 189 | + return __vfs_getxattr(dentry, ip, name, value, size, XATTR_NOSECURITY); |
|---|
| 190 | +} |
|---|
| 191 | + |
|---|
| 192 | +static inline int ovl_do_setxattr(struct ovl_fs *ofs, struct dentry *dentry, |
|---|
| 193 | + enum ovl_xattr ox, const void *value, |
|---|
| 194 | + size_t size) |
|---|
| 195 | +{ |
|---|
| 196 | + const char *name = ovl_xattr(ofs, ox); |
|---|
| 197 | + int err = vfs_setxattr(dentry, name, value, size, 0); |
|---|
| 198 | + pr_debug("setxattr(%pd2, \"%s\", \"%*pE\", %zu, 0) = %i\n", |
|---|
| 199 | + dentry, name, min((int)size, 48), value, size, err); |
|---|
| 157 | 200 | return err; |
|---|
| 158 | 201 | } |
|---|
| 159 | 202 | |
|---|
| 160 | | -static inline int ovl_do_removexattr(struct dentry *dentry, const char *name) |
|---|
| 203 | +static inline int ovl_do_removexattr(struct ovl_fs *ofs, struct dentry *dentry, |
|---|
| 204 | + enum ovl_xattr ox) |
|---|
| 161 | 205 | { |
|---|
| 206 | + const char *name = ovl_xattr(ofs, ox); |
|---|
| 162 | 207 | int err = vfs_removexattr(dentry, name); |
|---|
| 163 | 208 | pr_debug("removexattr(%pd2, \"%s\") = %i\n", dentry, name, err); |
|---|
| 164 | 209 | return err; |
|---|
| .. | .. |
|---|
| 208 | 253 | void ovl_drop_write(struct dentry *dentry); |
|---|
| 209 | 254 | struct dentry *ovl_workdir(struct dentry *dentry); |
|---|
| 210 | 255 | const struct cred *ovl_override_creds(struct super_block *sb); |
|---|
| 211 | | -void ovl_revert_creds(const struct cred *oldcred); |
|---|
| 212 | | -ssize_t ovl_vfs_getxattr(struct dentry *dentry, const char *name, void *buf, |
|---|
| 213 | | - size_t size); |
|---|
| 214 | | -struct super_block *ovl_same_sb(struct super_block *sb); |
|---|
| 256 | +void ovl_revert_creds(struct super_block *sb, const struct cred *oldcred); |
|---|
| 215 | 257 | int ovl_can_decode_fh(struct super_block *sb); |
|---|
| 216 | 258 | struct dentry *ovl_indexdir(struct super_block *sb); |
|---|
| 217 | 259 | bool ovl_index_all(struct super_block *sb); |
|---|
| 218 | 260 | bool ovl_verify_lower(struct super_block *sb); |
|---|
| 219 | 261 | struct ovl_entry *ovl_alloc_entry(unsigned int numlower); |
|---|
| 220 | 262 | bool ovl_dentry_remote(struct dentry *dentry); |
|---|
| 263 | +void ovl_dentry_update_reval(struct dentry *dentry, struct dentry *realdentry); |
|---|
| 264 | +void ovl_dentry_init_reval(struct dentry *dentry, struct dentry *upperdentry); |
|---|
| 265 | +void ovl_dentry_init_flags(struct dentry *dentry, struct dentry *upperdentry, |
|---|
| 266 | + unsigned int mask); |
|---|
| 221 | 267 | bool ovl_dentry_weird(struct dentry *dentry); |
|---|
| 222 | 268 | enum ovl_path_type ovl_path_type(struct dentry *dentry); |
|---|
| 223 | 269 | void ovl_path_upper(struct dentry *dentry, struct path *path); |
|---|
| .. | .. |
|---|
| 227 | 273 | struct dentry *ovl_dentry_upper(struct dentry *dentry); |
|---|
| 228 | 274 | struct dentry *ovl_dentry_lower(struct dentry *dentry); |
|---|
| 229 | 275 | struct dentry *ovl_dentry_lowerdata(struct dentry *dentry); |
|---|
| 230 | | -struct ovl_layer *ovl_layer_lower(struct dentry *dentry); |
|---|
| 276 | +const struct ovl_layer *ovl_layer_lower(struct dentry *dentry); |
|---|
| 231 | 277 | struct dentry *ovl_dentry_real(struct dentry *dentry); |
|---|
| 232 | 278 | struct dentry *ovl_i_dentry_upper(struct inode *inode); |
|---|
| 233 | 279 | struct inode *ovl_inode_upper(struct inode *inode); |
|---|
| .. | .. |
|---|
| 252 | 298 | bool ovl_redirect_dir(struct super_block *sb); |
|---|
| 253 | 299 | const char *ovl_dentry_get_redirect(struct dentry *dentry); |
|---|
| 254 | 300 | void ovl_dentry_set_redirect(struct dentry *dentry, const char *redirect); |
|---|
| 255 | | -void ovl_inode_init(struct inode *inode, struct dentry *upperdentry, |
|---|
| 256 | | - struct dentry *lowerdentry, struct dentry *lowerdata); |
|---|
| 257 | 301 | void ovl_inode_update(struct inode *inode, struct dentry *upperdentry); |
|---|
| 258 | 302 | void ovl_dir_modified(struct dentry *dentry, bool impurity); |
|---|
| 259 | 303 | u64 ovl_dentry_version_get(struct dentry *dentry); |
|---|
| .. | .. |
|---|
| 262 | 306 | int ovl_copy_up_start(struct dentry *dentry, int flags); |
|---|
| 263 | 307 | void ovl_copy_up_end(struct dentry *dentry); |
|---|
| 264 | 308 | bool ovl_already_copied_up(struct dentry *dentry, int flags); |
|---|
| 265 | | -bool ovl_check_origin_xattr(struct dentry *dentry); |
|---|
| 266 | | -bool ovl_check_dir_xattr(struct dentry *dentry, const char *name); |
|---|
| 309 | +bool ovl_check_origin_xattr(struct ovl_fs *ofs, struct dentry *dentry); |
|---|
| 310 | +bool ovl_check_dir_xattr(struct super_block *sb, struct dentry *dentry, |
|---|
| 311 | + enum ovl_xattr ox); |
|---|
| 267 | 312 | int ovl_check_setxattr(struct dentry *dentry, struct dentry *upperdentry, |
|---|
| 268 | | - const char *name, const void *value, size_t size, |
|---|
| 313 | + enum ovl_xattr ox, const void *value, size_t size, |
|---|
| 269 | 314 | int xerr); |
|---|
| 270 | 315 | int ovl_set_impure(struct dentry *dentry, struct dentry *upperdentry); |
|---|
| 271 | | -void ovl_set_flag(unsigned long flag, struct inode *inode); |
|---|
| 272 | | -void ovl_clear_flag(unsigned long flag, struct inode *inode); |
|---|
| 273 | | -bool ovl_test_flag(unsigned long flag, struct inode *inode); |
|---|
| 274 | 316 | bool ovl_inuse_trylock(struct dentry *dentry); |
|---|
| 275 | 317 | void ovl_inuse_unlock(struct dentry *dentry); |
|---|
| 276 | 318 | bool ovl_is_inuse(struct dentry *dentry); |
|---|
| 277 | 319 | bool ovl_need_index(struct dentry *dentry); |
|---|
| 278 | | -int ovl_nlink_start(struct dentry *dentry, bool *locked); |
|---|
| 279 | | -void ovl_nlink_end(struct dentry *dentry, bool locked); |
|---|
| 320 | +int ovl_nlink_start(struct dentry *dentry); |
|---|
| 321 | +void ovl_nlink_end(struct dentry *dentry); |
|---|
| 280 | 322 | int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir); |
|---|
| 281 | | -int ovl_check_metacopy_xattr(struct dentry *dentry); |
|---|
| 323 | +int ovl_check_metacopy_xattr(struct ovl_fs *ofs, struct dentry *dentry); |
|---|
| 282 | 324 | bool ovl_is_metacopy_dentry(struct dentry *dentry); |
|---|
| 283 | | -char *ovl_get_redirect_xattr(struct dentry *dentry, int padding); |
|---|
| 284 | | -ssize_t ovl_getxattr(struct dentry *dentry, char *name, char **value, |
|---|
| 285 | | - size_t padding); |
|---|
| 325 | +char *ovl_get_redirect_xattr(struct ovl_fs *ofs, struct dentry *dentry, |
|---|
| 326 | + int padding); |
|---|
| 327 | +int ovl_sync_status(struct ovl_fs *ofs); |
|---|
| 286 | 328 | |
|---|
| 287 | | -static inline bool ovl_is_impuredir(struct dentry *dentry) |
|---|
| 329 | +static inline void ovl_set_flag(unsigned long flag, struct inode *inode) |
|---|
| 288 | 330 | { |
|---|
| 289 | | - return ovl_check_dir_xattr(dentry, OVL_XATTR_IMPURE); |
|---|
| 331 | + set_bit(flag, &OVL_I(inode)->flags); |
|---|
| 332 | +} |
|---|
| 333 | + |
|---|
| 334 | +static inline void ovl_clear_flag(unsigned long flag, struct inode *inode) |
|---|
| 335 | +{ |
|---|
| 336 | + clear_bit(flag, &OVL_I(inode)->flags); |
|---|
| 337 | +} |
|---|
| 338 | + |
|---|
| 339 | +static inline bool ovl_test_flag(unsigned long flag, struct inode *inode) |
|---|
| 340 | +{ |
|---|
| 341 | + return test_bit(flag, &OVL_I(inode)->flags); |
|---|
| 342 | +} |
|---|
| 343 | + |
|---|
| 344 | +static inline bool ovl_is_impuredir(struct super_block *sb, |
|---|
| 345 | + struct dentry *dentry) |
|---|
| 346 | +{ |
|---|
| 347 | + return ovl_check_dir_xattr(sb, dentry, OVL_XATTR_IMPURE); |
|---|
| 348 | +} |
|---|
| 349 | + |
|---|
| 350 | +/* |
|---|
| 351 | + * With xino=auto, we do best effort to keep all inodes on same st_dev and |
|---|
| 352 | + * d_ino consistent with st_ino. |
|---|
| 353 | + * With xino=on, we do the same effort but we warn if we failed. |
|---|
| 354 | + */ |
|---|
| 355 | +static inline bool ovl_xino_warn(struct super_block *sb) |
|---|
| 356 | +{ |
|---|
| 357 | + return OVL_FS(sb)->config.xino == OVL_XINO_ON; |
|---|
| 358 | +} |
|---|
| 359 | + |
|---|
| 360 | +/* All layers on same fs? */ |
|---|
| 361 | +static inline bool ovl_same_fs(struct super_block *sb) |
|---|
| 362 | +{ |
|---|
| 363 | + return OVL_FS(sb)->xino_mode == 0; |
|---|
| 364 | +} |
|---|
| 365 | + |
|---|
| 366 | +/* All overlay inodes have same st_dev? */ |
|---|
| 367 | +static inline bool ovl_same_dev(struct super_block *sb) |
|---|
| 368 | +{ |
|---|
| 369 | + return OVL_FS(sb)->xino_mode >= 0; |
|---|
| 290 | 370 | } |
|---|
| 291 | 371 | |
|---|
| 292 | 372 | static inline unsigned int ovl_xino_bits(struct super_block *sb) |
|---|
| 293 | 373 | { |
|---|
| 294 | | - struct ovl_fs *ofs = sb->s_fs_info; |
|---|
| 374 | + return ovl_same_dev(sb) ? OVL_FS(sb)->xino_mode : 0; |
|---|
| 375 | +} |
|---|
| 295 | 376 | |
|---|
| 296 | | - return ofs->xino_bits; |
|---|
| 377 | +static inline void ovl_inode_lock(struct inode *inode) |
|---|
| 378 | +{ |
|---|
| 379 | + mutex_lock(&OVL_I(inode)->lock); |
|---|
| 380 | +} |
|---|
| 381 | + |
|---|
| 382 | +static inline int ovl_inode_lock_interruptible(struct inode *inode) |
|---|
| 383 | +{ |
|---|
| 384 | + return mutex_lock_interruptible(&OVL_I(inode)->lock); |
|---|
| 385 | +} |
|---|
| 386 | + |
|---|
| 387 | +static inline void ovl_inode_unlock(struct inode *inode) |
|---|
| 388 | +{ |
|---|
| 389 | + mutex_unlock(&OVL_I(inode)->lock); |
|---|
| 297 | 390 | } |
|---|
| 298 | 391 | |
|---|
| 299 | 392 | |
|---|
| 300 | 393 | /* namei.c */ |
|---|
| 301 | | -int ovl_check_fh_len(struct ovl_fh *fh, int fh_len); |
|---|
| 394 | +int ovl_check_fb_len(struct ovl_fb *fb, int fb_len); |
|---|
| 395 | + |
|---|
| 396 | +static inline int ovl_check_fh_len(struct ovl_fh *fh, int fh_len) |
|---|
| 397 | +{ |
|---|
| 398 | + if (fh_len < sizeof(struct ovl_fh)) |
|---|
| 399 | + return -EINVAL; |
|---|
| 400 | + |
|---|
| 401 | + return ovl_check_fb_len(&fh->fb, fh_len - OVL_FH_WIRE_OFFSET); |
|---|
| 402 | +} |
|---|
| 403 | + |
|---|
| 302 | 404 | struct dentry *ovl_decode_real_fh(struct ovl_fh *fh, struct vfsmount *mnt, |
|---|
| 303 | 405 | bool connected); |
|---|
| 304 | 406 | int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected, |
|---|
| 305 | 407 | struct dentry *upperdentry, struct ovl_path **stackp); |
|---|
| 306 | | -int ovl_verify_set_fh(struct dentry *dentry, const char *name, |
|---|
| 307 | | - struct dentry *real, bool is_upper, bool set); |
|---|
| 408 | +int ovl_verify_set_fh(struct ovl_fs *ofs, struct dentry *dentry, |
|---|
| 409 | + enum ovl_xattr ox, struct dentry *real, bool is_upper, |
|---|
| 410 | + bool set); |
|---|
| 308 | 411 | struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index); |
|---|
| 309 | 412 | int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index); |
|---|
| 310 | 413 | int ovl_get_index_name(struct dentry *origin, struct qstr *name); |
|---|
| .. | .. |
|---|
| 316 | 419 | unsigned int flags); |
|---|
| 317 | 420 | bool ovl_lower_positive(struct dentry *dentry); |
|---|
| 318 | 421 | |
|---|
| 319 | | -static inline int ovl_verify_origin(struct dentry *upper, |
|---|
| 422 | +static inline int ovl_verify_origin(struct ovl_fs *ofs, struct dentry *upper, |
|---|
| 320 | 423 | struct dentry *origin, bool set) |
|---|
| 321 | 424 | { |
|---|
| 322 | | - return ovl_verify_set_fh(upper, OVL_XATTR_ORIGIN, origin, false, set); |
|---|
| 425 | + return ovl_verify_set_fh(ofs, upper, OVL_XATTR_ORIGIN, origin, |
|---|
| 426 | + false, set); |
|---|
| 323 | 427 | } |
|---|
| 324 | 428 | |
|---|
| 325 | | -static inline int ovl_verify_upper(struct dentry *index, |
|---|
| 326 | | - struct dentry *upper, bool set) |
|---|
| 429 | +static inline int ovl_verify_upper(struct ovl_fs *ofs, struct dentry *index, |
|---|
| 430 | + struct dentry *upper, bool set) |
|---|
| 327 | 431 | { |
|---|
| 328 | | - return ovl_verify_set_fh(index, OVL_XATTR_UPPER, upper, true, set); |
|---|
| 432 | + return ovl_verify_set_fh(ofs, index, OVL_XATTR_UPPER, upper, true, set); |
|---|
| 329 | 433 | } |
|---|
| 330 | 434 | |
|---|
| 331 | 435 | /* readdir.c */ |
|---|
| 332 | 436 | extern const struct file_operations ovl_dir_operations; |
|---|
| 437 | +struct file *ovl_dir_real_file(const struct file *file, bool want_upper); |
|---|
| 333 | 438 | int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list); |
|---|
| 334 | 439 | void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list); |
|---|
| 335 | 440 | void ovl_cache_free(struct list_head *list); |
|---|
| 336 | 441 | void ovl_dir_cache_free(struct inode *inode); |
|---|
| 337 | 442 | int ovl_check_d_type_supported(struct path *realpath); |
|---|
| 338 | | -void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt, |
|---|
| 339 | | - struct dentry *dentry, int level); |
|---|
| 443 | +int ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt, |
|---|
| 444 | + struct dentry *dentry, int level); |
|---|
| 340 | 445 | int ovl_indexdir_cleanup(struct ovl_fs *ofs); |
|---|
| 446 | + |
|---|
| 447 | +/* |
|---|
| 448 | + * Can we iterate real dir directly? |
|---|
| 449 | + * |
|---|
| 450 | + * Non-merge dir may contain whiteouts from a time it was a merge upper, before |
|---|
| 451 | + * lower dir was removed under it and possibly before it was rotated from upper |
|---|
| 452 | + * to lower layer. |
|---|
| 453 | + */ |
|---|
| 454 | +static inline bool ovl_dir_is_real(struct dentry *dir) |
|---|
| 455 | +{ |
|---|
| 456 | + return !ovl_test_flag(OVL_WHITEOUTS, d_inode(dir)); |
|---|
| 457 | +} |
|---|
| 341 | 458 | |
|---|
| 342 | 459 | /* inode.c */ |
|---|
| 343 | 460 | int ovl_set_nlink_upper(struct dentry *dentry); |
|---|
| 344 | 461 | int ovl_set_nlink_lower(struct dentry *dentry); |
|---|
| 345 | | -unsigned int ovl_get_nlink(struct dentry *lowerdentry, |
|---|
| 462 | +unsigned int ovl_get_nlink(struct ovl_fs *ofs, struct dentry *lowerdentry, |
|---|
| 346 | 463 | struct dentry *upperdentry, |
|---|
| 347 | 464 | unsigned int fallback); |
|---|
| 348 | 465 | int ovl_setattr(struct dentry *dentry, struct iattr *attr); |
|---|
| .. | .. |
|---|
| 352 | 469 | int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char *name, |
|---|
| 353 | 470 | const void *value, size_t size, int flags); |
|---|
| 354 | 471 | int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name, |
|---|
| 355 | | - void *value, size_t size); |
|---|
| 356 | | -int __ovl_xattr_get(struct dentry *dentry, struct inode *inode, |
|---|
| 357 | | - const char *name, void *value, size_t size); |
|---|
| 472 | + void *value, size_t size, int flags); |
|---|
| 358 | 473 | ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); |
|---|
| 359 | 474 | struct posix_acl *ovl_get_acl(struct inode *inode, int type); |
|---|
| 360 | 475 | int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags); |
|---|
| 361 | | -bool ovl_is_private_xattr(const char *name); |
|---|
| 476 | +bool ovl_is_private_xattr(struct super_block *sb, const char *name); |
|---|
| 362 | 477 | |
|---|
| 363 | 478 | struct ovl_inode_params { |
|---|
| 364 | 479 | struct inode *newinode; |
|---|
| 365 | 480 | struct dentry *upperdentry; |
|---|
| 366 | 481 | struct ovl_path *lowerpath; |
|---|
| 367 | | - struct dentry *index; |
|---|
| 482 | + bool index; |
|---|
| 368 | 483 | unsigned int numlower; |
|---|
| 369 | 484 | char *redirect; |
|---|
| 370 | 485 | struct dentry *lowerdata; |
|---|
| 371 | 486 | }; |
|---|
| 487 | +void ovl_inode_init(struct inode *inode, struct ovl_inode_params *oip, |
|---|
| 488 | + unsigned long ino, int fsid); |
|---|
| 372 | 489 | struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, dev_t rdev); |
|---|
| 373 | 490 | struct inode *ovl_lookup_inode(struct super_block *sb, struct dentry *real, |
|---|
| 374 | 491 | bool is_upper); |
|---|
| .. | .. |
|---|
| 396 | 513 | |
|---|
| 397 | 514 | /* dir.c */ |
|---|
| 398 | 515 | extern const struct inode_operations ovl_dir_inode_operations; |
|---|
| 399 | | -int ovl_cleanup_and_whiteout(struct dentry *workdir, struct inode *dir, |
|---|
| 516 | +int ovl_cleanup_and_whiteout(struct ovl_fs *ofs, struct inode *dir, |
|---|
| 400 | 517 | struct dentry *dentry); |
|---|
| 401 | 518 | struct ovl_cattr { |
|---|
| 402 | 519 | dev_t rdev; |
|---|
| .. | .. |
|---|
| 411 | 528 | struct dentry *ovl_create_real(struct inode *dir, struct dentry *newdentry, |
|---|
| 412 | 529 | struct ovl_cattr *attr); |
|---|
| 413 | 530 | int ovl_cleanup(struct inode *dir, struct dentry *dentry); |
|---|
| 531 | +struct dentry *ovl_lookup_temp(struct dentry *workdir); |
|---|
| 414 | 532 | struct dentry *ovl_create_temp(struct dentry *workdir, struct ovl_cattr *attr); |
|---|
| 415 | 533 | |
|---|
| 416 | 534 | /* file.c */ |
|---|
| 417 | 535 | extern const struct file_operations ovl_file_operations; |
|---|
| 536 | +int __init ovl_aio_request_cache_init(void); |
|---|
| 537 | +void ovl_aio_request_cache_destroy(void); |
|---|
| 538 | +long ovl_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
|---|
| 539 | +long ovl_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
|---|
| 418 | 540 | |
|---|
| 419 | 541 | /* copy_up.c */ |
|---|
| 420 | 542 | int ovl_copy_up(struct dentry *dentry); |
|---|
| 421 | 543 | int ovl_copy_up_with_data(struct dentry *dentry); |
|---|
| 422 | | -int ovl_copy_up_flags(struct dentry *dentry, int flags); |
|---|
| 423 | 544 | int ovl_maybe_copy_up(struct dentry *dentry, int flags); |
|---|
| 424 | | -int ovl_copy_xattr(struct dentry *old, struct dentry *new); |
|---|
| 545 | +int ovl_copy_xattr(struct super_block *sb, struct dentry *old, |
|---|
| 546 | + struct dentry *new); |
|---|
| 425 | 547 | int ovl_set_attr(struct dentry *upper, struct kstat *stat); |
|---|
| 426 | 548 | struct ovl_fh *ovl_encode_real_fh(struct dentry *real, bool is_upper); |
|---|
| 427 | 549 | int ovl_set_origin(struct dentry *dentry, struct dentry *lower, |
|---|