/* || bindex > au_sbend(dentry->d_sb) */); d = au_di(dentry)->di_hdentry[0 + bindex].hd_dentry; AuDebugOn(d && (atomic_read(&d->d_count) <= 0)); return d; } aufs_bindex_t au_dbtail(struct dentry *dentry) { aufs_bindex_t bend, bwh; bend = au_dbend(dentry); if (0 <= bend) { bwh = au_dbwh(dentry); if (!bwh) return bwh; if (0 < bwh && bwh < bend) return bwh - 1; } return bend; } aufs_bindex_t au_dbtaildir(struct dentry *dentry) { aufs_bindex_t bend, bopq; AuDebugOn(dentry->d_inode && dentry->d_inode->i_mode && !S_ISDIR(dentry->d_inode->i_mode)); bend = au_dbtail(dentry); if (0 <= bend) { bopq = au_dbdiropq(dentry); AuDebugOn(bend < bopq); if (0 <= bopq && bopq < bend) bend = bopq; } return bend; } #if 0 /* reserved for future use */ aufs_bindex_t au_dbtail_generic(struct dentry *dentry) { struct inode *inode; inode = dentry->d_inode; if (inode && S_ISDIR(inode->i_mode)) return au_dbtaildir(dentry); else return au_dbtail(dentry); }
aufs_bindex_t au_dbtaildir(struct dentry *dentry) { aufs_bindex_t bend, bopq; bend = au_dbtail(dentry); if (0 <= bend) { bopq = au_dbdiropq(dentry); if (0 <= bopq && bopq < bend) bend = bopq; } return bend; }
aufs_bindex_t au_dbtaildir(struct dentry *dentry) { aufs_bindex_t bend, bopq; AuDebugOn(dentry->d_inode && dentry->d_inode->i_mode && !S_ISDIR(dentry->d_inode->i_mode)); bend = au_dbtail(dentry); if (0 <= bend) { bopq = au_dbdiropq(dentry); AuDebugOn(bend < bopq); if (0 <= bopq && bopq < bend) bend = bopq; } return bend; }
static int set_inode(struct inode *inode, struct dentry *dentry) { int err; unsigned int flags; umode_t mode; aufs_bindex_t bindex, bstart, btail; unsigned char isdir; struct dentry *h_dentry; struct inode *h_inode; struct au_iinfo *iinfo; IiMustWriteLock(inode); err = 0; isdir = 0; bstart = au_dbstart(dentry); h_inode = au_h_dptr(dentry, bstart)->d_inode; mode = h_inode->i_mode; switch (mode & S_IFMT) { case S_IFREG: btail = au_dbtail(dentry); inode->i_op = &aufs_iop; inode->i_fop = &aufs_file_fop; inode->i_mapping->a_ops = &aufs_aop; break; case S_IFDIR: isdir = 1; btail = au_dbtaildir(dentry); inode->i_op = &aufs_dir_iop; inode->i_fop = &aufs_dir_fop; break; case S_IFLNK: btail = au_dbtail(dentry); inode->i_op = &aufs_symlink_iop; break; case S_IFBLK: case S_IFCHR: case S_IFIFO: case S_IFSOCK: btail = au_dbtail(dentry); inode->i_op = &aufs_iop; au_init_special_fop(inode, mode, h_inode->i_rdev); break; default: AuIOErr("Unknown file type 0%o\n", mode); err = -EIO; goto out; } /* do not set inotify for whiteouted dirs (SHWH mode) */ flags = au_hi_flags(inode, isdir); if (au_opt_test(au_mntflags(dentry->d_sb), SHWH) && au_ftest_hi(flags, HINOTIFY) && dentry->d_name.len > AUFS_WH_PFX_LEN && !memcmp(dentry->d_name.name, AUFS_WH_PFX, AUFS_WH_PFX_LEN)) au_fclr_hi(flags, HINOTIFY); iinfo = au_ii(inode); iinfo->ii_bstart = bstart; iinfo->ii_bend = btail; for (bindex = bstart; bindex <= btail; bindex++) { h_dentry = au_h_dptr(dentry, bindex); if (h_dentry) au_set_h_iptr(inode, bindex, au_igrab(h_dentry->d_inode), flags); } au_cpup_attr_all(inode, /*force*/1); out: return err; }