Module Name:    src
Committed By:   dsl
Date:           Sun Dec  6 16:35:16 UTC 2009

Modified Files:
        src/usr.sbin/vnconfig: vnconfig.c

Log Message:
VNDIOCSET now returns a 64bit unsigned size.
Use compat ioctls if the kernel rejects the request.
Fixes PR/41873.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/vnconfig/vnconfig.c

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

Modified files:

Index: src/usr.sbin/vnconfig/vnconfig.c
diff -u src/usr.sbin/vnconfig/vnconfig.c:1.37 src/usr.sbin/vnconfig/vnconfig.c:1.38
--- src/usr.sbin/vnconfig/vnconfig.c:1.37	Sun Apr 19 00:56:32 2009
+++ src/usr.sbin/vnconfig/vnconfig.c	Sun Dec  6 16:35:16 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnconfig.c,v 1.37 2009/04/19 00:56:32 lukem Exp $	*/
+/*	$NetBSD: vnconfig.c,v 1.38 2009/12/06 16:35:16 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -119,6 +119,7 @@
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -326,6 +327,10 @@
 		if (force)
 			vndio.vnd_flags |= VNDIOF_FORCE;
 		rv = ioctl(fd, VNDIOCCLR, &vndio);
+#ifdef VNDIOOCCLR
+		if (rv && errno == ENOTTY)
+			rv = ioctl(fd, VNDIOOCCLR, &vndio);
+#endif
 		if (rv)
 			warn("%s: VNDIOCCLR", rdev);
 		else if (verbose)
@@ -344,10 +349,16 @@
 			(void) close(ffd);
 
 			rv = ioctl(fd, VNDIOCSET, &vndio);
+#ifdef VNDIOOCSET
+			if (rv && errno == ENOTTY) {
+				rv = ioctl(fd, VNDIOOCSET, &vndio);
+				vndio.vnd_size = vndio.vnd_osize;
+			}
+#endif
 			if (rv)
 				warn("%s: VNDIOCSET", rdev);
 			else if (verbose) {
-				printf("%s: %d bytes on %s", rdev,
+				printf("%s: %" PRIu64 " bytes on %s", rdev,
 				    vndio.vnd_size, file);
 				if (vndio.vnd_flags & VNDIOF_HASGEOM)
 					printf(" using geometry %d/%d/%d/%d",

Reply via email to