Source-Changes-HG archive

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

[src/trunk]: src/sys/kern When calculating the space needed for the data, use...



details:   https://anonhg.NetBSD.org/src/rev/e7d56513c575
branches:  trunk
changeset: 538855:e7d56513c575
user:      simonb <simonb%NetBSD.org@localhost>
date:      Fri Nov 01 15:20:03 2002 +0000

description:
When calculating the space needed for the data, use the supplied
userland structure size (if passed in).
Use the supplied userland structure size (if passed in) to check if
there is enough room to copyout the next structure.

diffstat:

 sys/kern/subr_disk.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r caa38322a591 -r e7d56513c575 sys/kern/subr_disk.c
--- a/sys/kern/subr_disk.c      Fri Nov 01 14:02:21 2002 +0000
+++ b/sys/kern/subr_disk.c      Fri Nov 01 15:20:03 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_disk.c,v 1.45 2002/11/01 11:32:01 mrg Exp $       */
+/*     $NetBSD: subr_disk.c,v 1.46 2002/11/01 15:20:03 simonb Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 1999, 2000 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.45 2002/11/01 11:32:01 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.46 2002/11/01 15:20:03 simonb Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -397,7 +397,10 @@
        int error;
 
        if (where == NULL) {
-               *sizep = disk_count * sizeof(sdisk);
+               if (namelen == 0)
+                       *sizep = disk_count * sizeof(sdisk);
+               else
+                       *sizep = disk_count * name[0];
                return (0);
        }
 
@@ -413,7 +416,7 @@
 
        simple_lock(&disklist_slock);
        TAILQ_FOREACH(diskp, &disklist, dk_link) {
-               if (left < sizeof(struct disk_sysctl))
+               if (left < tocopy)
                        break;
                strncpy(sdisk.dk_name, diskp->dk_name, sizeof(sdisk.dk_name));
                sdisk.dk_xfer = diskp->dk_rxfer + diskp->dk_wxfer;



Home | Main Index | Thread Index | Old Index