Subject: Upgrade of `struct vnd_ioctl'
To: None <tech-kern@netbsd.org>
From: Arnaud Lacombe <arnaud.lacombe.1@ulaval.ca>
List: tech-kern
Date: 02/11/2007 14:27:22
--x+6KMIRAuhnl3hBn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

I'd like to change the size of the `vnd_size' member of struct vnd_ioctl
from `int' to `u_quad_t' (or any other unsigned 64bits type, but
u_quad_t is used by `struct vattr->va_size').

Currently, it is quite easy make it either negative or greater than
2^32[1]. This field is only used when we call vnconfig(8) with -v
(verbose).

Does the change needs any compatibility layer to be added ? 

Thanks in advance,

 - Arnaud

[1]: e.g. with a DVD image:
% ls -l foo.iso 
-rw-r--r--  1 root  wheel  4449662976 Feb  6 23:25 foo.iso
% sudo vnconfig -r -v vnd0 foo.iso
/dev/rvnd0d: 154695680 bytes on foo.iso 


--x+6KMIRAuhnl3hBn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="vnd_ioctl.diff"

Index: src/sys/dev/vndvar.h
===================================================================
RCS file: /data/netbsd/cvsroot/src/sys/dev/vndvar.h,v
retrieving revision 1.20
diff -u -r1.20 vndvar.h
--- src/sys/dev/vndvar.h	14 May 2006 21:42:26 -0000	1.20
+++ src/sys/dev/vndvar.h	11 Feb 2007 19:01:11 -0000
@@ -132,7 +132,7 @@
 	char		*vnd_file;	/* pathname of file to mount */
 	int		vnd_flags;	/* flags; see below */
 	struct vndgeom	vnd_geom;	/* geometry to emulate */
-	int		vnd_size;	/* (returned) size of disk */
+	u_quad_t	vnd_size;	/* (returned) size of disk */
 };
 
 /* vnd_flags */
Index: src/sys/dev/vnd.c
===================================================================
RCS file: /data/netbsd/cvsroot/src/sys/dev/vnd.c,v
retrieving revision 1.161
diff -u -r1.161 vnd.c
--- src/sys/dev/vnd.c	28 Jan 2007 21:33:24 -0000	1.161
+++ src/sys/dev/vnd.c	11 Feb 2007 19:03:47 -0000
@@ -1182,7 +1182,7 @@
 			goto close_and_exit;
 
 		vndthrottle(vnd, vnd->sc_vp);
-		vio->vnd_size = dbtob(vnd->sc_size);
+		vio->vnd_size = vattr.va_size;
 		vnd->sc_flags |= VNF_INITED;
 
 		/* create the kernel thread, wait for it to be up */
Index: src/usr.sbin/vnconfig/vnconfig.c
===================================================================
RCS file: /data/netbsd/cvsroot/src/usr.sbin/vnconfig/vnconfig.c,v
retrieving revision 1.34
diff -u -r1.34 vnconfig.c
--- src/usr.sbin/vnconfig/vnconfig.c	19 Aug 2005 02:09:50 -0000	1.34
+++ src/usr.sbin/vnconfig/vnconfig.c	11 Feb 2007 19:08:23 -0000
@@ -353,7 +353,7 @@
 			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",

--x+6KMIRAuhnl3hBn--