lkml.org 
[lkml]   [2003]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Add MOUNT_STATUS ioctl to cdrom device
Christoph Hellwig wrote:
>>+ 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.

I'm sorry for issueing this layering violation. I read a guideline that
it's easier to submit a patch to add device driver ioctl than inventing
something new. It really doesn't belong here.
Could you guide me where else can I place this functionality?

(my random idea)
- fcntl(open("/dev/cdrom", F_MNTSTAT)
- umount2("/dev/cdrom", MS_TEST) // not actually perform
- new system call! e.g. mntstat(open("/dev/cdrom"))

--
Samphan Raruenrom,
The Open Source Project,
National Electronics and Computer Technology Center,
National Science and Technology Development Agency,
Thailand.

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

\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.062 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site