Skip to contentSkip to conversation

namespace question

DISCUSSION [email protected] 2 participants 2 messages Jun 23, 2005

lore
Share & tools
lore
#0 lore raw

I don't believe the following to be an error, but I am curious how it occurs:

Running a kernel module which uses d_path iteratively over the mnt_mountpoint members of the vfsmount structures which hang off of current->namespace->list, I get a curious doubling of the mount point names:

rootfs / rootfs
/dev2/root2 / ext3
proc /proc/proc proc
sysfs /sys/sys sysfs
devpts /dev/pts/dev/pts devpts
tmpfs /dev/shm/dev/shm tmpfs
/dev/hda1 /boot/boot ext2
usbfs /proc/bus/usb/bus/usb usbfs

Is there any simple explanation? I have cross-checked and it appears _not_ be be an artifact of my programming, and I have no CLONE_NEWNS processes. Using the same algorithm with mnt_root produces correct results.

The code follows:

        char *path;
...
        namespace = current-> namespace
        down_read(&namespace->sem);
        list_for_each_entry(vfsmnt_ptr,&namespace->list,mnt_list) {
                mount = mntget(vfsmnt_ptr);
                dentry = dget(vfsmnt_ptr->mnt_mountpoint);

                device = vfsmnt_ptr->mnt_devname ? vfsmnt_ptr->mnt_devname : "none";

                path = d_path(dentry, mount, buf, PAGE_SIZE);
                error = PTR_ERR(path);
                if(IS_ERR(path)) {
                        dput(dentry);
                        mntput(mount);
                        goto out;
                }

                fstype = vfsmnt_ptr->mnt_sb->s_type->name;
                printk("%s\t%s\t%s\n",device,path,fstype);

---

$ uname -a
Linux nectarsys 2.6.10-1-k7 #1 Fri Mar 11 03:13:32 EST 2005 i686 GNU/Linux
#1 lore raw
Quoted 17 lines · [email protected] wrote:

I don't believe the following to be an error, but I am curious how it occurs:

Running a kernel module which uses d_path iteratively over the mnt_mountpoint members of the vfsmount structures which hang off of current->namespace->list, I get a curious doubling of the mount point names:

rootfs / rootfs
/dev2/root2 / ext3
proc /proc/proc proc
sysfs /sys/sys sysfs
devpts /dev/pts/dev/pts devpts
tmpfs /dev/shm/dev/shm tmpfs
/dev/hda1 /boot/boot ext2
usbfs /proc/bus/usb/bus/usb usbfs

Is there any simple explanation? I have cross-checked and it appears _not_ be be an artifact of my programming, and I have no CLONE_NEWNS processes. Using the same algorithm with mnt_root produces correct results.

The code follows:

Quoted 7 lines
        char *path;
...
        namespace = current-> namespace
        down_read(&namespace->sem);
        list_for_each_entry(vfsmnt_ptr,&namespace->list,mnt_list) {
                mount = mntget(vfsmnt_ptr);
                dentry = dget(vfsmnt_ptr->mnt_mountpoint);

should be:

dentry = dget(vfsmnt_ptr->mnt_root);

Quoted 13 lines
                device = vfsmnt_ptr->mnt_devname ? vfsmnt_ptr->mnt_devname : "none";

                path = d_path(dentry, mount, buf, PAGE_SIZE);
                error = PTR_ERR(path);
                if(IS_ERR(path)) {
                        dput(dentry);
                        mntput(mount);
                        goto out;
                }

                fstype = vfsmnt_ptr->mnt_sb->s_type->name;
                printk("%s\t%s\t%s\n",device,path,fstype);
Quoted 8 lines

---

$ uname -a
Linux nectarsys 2.6.10-1-k7 #1 Fri Mar 11 03:13:32 EST 2005 i686 GNU/Linux

Mike Waychison