Module Name:    src
Committed By:   jdolecek
Date:           Fri Apr 10 10:53:02 UTC 2020

Modified Files:
        src/sys/dev: vnd.c

Log Message:
add support for DIOCGSTRATEGY and DIOCGCACHE

only allow DIOCCACHESYNC if open for writing, same as everything supporting
DIOCCACHESYNC


To generate a diff of this commit:
cvs rdiff -u -r1.274 -r1.275 src/sys/dev/vnd.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/vnd.c
diff -u src/sys/dev/vnd.c:1.274 src/sys/dev/vnd.c:1.275
--- src/sys/dev/vnd.c:1.274	Sun Feb 23 15:46:39 2020
+++ src/sys/dev/vnd.c	Fri Apr 10 10:53:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.274 2020/02/23 15:46:39 ad Exp $	*/
+/*	$NetBSD: vnd.c,v 1.275 2020/04/10 10:53:02 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008, 2020 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.274 2020/02/23 15:46:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.275 2020/04/10 10:53:02 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -1216,6 +1216,7 @@ vndioctl(dev_t dev, u_long cmd, void *da
 #endif
 	case DIOCKLABEL:
 	case DIOCWLABEL:
+	case DIOCCACHESYNC:
 		if ((flag & FWRITE) == 0)
 			return EBADF;
 	}
@@ -1231,6 +1232,8 @@ vndioctl(dev_t dev, u_long cmd, void *da
 	case DIOCKLABEL:
 	case DIOCWLABEL:
 	case DIOCGDEFLABEL:
+	case DIOCGCACHE:
+	case DIOCGSTRATEGY:
 	case DIOCCACHESYNC:
 #ifdef __HAVE_OLD_DISKLABEL
 	case ODIOCGDINFO:
@@ -1645,6 +1648,23 @@ unlock_and_exit:
 		break;
 #endif
 
+	case DIOCGSTRATEGY:
+	    {
+		struct disk_strategy *dks = (void *)data;
+
+		/* No lock needed, never changed */
+		strlcpy(dks->dks_name,
+		    bufq_getstrategyname(vnd->sc_tab),
+		    sizeof(dks->dks_name));
+		dks->dks_paramlen = 0;
+		break;
+	    }
+	case DIOCGCACHE:
+	    {
+		int *bits = (int *)data;
+		*bits |= DKCACHE_READ | DKCACHE_WRITE;
+		break;
+	    }
 	case DIOCCACHESYNC:
 		vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY);
 		error = VOP_FSYNC(vnd->sc_vp, vnd->sc_cred,

Reply via email to