Re: [PATCH] Add MOUNT_STATUS ioctl to cdrom device

From: Christoph Hellwig
Date: Mon Aug 25 2003 - 13:51:43 EST


On Tue, Aug 26, 2003 at 01:22:37AM +0700, Samphan Raruenrom wrote:
> #include <linux/sysctl.h>
> #include <linux/proc_fs.h>
> #include <linux/init.h>
> +#include <linux/namespace.h>
> +#include <linux/mount.h>

your mailer is screwed.

>
> + case CDROM_MOUNT_STATUS: {
> + struct super_block *sb = get_super(dev);
> + if (sb == NULL) return -EINVAL;
> + down_read(&current->namespace->sem);
> + struct vfsmount *mnt = NULL;
> + struct list_head *p;
> + list_for_each(p, &current->namespace->list) {
> + struct vfsmount *m = list_entry(p, struct vfsmount, mnt_list);
> + if (sb == m->mnt_sb) {
> + mnt = m; break;
> + }
> + }
> + up_read(&current->namespace->sem);
> + drop_super(sb);
> + int mstat = 0; /* 0 not mounted, 1 umount ok, 2 umount EBUSY */
> + if (mnt) mstat = 1 + (atomic_read(&mnt->mnt_count) > 1);
> + cdinfo(CD_DO_IOCTL, "mount status(%s) = %d\n", mnt->mnt_devname, mstat);
> + return mstat;

WTF? This is not only a layering violation but also totally racy.

Rejected.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/