Re: stat inconsistency with overlayfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Hu, Atom2,

> I don't have the Overlayfs code on 3.11 or 3.13. I've lookup the v11
> code in Miklos's git tree:
Fortunately I got the overlay fs code of kernel V3.18, which is mostly
same to v11 code in Miklos's git.

135 static int ovl_dir_getattr(struct vfsmount *mnt, struct dentry *dentry,
136              struct kstat *stat)
137 {
138     int err;
139     enum ovl_path_type type;
140     struct path realpath;
141 
142     type = ovl_path_real(dentry, &realpath);
143     err = vfs_getattr(&realpath, stat);
144     if (err)
145         return err;
146 
147     stat->dev = dentry->d_sb->s_dev;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ here set dev number as Hu mentioned
148     stat->ino = dentry->d_inode->i_ino;
149 
150     /*
151      * It's probably not worth it to count subdirs to get the
152      * correct link count.  nlink=1 seems to pacify 'find' and
153      * other utilities.
154      */
155     if (type == OVL_PATH_MERGE)
156         stat->nlink = 1;
157 
158     return 0;
159 }

And the d_sb->s_dev is coming from the super_block of overlayfs, which is fake.
The super block s_dev is initialized by the call trace 
"mount_nodev->set_anon_super-->get_anon_bdev".

Either the dir exists in lower or exists in upper, the overlay fs fakes it exits in
overlay, which holds the fake device number.

Thanks,

George
-- 
George Wang 王旭

Kernel Quantity Engineer
Red Hat Software (Beijing) Co.,Ltd
IRC:xuw
Tel:+86-010-62608041
Phone:15901231579
9/F, Tower C, Raycom
--
To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux