1e9be9d5eSMiklos Szeredi /* 2e9be9d5eSMiklos Szeredi * 3e9be9d5eSMiklos Szeredi * Copyright (C) 2011 Novell Inc. 4e9be9d5eSMiklos Szeredi * 5e9be9d5eSMiklos Szeredi * This program is free software; you can redistribute it and/or modify it 6e9be9d5eSMiklos Szeredi * under the terms of the GNU General Public License version 2 as published by 7e9be9d5eSMiklos Szeredi * the Free Software Foundation. 8e9be9d5eSMiklos Szeredi */ 9e9be9d5eSMiklos Szeredi 10e9be9d5eSMiklos Szeredi #include <linux/kernel.h> 113a1e819bSAmir Goldstein #include <linux/uuid.h> 12ee023c30SAmir Goldstein #include "ovl_entry.h" 13e9be9d5eSMiklos Szeredi 14e9be9d5eSMiklos Szeredi enum ovl_path_type { 1538e813dbSMiklos Szeredi __OVL_PATH_UPPER = (1 << 0), 1638e813dbSMiklos Szeredi __OVL_PATH_MERGE = (1 << 1), 1759548503SAmir Goldstein __OVL_PATH_ORIGIN = (1 << 2), 18e9be9d5eSMiklos Szeredi }; 19e9be9d5eSMiklos Szeredi 201afaba1eSMiklos Szeredi #define OVL_TYPE_UPPER(type) ((type) & __OVL_PATH_UPPER) 211afaba1eSMiklos Szeredi #define OVL_TYPE_MERGE(type) ((type) & __OVL_PATH_MERGE) 2259548503SAmir Goldstein #define OVL_TYPE_ORIGIN(type) ((type) & __OVL_PATH_ORIGIN) 23d837a49bSMiklos Szeredi 24fe2b7595SAndreas Gruenbacher #define OVL_XATTR_PREFIX XATTR_TRUSTED_PREFIX "overlay." 25fe2b7595SAndreas Gruenbacher #define OVL_XATTR_OPAQUE OVL_XATTR_PREFIX "opaque" 2602b69b28SMiklos Szeredi #define OVL_XATTR_REDIRECT OVL_XATTR_PREFIX "redirect" 273a1e819bSAmir Goldstein #define OVL_XATTR_ORIGIN OVL_XATTR_PREFIX "origin" 28ee1d6d37SAmir Goldstein #define OVL_XATTR_IMPURE OVL_XATTR_PREFIX "impure" 295f8415d6SAmir Goldstein #define OVL_XATTR_NLINK OVL_XATTR_PREFIX "nlink" 30ad1d615cSAmir Goldstein #define OVL_XATTR_UPPER OVL_XATTR_PREFIX "upper" 313a1e819bSAmir Goldstein 32c62520a8SAmir Goldstein enum ovl_inode_flag { 33b79e05aaSAmir Goldstein /* Pure upper dir that may contain non pure upper entries */ 3413c72075SMiklos Szeredi OVL_IMPURE, 35b79e05aaSAmir Goldstein /* Non-merge dir that may contain whiteout entries */ 36b79e05aaSAmir Goldstein OVL_WHITEOUTS, 37359f392cSAmir Goldstein OVL_INDEX, 3813c72075SMiklos Szeredi }; 3913c72075SMiklos Szeredi 40c62520a8SAmir Goldstein enum ovl_entry_flag { 41c62520a8SAmir Goldstein OVL_E_UPPER_ALIAS, 42c62520a8SAmir Goldstein OVL_E_OPAQUE, 432ca3c148SAmir Goldstein OVL_E_CONNECTED, 44c62520a8SAmir Goldstein }; 45c62520a8SAmir Goldstein 463a1e819bSAmir Goldstein /* 473a1e819bSAmir Goldstein * The tuple (fh,uuid) is a universal unique identifier for a copy up origin, 483a1e819bSAmir Goldstein * where: 493a1e819bSAmir Goldstein * origin.fh - exported file handle of the lower file 503a1e819bSAmir Goldstein * origin.uuid - uuid of the lower filesystem 513a1e819bSAmir Goldstein */ 523a1e819bSAmir Goldstein #define OVL_FH_VERSION 0 533a1e819bSAmir Goldstein #define OVL_FH_MAGIC 0xfb 543a1e819bSAmir Goldstein 553a1e819bSAmir Goldstein /* CPU byte order required for fid decoding: */ 563a1e819bSAmir Goldstein #define OVL_FH_FLAG_BIG_ENDIAN (1 << 0) 573a1e819bSAmir Goldstein #define OVL_FH_FLAG_ANY_ENDIAN (1 << 1) 5854fb347eSAmir Goldstein /* Is the real inode encoded in fid an upper inode? */ 5954fb347eSAmir Goldstein #define OVL_FH_FLAG_PATH_UPPER (1 << 2) 603a1e819bSAmir Goldstein 61961af647SAmir Goldstein #define OVL_FH_FLAG_ALL (OVL_FH_FLAG_BIG_ENDIAN | OVL_FH_FLAG_ANY_ENDIAN | \ 62961af647SAmir Goldstein OVL_FH_FLAG_PATH_UPPER) 633a1e819bSAmir Goldstein 643a1e819bSAmir Goldstein #if defined(__LITTLE_ENDIAN) 653a1e819bSAmir Goldstein #define OVL_FH_FLAG_CPU_ENDIAN 0 663a1e819bSAmir Goldstein #elif defined(__BIG_ENDIAN) 673a1e819bSAmir Goldstein #define OVL_FH_FLAG_CPU_ENDIAN OVL_FH_FLAG_BIG_ENDIAN 683a1e819bSAmir Goldstein #else 693a1e819bSAmir Goldstein #error Endianness not defined 703a1e819bSAmir Goldstein #endif 713a1e819bSAmir Goldstein 728ed5eec9SAmir Goldstein /* The type returned by overlay exportfs ops when encoding an ovl_fh handle */ 738ed5eec9SAmir Goldstein #define OVL_FILEID 0xfb 748ed5eec9SAmir Goldstein 753a1e819bSAmir Goldstein /* On-disk and in-memeory format for redirect by file handle */ 763a1e819bSAmir Goldstein struct ovl_fh { 773a1e819bSAmir Goldstein u8 version; /* 0 */ 783a1e819bSAmir Goldstein u8 magic; /* 0xfb */ 793a1e819bSAmir Goldstein u8 len; /* size of this header + size of fid */ 803a1e819bSAmir Goldstein u8 flags; /* OVL_FH_FLAG_* */ 813a1e819bSAmir Goldstein u8 type; /* fid_type of fid */ 8201633fd2SChristoph Hellwig uuid_t uuid; /* uuid of filesystem */ 833a1e819bSAmir Goldstein u8 fid[0]; /* file identifier */ 843a1e819bSAmir Goldstein } __packed; 85e9be9d5eSMiklos Szeredi 86e9be9d5eSMiklos Szeredi static inline int ovl_do_rmdir(struct inode *dir, struct dentry *dentry) 87e9be9d5eSMiklos Szeredi { 88e9be9d5eSMiklos Szeredi int err = vfs_rmdir(dir, dentry); 896cf00764SAmir Goldstein 90e9be9d5eSMiklos Szeredi pr_debug("rmdir(%pd2) = %i\n", dentry, err); 91e9be9d5eSMiklos Szeredi return err; 92e9be9d5eSMiklos Szeredi } 93e9be9d5eSMiklos Szeredi 94e9be9d5eSMiklos Szeredi static inline int ovl_do_unlink(struct inode *dir, struct dentry *dentry) 95e9be9d5eSMiklos Szeredi { 96e9be9d5eSMiklos Szeredi int err = vfs_unlink(dir, dentry, NULL); 976cf00764SAmir Goldstein 98e9be9d5eSMiklos Szeredi pr_debug("unlink(%pd2) = %i\n", dentry, err); 99e9be9d5eSMiklos Szeredi return err; 100e9be9d5eSMiklos Szeredi } 101e9be9d5eSMiklos Szeredi 102e9be9d5eSMiklos Szeredi static inline int ovl_do_link(struct dentry *old_dentry, struct inode *dir, 1036cf00764SAmir Goldstein struct dentry *new_dentry) 104e9be9d5eSMiklos Szeredi { 105e9be9d5eSMiklos Szeredi int err = vfs_link(old_dentry, dir, new_dentry, NULL); 1066cf00764SAmir Goldstein 1076cf00764SAmir Goldstein pr_debug("link(%pd2, %pd2) = %i\n", old_dentry, new_dentry, err); 108e9be9d5eSMiklos Szeredi return err; 109e9be9d5eSMiklos Szeredi } 110e9be9d5eSMiklos Szeredi 111e9be9d5eSMiklos Szeredi static inline int ovl_do_create(struct inode *dir, struct dentry *dentry, 1126cf00764SAmir Goldstein umode_t mode) 113e9be9d5eSMiklos Szeredi { 114e9be9d5eSMiklos Szeredi int err = vfs_create(dir, dentry, mode, true); 1156cf00764SAmir Goldstein 116e9be9d5eSMiklos Szeredi pr_debug("create(%pd2, 0%o) = %i\n", dentry, mode, err); 117e9be9d5eSMiklos Szeredi return err; 118e9be9d5eSMiklos Szeredi } 119e9be9d5eSMiklos Szeredi 120e9be9d5eSMiklos Szeredi static inline int ovl_do_mkdir(struct inode *dir, struct dentry *dentry, 1216cf00764SAmir Goldstein umode_t mode) 122e9be9d5eSMiklos Szeredi { 123e9be9d5eSMiklos Szeredi int err = vfs_mkdir(dir, dentry, mode); 124e9be9d5eSMiklos Szeredi pr_debug("mkdir(%pd2, 0%o) = %i\n", dentry, mode, err); 125e9be9d5eSMiklos Szeredi return err; 126e9be9d5eSMiklos Szeredi } 127e9be9d5eSMiklos Szeredi 128e9be9d5eSMiklos Szeredi static inline int ovl_do_mknod(struct inode *dir, struct dentry *dentry, 1296cf00764SAmir Goldstein umode_t mode, dev_t dev) 130e9be9d5eSMiklos Szeredi { 131e9be9d5eSMiklos Szeredi int err = vfs_mknod(dir, dentry, mode, dev); 1326cf00764SAmir Goldstein 1336cf00764SAmir Goldstein pr_debug("mknod(%pd2, 0%o, 0%o) = %i\n", dentry, mode, dev, err); 134e9be9d5eSMiklos Szeredi return err; 135e9be9d5eSMiklos Szeredi } 136e9be9d5eSMiklos Szeredi 137e9be9d5eSMiklos Szeredi static inline int ovl_do_symlink(struct inode *dir, struct dentry *dentry, 1386cf00764SAmir Goldstein const char *oldname) 139e9be9d5eSMiklos Szeredi { 140e9be9d5eSMiklos Szeredi int err = vfs_symlink(dir, dentry, oldname); 1416cf00764SAmir Goldstein 142e9be9d5eSMiklos Szeredi pr_debug("symlink(\"%s\", %pd2) = %i\n", oldname, dentry, err); 143e9be9d5eSMiklos Szeredi return err; 144e9be9d5eSMiklos Szeredi } 145e9be9d5eSMiklos Szeredi 146e9be9d5eSMiklos Szeredi static inline int ovl_do_setxattr(struct dentry *dentry, const char *name, 147e9be9d5eSMiklos Szeredi const void *value, size_t size, int flags) 148e9be9d5eSMiklos Szeredi { 149e9be9d5eSMiklos Szeredi int err = vfs_setxattr(dentry, name, value, size, flags); 150e9be9d5eSMiklos Szeredi pr_debug("setxattr(%pd2, \"%s\", \"%*s\", 0x%x) = %i\n", 151e9be9d5eSMiklos Szeredi dentry, name, (int) size, (char *) value, flags, err); 152e9be9d5eSMiklos Szeredi return err; 153e9be9d5eSMiklos Szeredi } 154e9be9d5eSMiklos Szeredi 155e9be9d5eSMiklos Szeredi static inline int ovl_do_removexattr(struct dentry *dentry, const char *name) 156e9be9d5eSMiklos Szeredi { 157e9be9d5eSMiklos Szeredi int err = vfs_removexattr(dentry, name); 158e9be9d5eSMiklos Szeredi pr_debug("removexattr(%pd2, \"%s\") = %i\n", dentry, name, err); 159e9be9d5eSMiklos Szeredi return err; 160e9be9d5eSMiklos Szeredi } 161e9be9d5eSMiklos Szeredi 162e9be9d5eSMiklos Szeredi static inline int ovl_do_rename(struct inode *olddir, struct dentry *olddentry, 163e9be9d5eSMiklos Szeredi struct inode *newdir, struct dentry *newdentry, 164e9be9d5eSMiklos Szeredi unsigned int flags) 165e9be9d5eSMiklos Szeredi { 166e9be9d5eSMiklos Szeredi int err; 167e9be9d5eSMiklos Szeredi 1686cf00764SAmir Goldstein pr_debug("rename(%pd2, %pd2, 0x%x)\n", olddentry, newdentry, flags); 169e9be9d5eSMiklos Szeredi err = vfs_rename(olddir, olddentry, newdir, newdentry, NULL, flags); 170e9be9d5eSMiklos Szeredi if (err) { 1712773bf00SMiklos Szeredi pr_debug("...rename(%pd2, %pd2, ...) = %i\n", 172e9be9d5eSMiklos Szeredi olddentry, newdentry, err); 173e9be9d5eSMiklos Szeredi } 174e9be9d5eSMiklos Szeredi return err; 175e9be9d5eSMiklos Szeredi } 176e9be9d5eSMiklos Szeredi 177e9be9d5eSMiklos Szeredi static inline int ovl_do_whiteout(struct inode *dir, struct dentry *dentry) 178e9be9d5eSMiklos Szeredi { 179e9be9d5eSMiklos Szeredi int err = vfs_whiteout(dir, dentry); 180e9be9d5eSMiklos Szeredi pr_debug("whiteout(%pd2) = %i\n", dentry, err); 181e9be9d5eSMiklos Szeredi return err; 182e9be9d5eSMiklos Szeredi } 183e9be9d5eSMiklos Szeredi 184e7f52429SAmir Goldstein static inline struct dentry *ovl_do_tmpfile(struct dentry *dentry, umode_t mode) 185e7f52429SAmir Goldstein { 186e7f52429SAmir Goldstein struct dentry *ret = vfs_tmpfile(dentry, mode, 0); 1877879cb43SVasyl Gomonovych int err = PTR_ERR_OR_ZERO(ret); 188e7f52429SAmir Goldstein 189e7f52429SAmir Goldstein pr_debug("tmpfile(%pd2, 0%o) = %i\n", dentry, mode, err); 190e7f52429SAmir Goldstein return ret; 191e7f52429SAmir Goldstein } 192e7f52429SAmir Goldstein 193bbb1e54dSMiklos Szeredi /* util.c */ 194bbb1e54dSMiklos Szeredi int ovl_want_write(struct dentry *dentry); 195bbb1e54dSMiklos Szeredi void ovl_drop_write(struct dentry *dentry); 196bbb1e54dSMiklos Szeredi struct dentry *ovl_workdir(struct dentry *dentry); 197bbb1e54dSMiklos Szeredi const struct cred *ovl_override_creds(struct super_block *sb); 1987bcd74b9SAmir Goldstein struct super_block *ovl_same_sb(struct super_block *sb); 199e487d889SAmir Goldstein int ovl_can_decode_fh(struct super_block *sb); 20002bcd157SAmir Goldstein struct dentry *ovl_indexdir(struct super_block *sb); 201f168f109SAmir Goldstein bool ovl_index_all(struct super_block *sb); 202f168f109SAmir Goldstein bool ovl_verify_lower(struct super_block *sb); 203bbb1e54dSMiklos Szeredi struct ovl_entry *ovl_alloc_entry(unsigned int numlower); 204bbb1e54dSMiklos Szeredi bool ovl_dentry_remote(struct dentry *dentry); 205bbb1e54dSMiklos Szeredi bool ovl_dentry_weird(struct dentry *dentry); 206e9be9d5eSMiklos Szeredi enum ovl_path_type ovl_path_type(struct dentry *dentry); 207e9be9d5eSMiklos Szeredi void ovl_path_upper(struct dentry *dentry, struct path *path); 208e9be9d5eSMiklos Szeredi void ovl_path_lower(struct dentry *dentry, struct path *path); 209e9be9d5eSMiklos Szeredi enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path); 210e9be9d5eSMiklos Szeredi struct dentry *ovl_dentry_upper(struct dentry *dentry); 211e9be9d5eSMiklos Szeredi struct dentry *ovl_dentry_lower(struct dentry *dentry); 212da309e8cSAmir Goldstein struct ovl_layer *ovl_layer_lower(struct dentry *dentry); 213e9be9d5eSMiklos Szeredi struct dentry *ovl_dentry_real(struct dentry *dentry); 2141d88f183SMiklos Szeredi struct dentry *ovl_i_dentry_upper(struct inode *inode); 21509d8b586SMiklos Szeredi struct inode *ovl_inode_upper(struct inode *inode); 21609d8b586SMiklos Szeredi struct inode *ovl_inode_lower(struct inode *inode); 21709d8b586SMiklos Szeredi struct inode *ovl_inode_real(struct inode *inode); 2184edb83bbSMiklos Szeredi struct ovl_dir_cache *ovl_dir_cache(struct inode *inode); 2194edb83bbSMiklos Szeredi void ovl_set_dir_cache(struct inode *inode, struct ovl_dir_cache *cache); 220c62520a8SAmir Goldstein void ovl_dentry_set_flag(unsigned long flag, struct dentry *dentry); 221c62520a8SAmir Goldstein void ovl_dentry_clear_flag(unsigned long flag, struct dentry *dentry); 222c62520a8SAmir Goldstein bool ovl_dentry_test_flag(unsigned long flag, struct dentry *dentry); 223e9be9d5eSMiklos Szeredi bool ovl_dentry_is_opaque(struct dentry *dentry); 224c412ce49SMiklos Szeredi bool ovl_dentry_is_whiteout(struct dentry *dentry); 2255cf5b477SMiklos Szeredi void ovl_dentry_set_opaque(struct dentry *dentry); 22655acc661SMiklos Szeredi bool ovl_dentry_has_upper_alias(struct dentry *dentry); 22755acc661SMiklos Szeredi void ovl_dentry_set_upper_alias(struct dentry *dentry); 228a6c60655SMiklos Szeredi bool ovl_redirect_dir(struct super_block *sb); 229a6c60655SMiklos Szeredi const char *ovl_dentry_get_redirect(struct dentry *dentry); 230a6c60655SMiklos Szeredi void ovl_dentry_set_redirect(struct dentry *dentry, const char *redirect); 23109d8b586SMiklos Szeredi void ovl_inode_init(struct inode *inode, struct dentry *upperdentry, 23209d8b586SMiklos Szeredi struct dentry *lowerdentry); 23309d8b586SMiklos Szeredi void ovl_inode_update(struct inode *inode, struct dentry *upperdentry); 2344edb83bbSMiklos Szeredi void ovl_dentry_version_inc(struct dentry *dentry, bool impurity); 235bbb1e54dSMiklos Szeredi u64 ovl_dentry_version_get(struct dentry *dentry); 236bbb1e54dSMiklos Szeredi bool ovl_is_whiteout(struct dentry *dentry); 237e9be9d5eSMiklos Szeredi struct file *ovl_path_open(struct path *path, int flags); 23839d3d60aSAmir Goldstein int ovl_copy_up_start(struct dentry *dentry); 23939d3d60aSAmir Goldstein void ovl_copy_up_end(struct dentry *dentry); 240b79e05aaSAmir Goldstein bool ovl_check_origin_xattr(struct dentry *dentry); 241f3a15685SAmir Goldstein bool ovl_check_dir_xattr(struct dentry *dentry, const char *name); 242f3a15685SAmir Goldstein int ovl_check_setxattr(struct dentry *dentry, struct dentry *upperdentry, 243f3a15685SAmir Goldstein const char *name, const void *value, size_t size, 244f3a15685SAmir Goldstein int xerr); 245f3a15685SAmir Goldstein int ovl_set_impure(struct dentry *dentry, struct dentry *upperdentry); 24613c72075SMiklos Szeredi void ovl_set_flag(unsigned long flag, struct inode *inode); 2474edb83bbSMiklos Szeredi void ovl_clear_flag(unsigned long flag, struct inode *inode); 24813c72075SMiklos Szeredi bool ovl_test_flag(unsigned long flag, struct inode *inode); 249ad0af710SAmir Goldstein bool ovl_inuse_trylock(struct dentry *dentry); 250ad0af710SAmir Goldstein void ovl_inuse_unlock(struct dentry *dentry); 25124b33ee1SAmir Goldstein bool ovl_need_index(struct dentry *dentry); 2525f8415d6SAmir Goldstein int ovl_nlink_start(struct dentry *dentry, bool *locked); 2535f8415d6SAmir Goldstein void ovl_nlink_end(struct dentry *dentry, bool locked); 2545820dc08SAmir Goldstein int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir); 255f3a15685SAmir Goldstein 256f3a15685SAmir Goldstein static inline bool ovl_is_impuredir(struct dentry *dentry) 257f3a15685SAmir Goldstein { 258f3a15685SAmir Goldstein return ovl_check_dir_xattr(dentry, OVL_XATTR_IMPURE); 259f3a15685SAmir Goldstein } 260f3a15685SAmir Goldstein 261e487d889SAmir Goldstein static inline unsigned int ovl_xino_bits(struct super_block *sb) 262e487d889SAmir Goldstein { 263e487d889SAmir Goldstein struct ovl_fs *ofs = sb->s_fs_info; 264e487d889SAmir Goldstein 265e487d889SAmir Goldstein return ofs->xino_bits; 266e487d889SAmir Goldstein } 267e487d889SAmir Goldstein 268e9be9d5eSMiklos Szeredi 269bbb1e54dSMiklos Szeredi /* namei.c */ 2708556a420SAmir Goldstein int ovl_check_fh_len(struct ovl_fh *fh, int fh_len); 2718a22efa1SAmir Goldstein struct dentry *ovl_decode_real_fh(struct ovl_fh *fh, struct vfsmount *mnt, 2728a22efa1SAmir Goldstein bool connected); 2738a22efa1SAmir Goldstein int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected, 274f941866fSAmir Goldstein struct dentry *upperdentry, struct ovl_path **stackp); 27505122443SAmir Goldstein int ovl_verify_set_fh(struct dentry *dentry, const char *name, 27605122443SAmir Goldstein struct dentry *real, bool is_upper, bool set); 2773b0bfc6eSAmir Goldstein struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index); 2781eff1a1dSAmir Goldstein int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index); 279359f392cSAmir Goldstein int ovl_get_index_name(struct dentry *origin, struct qstr *name); 28091ffe7beSAmir Goldstein struct dentry *ovl_get_index_fh(struct ovl_fs *ofs, struct ovl_fh *fh); 28106170154SAmir Goldstein struct dentry *ovl_lookup_index(struct ovl_fs *ofs, struct dentry *upper, 28206170154SAmir Goldstein struct dentry *origin, bool verify); 283bbb1e54dSMiklos Szeredi int ovl_path_next(int idx, struct dentry *dentry, struct path *path); 2841eff1a1dSAmir Goldstein struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, 2851eff1a1dSAmir Goldstein unsigned int flags); 286bbb1e54dSMiklos Szeredi bool ovl_lower_positive(struct dentry *dentry); 287e9be9d5eSMiklos Szeredi 28805122443SAmir Goldstein static inline int ovl_verify_origin(struct dentry *upper, 28905122443SAmir Goldstein struct dentry *origin, bool set) 29005122443SAmir Goldstein { 29105122443SAmir Goldstein return ovl_verify_set_fh(upper, OVL_XATTR_ORIGIN, origin, false, set); 29205122443SAmir Goldstein } 29305122443SAmir Goldstein 294ad1d615cSAmir Goldstein static inline int ovl_verify_upper(struct dentry *index, 295ad1d615cSAmir Goldstein struct dentry *upper, bool set) 296ad1d615cSAmir Goldstein { 297ad1d615cSAmir Goldstein return ovl_verify_set_fh(index, OVL_XATTR_UPPER, upper, true, set); 298ad1d615cSAmir Goldstein } 299ad1d615cSAmir Goldstein 300e9be9d5eSMiklos Szeredi /* readdir.c */ 301e9be9d5eSMiklos Szeredi extern const struct file_operations ovl_dir_operations; 302e9be9d5eSMiklos Szeredi int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list); 303e9be9d5eSMiklos Szeredi void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list); 304e9be9d5eSMiklos Szeredi void ovl_cache_free(struct list_head *list); 3054edb83bbSMiklos Szeredi void ovl_dir_cache_free(struct inode *inode); 30645aebeafSVivek Goyal int ovl_check_d_type_supported(struct path *realpath); 307eea2fb48SMiklos Szeredi void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt, 308eea2fb48SMiklos Szeredi struct dentry *dentry, int level); 3091eff1a1dSAmir Goldstein int ovl_indexdir_cleanup(struct ovl_fs *ofs); 310e9be9d5eSMiklos Szeredi 311e9be9d5eSMiklos Szeredi /* inode.c */ 3125f8415d6SAmir Goldstein int ovl_set_nlink_upper(struct dentry *dentry); 3135f8415d6SAmir Goldstein int ovl_set_nlink_lower(struct dentry *dentry); 314caf70cb2SAmir Goldstein unsigned int ovl_get_nlink(struct dentry *lowerdentry, 315caf70cb2SAmir Goldstein struct dentry *upperdentry, 316caf70cb2SAmir Goldstein unsigned int fallback); 317e9be9d5eSMiklos Szeredi int ovl_setattr(struct dentry *dentry, struct iattr *attr); 3185b712091SMiklos Szeredi int ovl_getattr(const struct path *path, struct kstat *stat, 3195b712091SMiklos Szeredi u32 request_mask, unsigned int flags); 320e9be9d5eSMiklos Szeredi int ovl_permission(struct inode *inode, int mask); 3211d88f183SMiklos Szeredi int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char *name, 3221d88f183SMiklos Szeredi const void *value, size_t size, int flags); 3231d88f183SMiklos Szeredi int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name, 3240eb45fc3SAndreas Gruenbacher void *value, size_t size); 325e9be9d5eSMiklos Szeredi ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); 32639a25b2bSVivek Goyal struct posix_acl *ovl_get_acl(struct inode *inode, int type); 3272d902671SMiklos Szeredi int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags); 328d719e8f2SMiklos Szeredi int ovl_update_time(struct inode *inode, struct timespec *ts, int flags); 3290956254aSMiklos Szeredi bool ovl_is_private_xattr(const char *name); 330e9be9d5eSMiklos Szeredi 331ca4c8a3aSMiklos Szeredi struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, dev_t rdev); 3324b91c30aSAmir Goldstein struct inode *ovl_lookup_inode(struct super_block *sb, struct dentry *real, 3334b91c30aSAmir Goldstein bool is_upper); 3340aceb53eSAmir Goldstein struct inode *ovl_get_inode(struct super_block *sb, struct dentry *upperdentry, 33512574a9fSAmir Goldstein struct ovl_path *lowerpath, struct dentry *index, 3360aceb53eSAmir Goldstein unsigned int numlower); 337e9be9d5eSMiklos Szeredi static inline void ovl_copyattr(struct inode *from, struct inode *to) 338e9be9d5eSMiklos Szeredi { 339e9be9d5eSMiklos Szeredi to->i_uid = from->i_uid; 340e9be9d5eSMiklos Szeredi to->i_gid = from->i_gid; 34107a2daabSVivek Goyal to->i_mode = from->i_mode; 342d719e8f2SMiklos Szeredi to->i_atime = from->i_atime; 343d719e8f2SMiklos Szeredi to->i_mtime = from->i_mtime; 344d719e8f2SMiklos Szeredi to->i_ctime = from->i_ctime; 345e9be9d5eSMiklos Szeredi } 346e9be9d5eSMiklos Szeredi 347e9be9d5eSMiklos Szeredi /* dir.c */ 348e9be9d5eSMiklos Szeredi extern const struct inode_operations ovl_dir_inode_operations; 3493d27573cSMiklos Szeredi struct dentry *ovl_lookup_temp(struct dentry *workdir); 350e7dd0e71SAmir Goldstein int ovl_cleanup_and_whiteout(struct dentry *workdir, struct inode *dir, 351e7dd0e71SAmir Goldstein struct dentry *dentry); 352*471ec5dcSAmir Goldstein struct ovl_cattr { 35332a3d848SAl Viro dev_t rdev; 35432a3d848SAl Viro umode_t mode; 35532a3d848SAl Viro const char *link; 356*471ec5dcSAmir Goldstein struct dentry *hardlink; 35732a3d848SAl Viro }; 358*471ec5dcSAmir Goldstein 359*471ec5dcSAmir Goldstein #define OVL_CATTR(m) (&(struct ovl_cattr) { .mode = (m) }) 360*471ec5dcSAmir Goldstein 361e9be9d5eSMiklos Szeredi int ovl_create_real(struct inode *dir, struct dentry *newdentry, 362*471ec5dcSAmir Goldstein struct ovl_cattr *attr); 363415543d5SAmir Goldstein int ovl_cleanup(struct inode *dir, struct dentry *dentry); 364e9be9d5eSMiklos Szeredi 365e9be9d5eSMiklos Szeredi /* copy_up.c */ 366e9be9d5eSMiklos Szeredi int ovl_copy_up(struct dentry *dentry); 3679aba6521SAmir Goldstein int ovl_copy_up_flags(struct dentry *dentry, int flags); 368e9be9d5eSMiklos Szeredi int ovl_copy_xattr(struct dentry *old, struct dentry *new); 369e9be9d5eSMiklos Szeredi int ovl_set_attr(struct dentry *upper, struct kstat *stat); 3705b2cccd3SAmir Goldstein struct ovl_fh *ovl_encode_real_fh(struct dentry *real, bool is_upper); 3719678e630SAmir Goldstein int ovl_set_origin(struct dentry *dentry, struct dentry *lower, 3729678e630SAmir Goldstein struct dentry *upper); 3738ed5eec9SAmir Goldstein 3748ed5eec9SAmir Goldstein /* export.c */ 3758ed5eec9SAmir Goldstein extern const struct export_operations ovl_export_operations; 376