Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs/procfs On my 24 proc box I got ENOSPC, so make th...



details:   https://anonhg.NetBSD.org/src/rev/f9854501722d
branches:  trunk
changeset: 328518:f9854501722d
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Apr 05 18:42:32 2014 +0000

description:
On my 24 proc box I got ENOSPC, so make the routine return the size it wants
and try again.

diffstat:

 sys/miscfs/procfs/procfs.h       |   4 ++--
 sys/miscfs/procfs/procfs_linux.c |  17 +++++++++--------
 2 files changed, 11 insertions(+), 10 deletions(-)

diffs (58 lines):

diff -r 477abdfdf10e -r f9854501722d sys/miscfs/procfs/procfs.h
--- a/sys/miscfs/procfs/procfs.h        Sat Apr 05 17:06:44 2014 +0000
+++ b/sys/miscfs/procfs/procfs.h        Sat Apr 05 18:42:32 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: procfs.h,v 1.68 2012/05/28 13:16:10 christos Exp $     */
+/*     $NetBSD: procfs.h,v 1.69 2014/04/05 18:42:32 christos Exp $     */
 
 /*
  * Copyright (c) 1993
@@ -245,7 +245,7 @@
 
 int procfs_rw(void *);
 
-int procfs_getcpuinfstr(char *, int *);
+int procfs_getcpuinfstr(char *, size_t *);
 
 #define PROCFS_LOCKED  0x01
 #define PROCFS_WANT    0x02
diff -r 477abdfdf10e -r f9854501722d sys/miscfs/procfs/procfs_linux.c
--- a/sys/miscfs/procfs/procfs_linux.c  Sat Apr 05 17:06:44 2014 +0000
+++ b/sys/miscfs/procfs/procfs_linux.c  Sat Apr 05 18:42:32 2014 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: procfs_linux.c,v 1.66 2013/11/27 17:24:44 christos Exp $      */
+/*      $NetBSD: procfs_linux.c,v 1.67 2014/04/05 18:42:32 christos Exp $      */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.66 2013/11/27 17:24:44 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.67 2014/04/05 18:42:32 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -510,14 +510,15 @@
 procfs_docpuinfo(struct lwp *curl, struct proc *p,
     struct pfsnode *pfs, struct uio *uio)
 {
-       int len = LBFSZ;
-       char *bf = malloc(len, M_TEMP, M_WAITOK);
+       size_t len = LBFSZ;
+       char *bf = NULL;
        int error;
 
-       if (procfs_getcpuinfstr(bf, &len) < 0) {
-               error = ENOSPC;
-               goto done;
-       }
+       do {
+               if (bf)
+                       free(bf, M_TEMP);
+               bf = malloc(len, M_TEMP, M_WAITOK);
+       } while (procfs_getcpuinfstr(bf, &len) < 0);
 
        if (len == 0) {
                error = 0;



Home | Main Index | Thread Index | Old Index