Module Name:    src
Committed By:   riz
Date:           Wed Oct 31 15:17:53 UTC 2012

Modified Files:
        src/sys/dev/scsipi [netbsd-5]: sd.c

Log Message:
sys/dev/scsipi/sd.c                             patch

        Allow disk strategy to be queried and changed at runtime
        for sd(4) disks.
        [buhrow, ticket #1807]


To generate a diff of this commit:
cvs rdiff -u -r1.275 -r1.275.4.1 src/sys/dev/scsipi/sd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.275 src/sys/dev/scsipi/sd.c:1.275.4.1
--- src/sys/dev/scsipi/sd.c:1.275	Wed Jul 16 18:54:09 2008
+++ src/sys/dev/scsipi/sd.c	Wed Oct 31 15:17:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.275 2008/07/16 18:54:09 drochner Exp $	*/
+/*	$NetBSD: sd.c,v 1.275.4.1 2012/10/31 15:17:53 riz Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.275 2008/07/16 18:54:09 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.275.4.1 2012/10/31 15:17:53 riz Exp $");
 
 #include "opt_scsi.h"
 #include "rnd.h"
@@ -1003,7 +1003,7 @@ sdioctl(dev_t dev, u_long cmd, void *add
 	struct sd_softc *sd = device_lookup_private(&sd_cd, SDUNIT(dev));
 	struct scsipi_periph *periph = sd->sc_periph;
 	int part = SDPART(dev);
-	int error = 0;
+	int error = 0, s;
 #ifdef __HAVE_OLD_DISKLABEL
 	struct disklabel *newlabel = NULL;
 #endif
@@ -1027,6 +1027,8 @@ sdioctl(dev_t dev, u_long cmd, void *add
 		case OSCIOCIDENTIFY:
 		case SCIOCCOMMAND:
 		case SCIOCDEBUG:
+		case DIOCGSTRATEGY:
+		case DIOCSSTRATEGY:
 			if (part == RAW_PART)
 				break;
 		/* FALLTHROUGH */
@@ -1237,6 +1239,47 @@ sdioctl(dev_t dev, u_long cmd, void *add
 		return (dkwedge_list(&sd->sc_dk, dkwl, l));
 	    }
 
+	case DIOCGSTRATEGY:
+	    {
+		struct disk_strategy *dks = (void *)addr;
+
+		s = splbio();
+		strlcpy(dks->dks_name, bufq_getstrategyname(sd->buf_queue),
+		    sizeof(dks->dks_name));
+		splx(s);
+		dks->dks_paramlen = 0;
+
+		return 0;
+	    }
+	
+	case DIOCSSTRATEGY:
+	    {
+		struct disk_strategy *dks = (void *)addr;
+		struct bufq_state *new;
+		struct bufq_state *old;
+
+		if ((flag & FWRITE) == 0) {
+			return EBADF;
+		}
+		if (dks->dks_param != NULL) {
+			return EINVAL;
+		}
+		dks->dks_name[sizeof(dks->dks_name) - 1] = 0; /* ensure term */
+		error = bufq_alloc(&new, dks->dks_name,
+		    BUFQ_EXACT|BUFQ_SORT_RAWBLOCK);
+		if (error) {
+			return error;
+		}
+		s = splbio();
+		old = sd->buf_queue;
+		bufq_move(new, old);
+		sd->buf_queue = new;
+		splx(s);
+		bufq_free(old);
+
+		return 0;
+	    }
+
 	default:
 		if (part != RAW_PART)
 			return (ENOTTY);

Reply via email to