diff -dru linux-2.4.22-pre10.orig/drivers/cdrom/cdrom.c linux-2.4.22-pre10/drivers/cdrom/cdrom.c
--- linux-2.4.22-pre10.orig/drivers/cdrom/cdrom.c	2002-11-29 06:53:12.000000000 +0700
+++ linux-2.4.22-pre10/drivers/cdrom/cdrom.c	2003-08-14 20:14:22.000000000 +0700
@@ -264,6 +264,8 @@
 #include <linux/sysctl.h>
 #include <linux/proc_fs.h>
 #include <linux/init.h>
+#include <linux/namespace.h>
+#include <linux/mount.h>
 
 #include <asm/fcntl.h>
 #include <asm/segment.h>
@@ -1617,11 +1619,37 @@
 		keeplocked = arg ? 1 : 0;
 		/* don't unlock the door on multiple opens,but allow root
 		 * to do so */
-		if ((cdi->use_count != 1) && !arg && !capable(CAP_SYS_ADMIN))
+		if ((cdi->use_count != 1) && !arg && !capable(CAP_SYS_ADMIN)) {
+			/* special case when user-space 
+			   tell that it will handle locking itself */
+			if (!(cdi->options & CDO_LOCK) && cdi->use_count == 2)
+				goto unlock_ok; 
 			return -EBUSY;
+		}
+		unlock_ok:
 		return cdo->lock_door(cdi, arg);
 		}
 
+	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;
+		}
+	
 	case CDROM_DEBUG: {
 		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
diff -dru linux-2.4.22-pre10.orig/include/linux/cdrom.h linux-2.4.22-pre10/include/linux/cdrom.h
--- linux-2.4.22-pre10.orig/include/linux/cdrom.h	2003-08-05 02:59:58.000000000 +0700
+++ linux-2.4.22-pre10/include/linux/cdrom.h	2003-08-13 21:41:27.000000000 +0700
@@ -127,6 +127,7 @@
 #define CDROM_LOCKDOOR		0x5329  /* lock or unlock door */
 #define CDROM_DEBUG		0x5330	/* Turn debug messages on/off */
 #define CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
+#define CDROM_MOUNT_STATUS	0x5332	/* is it mounted? can umount? */
 
 /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
  * Future CDROM ioctls should be kept below 0x537F
