calling kern_path during mount process

77 Views Asked by At

I'm trying to get devt of mountpoint (path*) in one of the LSM hooks. Assuming I have the following mount:

/dev/mmcblk0p5 is mounted to /mnt/photos

I would expect that calling

kern_path("/mnt/photos", ...)

will return a struct path with path.mnt->mnt_sb->s_dev = 0x0b300005 since /dev/mmcblk0p5 is 179:5, but I always get 0x0b300002 (i.e. 179:2) - which is the root-fs device. Only after mounting again /dev/mmcblk0p5 to /mnt/photos, kern_path returns 0x0b300005.

Why is that? How can I fix it?
It happens with both kernel 4.14 and 5.15.

some more info, after 1st mount, printing address of path.mnt->mnt_sb is the same as of "/" (0x0b300002). after 2nd mount, printing address of path.mnt->mnt_sb is different. i guess that mnt_sb is being updated sometime between the 1st and the 2nd mount. so, when it happens? how can i get notification/hook after this update?

0

There are 0 best solutions below