Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add a DIOCTUR (test unit ready) ioctl, to allow userland...



details:   https://anonhg.NetBSD.org/src/rev/dbee5a5086ed
branches:  trunk
changeset: 753298:dbee5a5086ed
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Mar 22 16:49:41 2010 +0000

description:
Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.

diffstat:

 sys/dev/scsipi/cd.c |  14 ++++++++++++--
 sys/sys/dkio.h      |   5 ++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diffs (59 lines):

diff -r dc52a7e8d6a5 -r dbee5a5086ed sys/dev/scsipi/cd.c
--- a/sys/dev/scsipi/cd.c       Mon Mar 22 16:43:08 2010 +0000
+++ b/sys/dev/scsipi/cd.c       Mon Mar 22 16:49:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd.c,v 1.298 2010/03/11 04:00:36 mrg Exp $     */
+/*     $NetBSD: cd.c,v 1.299 2010/03/22 16:49:41 martin Exp $  */
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.298 2010/03/11 04:00:36 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.299 2010/03/22 16:49:41 martin Exp $");
 
 #include "rnd.h"
 
@@ -1270,6 +1270,7 @@
                case ODIOCEJECT:
                case DIOCEJECT:
                case DIOCCACHESYNC:
+               case DIOCTUR:
                case SCIOCIDENTIFY:
                case OSCIOCIDENTIFY:
                case SCIOCCOMMAND:
@@ -1397,6 +1398,15 @@
                return error;
 #endif
 
+       case DIOCTUR: {
+               /* test unit ready */
+               error = scsipi_test_unit_ready(cd->sc_periph, XS_CTL_SILENT);
+               *((int*)addr) = (error == 0);
+               if (error == ENODEV || error == EIO || error == 0)
+                       return 0;                       
+               return error;
+       }
+
        case CDIOCPLAYTRACKS: {
                /* PLAY_MSF command */
                struct ioc_play_track *args = addr;
diff -r dc52a7e8d6a5 -r dbee5a5086ed sys/sys/dkio.h
--- a/sys/sys/dkio.h    Mon Mar 22 16:43:08 2010 +0000
+++ b/sys/sys/dkio.h    Mon Mar 22 16:49:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dkio.h,v 1.15 2009/12/22 18:55:25 pooka Exp $  */
+/*     $NetBSD: dkio.h,v 1.16 2010/03/22 16:49:41 martin Exp $ */
 
 /*
  * Copyright (c) 1987, 1988, 1993
@@ -105,4 +105,7 @@
                /* get disk-info dictionary */
 #define        DIOCGDISKINFO   _IOR('d', 127, struct plistref)
 
+
+#define        DIOCTUR         _IOR('d', 128, int)     /* test unit ready */
+
 #endif /* _SYS_DKIO_H_ */



Home | Main Index | Thread Index | Old Index