CVS commit: src/sys/uvm
Module Name:src Committed By: matt Date: Tue Jan 4 08:17:01 UTC 2011 Modified Files: src/sys/uvm: uvm_stat.c Log Message: Print the number of page colors in use with db show uvm To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/uvm/uvm_stat.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/uvm/uvm_stat.c diff -u src/sys/uvm/uvm_stat.c:1.33 src/sys/uvm/uvm_stat.c:1.34 --- src/sys/uvm/uvm_stat.c:1.33 Mon Dec 20 00:25:48 2010 +++ src/sys/uvm/uvm_stat.c Tue Jan 4 08:17:01 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_stat.c,v 1.33 2010/12/20 00:25:48 matt Exp $ */ +/* $NetBSD: uvm_stat.c,v 1.34 2011/01/04 08:17:01 matt Exp $ */ /* * @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: uvm_stat.c,v 1.33 2010/12/20 00:25:48 matt Exp $); +__KERNEL_RCSID(0, $NetBSD: uvm_stat.c,v 1.34 2011/01/04 08:17:01 matt Exp $); #include opt_uvmhist.h #include opt_readahead.h @@ -215,9 +215,9 @@ uvm_estimatepageable(active, inactive); (*pr)(Current UVM status:\n); - (*pr)( pagesize=%d (0x%x), pagemask=0x%x, pageshift=%d\n, + (*pr)( pagesize=%d (0x%x), pagemask=0x%x, pageshift=%d\n, ncolors=%d, uvmexp.pagesize, uvmexp.pagesize, uvmexp.pagemask, - uvmexp.pageshift); + uvmexp.pageshift, uvmexp.ncolors); (*pr)( %d VM pages: %d active, %d inactive, %d wired, %d free\n, uvmexp.npages, active, inactive, uvmexp.wired, uvmexp.free);
CVS commit: src/usr.sbin/fwctl
Module Name:src Committed By: wiz Date: Tue Jan 4 09:04:24 UTC 2011 Modified Files: src/usr.sbin/fwctl: fwdv.c fwmpegts.c Log Message: Use format string for err(). From Henning Petersen in PR 44326. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/fwctl/fwdv.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/fwctl/fwmpegts.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/fwctl/fwdv.c diff -u src/usr.sbin/fwctl/fwdv.c:1.4 src/usr.sbin/fwctl/fwdv.c:1.5 --- src/usr.sbin/fwctl/fwdv.c:1.4 Tue Aug 24 08:41:24 2010 +++ src/usr.sbin/fwctl/fwdv.c Tue Jan 4 09:04:24 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fwdv.c,v 1.4 2010/08/24 08:41:24 cegger Exp $ */ +/* $NetBSD: fwdv.c,v 1.5 2011/01/04 09:04:24 wiz Exp $ */ /* * Copyright (C) 2003 * Hidetoshi Shimokawa. All rights reserved. @@ -107,7 +107,7 @@ } else { fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0660); if (fd == -1) - err(EX_NOINPUT, filename); + err(EX_NOINPUT, %s, filename); } buf = malloc(RBUFSIZE); pad = malloc(DSIZE*MAXBLOCKS); @@ -269,7 +269,7 @@ fd = open(filename, O_RDONLY); if (fd == -1) - err(EX_NOINPUT, filename); + err(EX_NOINPUT, %s, filename); pbuf = malloc(DSIZE * TNBUF); bzero(wbuf, sizeof(wbuf)); Index: src/usr.sbin/fwctl/fwmpegts.c diff -u src/usr.sbin/fwctl/fwmpegts.c:1.2 src/usr.sbin/fwctl/fwmpegts.c:1.3 --- src/usr.sbin/fwctl/fwmpegts.c:1.2 Tue Aug 24 08:41:24 2010 +++ src/usr.sbin/fwctl/fwmpegts.c Tue Jan 4 09:04:24 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fwmpegts.c,v 1.2 2010/08/24 08:41:24 cegger Exp $ */ +/* $NetBSD: fwmpegts.c,v 1.3 2011/01/04 09:04:24 wiz Exp $ */ /* * Copyright (C) 2005 * Petr Holub, Hidetoshi Shimokawa. All rights reserved. @@ -156,7 +156,7 @@ else { fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0660); if (fd == -1) - err(EX_NOINPUT, filename); + err(EX_NOINPUT, %s, filename); } buf = malloc(RBUFSIZE);
CVS commit: src/sys/arch/evbppc/conf
Module Name:src Committed By: matt Date: Tue Jan 4 09:13:19 UTC 2011 Modified Files: src/sys/arch/evbppc/conf: OPENBLOCKS266 Log Message: Add ukphy (makes MIIVERBOSE happier) To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/arch/evbppc/conf/OPENBLOCKS266 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbppc/conf/OPENBLOCKS266 diff -u src/sys/arch/evbppc/conf/OPENBLOCKS266:1.50 src/sys/arch/evbppc/conf/OPENBLOCKS266:1.51 --- src/sys/arch/evbppc/conf/OPENBLOCKS266:1.50 Tue Nov 23 11:13:57 2010 +++ src/sys/arch/evbppc/conf/OPENBLOCKS266 Tue Jan 4 09:13:19 2011 @@ -1,4 +1,4 @@ -# $NetBSD: OPENBLOCKS266,v 1.50 2010/11/23 11:13:57 hannken Exp $ +# $NetBSD: OPENBLOCKS266,v 1.51 2011/01/04 09:13:19 matt Exp $ # # GENERIC -- everything that's currently supported # @@ -7,7 +7,7 @@ #options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident OPENBLOCKS266-$Revision: 1.50 $ +#ident OPENBLOCKS266-$Revision: 1.51 $ maxusers 32 @@ -181,6 +181,7 @@ # MII/PHY support dmphy* at mii? phy ? # Davicom DM9101/9102 PHYs lxtphy* at mii? phy ? # Level One LXT-970 PHYs +ukphy* at mii? phy ? # unknown PHYs options MIIVERBOSE # verbose PHY autoconfig messages
CVS commit: src/usr.sbin/altq/altqstat
Module Name:src Committed By: wiz Date: Tue Jan 4 09:13:23 UTC 2011 Modified Files: src/usr.sbin/altq/altqstat: qdisc_conf.c Log Message: Close fd in error case. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/altq/altqstat/qdisc_conf.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/altq/altqstat/qdisc_conf.c diff -u src/usr.sbin/altq/altqstat/qdisc_conf.c:1.5 src/usr.sbin/altq/altqstat/qdisc_conf.c:1.6 --- src/usr.sbin/altq/altqstat/qdisc_conf.c:1.5 Fri May 2 19:07:44 2008 +++ src/usr.sbin/altq/altqstat/qdisc_conf.c Tue Jan 4 09:13:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: qdisc_conf.c,v 1.5 2008/05/02 19:07:44 xtraeme Exp $ */ +/* $NetBSD: qdisc_conf.c,v 1.6 2011/01/04 09:13:22 wiz Exp $ */ /* $KAME: qdisc_conf.c,v 1.5 2002/10/26 06:59:54 kjc Exp $ */ /* * Copyright (C) 1999-2000 @@ -91,6 +91,7 @@ } if (ioctl(fd, ALTQGTYPE, qtypereq) 0) { warn(ALTQGQTYPE); + close(fd); return (0); } close(fd);
CVS commit: src/usr.sbin/bootp/common
Module Name:src Committed By: wiz Date: Tue Jan 4 09:16:18 UTC 2011 Modified Files: src/usr.sbin/bootp/common: readfile.c Log Message: Add missing breaks in switch statement. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/bootp/common/readfile.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/bootp/common/readfile.c diff -u src/usr.sbin/bootp/common/readfile.c:1.17 src/usr.sbin/bootp/common/readfile.c:1.18 --- src/usr.sbin/bootp/common/readfile.c:1.17 Wed Apr 15 00:23:29 2009 +++ src/usr.sbin/bootp/common/readfile.c Tue Jan 4 09:16:17 2011 @@ -22,7 +22,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: readfile.c,v 1.17 2009/04/15 00:23:29 lukem Exp $); +__RCSID($NetBSD: readfile.c,v 1.18 2011/01/04 09:16:17 wiz Exp $); #endif @@ -681,8 +681,10 @@ break; case E_BAD_PATHNAME: msg = bad pathname (need leading '/'); + break; case E_BAD_VALUE: msg = bad value; + break; default: msg = unknown error; break;
CVS commit: src/usr.sbin/eeprom
Module Name:src Committed By: wiz Date: Tue Jan 4 09:25:21 UTC 2011 Modified Files: src/usr.sbin/eeprom: ofhandlers.c ophandlers.c prephandlers.c Log Message: Fix fd leak in error case. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/eeprom/ofhandlers.c cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/eeprom/ophandlers.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/eeprom/prephandlers.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/eeprom/ofhandlers.c diff -u src/usr.sbin/eeprom/ofhandlers.c:1.4 src/usr.sbin/eeprom/ofhandlers.c:1.5 --- src/usr.sbin/eeprom/ofhandlers.c:1.4 Mon Apr 28 20:24:15 2008 +++ src/usr.sbin/eeprom/ofhandlers.c Tue Jan 4 09:25:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ofhandlers.c,v 1.4 2008/04/28 20:24:15 martin Exp $ */ +/* $NetBSD: ofhandlers.c,v 1.5 2011/01/04 09:25:21 wiz Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -106,8 +106,10 @@ if (strcmp(ex-ex_keyword, keyword) == 0) break; - if (ioctl(fd, OFIOCGETOPTNODE, (char *)optnode) 0) + if (ioctl(fd, OFIOCGETOPTNODE, (char *)optnode) 0) { + (void)close(fd); BARF(OFIOCGETOPTNODE, strerror(errno)); + } memset(ofio_buf[0], 0, sizeof(ofio_buf)); memset(ofio, 0, sizeof(ofio)); @@ -121,8 +123,10 @@ ofio.of_buf = ofio_buf[0]; ofio.of_buflen = sizeof(ofio_buf); - if (ioctl(fd, OFIOCGET, (char *)ofio) 0) + if (ioctl(fd, OFIOCGET, (char *)ofio) 0) { +(void)close(fd); BARF(OFIOCGET, strerror(errno)); + } if (ofio.of_buflen = 0) { printf(nothing available for %s\n, keyword); @@ -142,8 +146,10 @@ ofio.of_buflen = strlen(arg); } - if (ioctl(fd, OFIOCSET, (char *)ofio) 0) + if (ioctl(fd, OFIOCSET, (char *)ofio) 0) { + (void)close(fd); BARF(invalid keyword, keyword); + } if (verbose) { printf(new: ); @@ -155,8 +161,10 @@ } else { ofio.of_buf = ofio_buf[0]; ofio.of_buflen = sizeof(ofio_buf); - if (ioctl(fd, OFIOCGET, (char *)ofio) 0) + if (ioctl(fd, OFIOCGET, (char *)ofio) 0) { + (void)close(fd); BARF(OFIOCGET, strerror(errno)); + } if (ofio.of_buflen = 0) { (void)snprintf(err_str, sizeof err_str, Index: src/usr.sbin/eeprom/ophandlers.c diff -u src/usr.sbin/eeprom/ophandlers.c:1.10 src/usr.sbin/eeprom/ophandlers.c:1.11 --- src/usr.sbin/eeprom/ophandlers.c:1.10 Mon Apr 28 20:24:15 2008 +++ src/usr.sbin/eeprom/ophandlers.c Tue Jan 4 09:25:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ophandlers.c,v 1.10 2008/04/28 20:24:15 martin Exp $ */ +/* $NetBSD: ophandlers.c,v 1.11 2011/01/04 09:25:21 wiz Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -114,8 +114,10 @@ if (strcmp(ex-ex_keyword, keyword) == 0) break; - if (ioctl(fd, OPIOCGETOPTNODE, (char *)optnode) 0) + if (ioctl(fd, OPIOCGETOPTNODE, (char *)optnode) 0) { + (void)close(fd); BARF(OPIOCGETOPTNODE, strerror(errno)); + } memset(opio_buf[0], 0, sizeof(opio_buf)); memset(opio, 0, sizeof(opio)); @@ -129,8 +131,10 @@ opio.op_buf = opio_buf[0]; opio.op_buflen = sizeof(opio_buf); - if (ioctl(fd, OPIOCGET, (char *)opio) 0) + if (ioctl(fd, OPIOCGET, (char *)opio) 0) { +(void)close(fd); BARF(OPIOCGET, strerror(errno)); + } if (opio.op_buflen = 0) { printf(nothing available for %s\n, keyword); @@ -150,8 +154,10 @@ opio.op_buflen = strlen(arg); } - if (ioctl(fd, OPIOCSET, (char *)opio) 0) + if (ioctl(fd, OPIOCSET, (char *)opio) 0) { + (void)close(fd); BARF(invalid keyword, keyword); + } if (verbose) { printf(new: ); @@ -163,8 +169,10 @@ } else { opio.op_buf = opio_buf[0]; opio.op_buflen = sizeof(opio_buf); - if (ioctl(fd, OPIOCGET, (char *)opio) 0) + if (ioctl(fd, OPIOCGET, (char *)opio) 0) { + (void)close(fd); BARF(OPIOCGET, strerror(errno)); + } if (opio.op_buflen = 0) { (void)snprintf(err_str, sizeof err_str, Index: src/usr.sbin/eeprom/prephandlers.c diff -u src/usr.sbin/eeprom/prephandlers.c:1.2 src/usr.sbin/eeprom/prephandlers.c:1.3 --- src/usr.sbin/eeprom/prephandlers.c:1.2 Mon Apr 28 20:24:15 2008 +++ src/usr.sbin/eeprom/prephandlers.c Tue Jan 4 09:25:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: prephandlers.c,v 1.2 2008/04/28 20:24:15 martin Exp $ */ +/* $NetBSD: prephandlers.c,v 1.3 2011/01/04 09:25:21 wiz Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -111,8 +111,10 @@ nvio.pnv_buf = nvio_buf[0]; nvio.pnv_buflen = sizeof(nvio_buf); - if (ioctl(fd, PNVIOCGET, (char *) nvio) 0) + if (ioctl(fd, PNVIOCGET, (char *) nvio) 0) { +(void)close(fd); BARF(PNVIOCGET, strerror(errno)); + } if (nvio.pnv_buflen = 0) { printf(nothing available for %s\n, keyword); @@ -131,8 +133,10 @@ nvio.pnv_buflen = strlen(arg); } - if (ioctl(fd, PNVIOCSET, (char *) nvio) 0) + if (ioctl(fd, PNVIOCSET, (char *) nvio) 0) { +
CVS commit: src/usr.sbin/extattrctl
Module Name:src Committed By: wiz Date: Tue Jan 4 09:28:44 UTC 2011 Modified Files: src/usr.sbin/extattrctl: extattrctl.c Log Message: Fix fd leaks. Found by cppcheck. While here, fix typo in warning message. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/extattrctl/extattrctl.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/extattrctl/extattrctl.c diff -u src/usr.sbin/extattrctl/extattrctl.c:1.2 src/usr.sbin/extattrctl/extattrctl.c:1.3 --- src/usr.sbin/extattrctl/extattrctl.c:1.2 Wed Apr 15 06:01:01 2009 +++ src/usr.sbin/extattrctl/extattrctl.c Tue Jan 4 09:28:44 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: extattrctl.c,v 1.2 2009/04/15 06:01:01 lukem Exp $ */ +/* $NetBSD: extattrctl.c,v 1.3 2011/01/04 09:28:44 wiz Exp $ */ /*- * Copyright (c) 1999-2002 Robert N. M. Watson @@ -153,7 +153,7 @@ uef.uef_version = rw32(UFS_EXTATTR_VERSION); uef.uef_size = rw32(atoi(argv[0])); if (write(i, uef, sizeof(uef)) != sizeof(uef)) { - warn(unable to write arribute file header); + warn(unable to write attribute file header); error = -1; } else if (fs_path != NULL) { easize = (sizeof(uef) + uef.uef_size) * @@ -170,6 +170,7 @@ easize -= wlen; } } + close(i); if (error == -1) { unlink(argv[1]); return (-1); @@ -197,6 +198,7 @@ i = read(fd, uef, sizeof(uef)); if (i != sizeof(uef)) { warn(unable to read attribute file header); + (void)close(fd); return (-1); } @@ -204,6 +206,7 @@ needswap = 1; if (rw32(uef.uef_magic) != UFS_EXTATTR_MAGIC) { fprintf(stderr, %s: bad magic\n, argv[0]); + (void)close(fd); return (-1); } } @@ -217,6 +220,7 @@ printf(%s: version %u, size %u, byte-order: %s\n, argv[0], rw32(uef.uef_version), rw32(uef.uef_size), bo); + close(fd); return (0); }
CVS commit: src/usr.sbin/grfconfig
Module Name:src Committed By: wiz Date: Tue Jan 4 09:32:31 UTC 2011 Modified Files: src/usr.sbin/grfconfig: grfconfig.c Log Message: Fix fd leaks in error cases. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/grfconfig/grfconfig.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/grfconfig/grfconfig.c diff -u src/usr.sbin/grfconfig/grfconfig.c:1.14 src/usr.sbin/grfconfig/grfconfig.c:1.15 --- src/usr.sbin/grfconfig/grfconfig.c:1.14 Sun Apr 26 19:24:18 2009 +++ src/usr.sbin/grfconfig/grfconfig.c Tue Jan 4 09:32:31 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: grfconfig.c,v 1.14 2009/04/26 19:24:18 mlelstv Exp $ */ +/* $NetBSD: grfconfig.c,v 1.15 2011/01/04 09:32:31 wiz Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #endif /* not lint */ #ifndef lint -__RCSID($NetBSD: grfconfig.c,v 1.14 2009/04/26 19:24:18 mlelstv Exp $); +__RCSID($NetBSD: grfconfig.c,v 1.15 2011/01/04 09:32:31 wiz Exp $); #endif /* not lint */ #include sys/file.h @@ -127,6 +127,7 @@ if (!(fp = fopen(modefile, r))) { printf(grfconfig: Cannot open mode definition file.\n); + (void)close(grffd); return (1); } while (fgets(buf, sizeof(buf), fp)) { @@ -168,6 +169,8 @@ if (i 14) { printf(grfconfig: too few values in mode definition file:\n %s\n, obuf); +(void)fclose(fp); +(void)close(grffd); return (1); } @@ -193,6 +196,8 @@ } else { printf(grfconfig: Illegal mode number: %s\n, cps[0]); + (void)fclose(fp); + (void)close(grffd); return (1); } @@ -210,6 +215,8 @@ (gv-vtotal == 0)) { printf(grfconfig: Illegal value in mode #%d:\n %s\n, gv-mode_num, obuf); +(void)fclose(fp); +(void)close(grffd); return (1); } @@ -230,6 +237,8 @@ grfconfig for more information about the new mode definition file.\n); + (void)fclose(fp); + (void)close(grffd); return (1); } } @@ -255,6 +264,8 @@ printf(grfconfig: Illegal flags in mode #%d: %s are both defined!\n, gv-mode_num, errortext); +(void)fclose(fp); +(void)close(grffd); return (1); } @@ -274,6 +285,8 @@ printf( See the manpage of grfconfig for more information about the new mode definition file.\n); +(void)fclose(fp); +(void)close(grffd); return (1); } @@ -298,6 +311,8 @@ printf( See the manpage of grfconfig for more information about the new mode definition file.\n); +(void)fclose(fp); +(void)close(grffd); return (1); } else if (((gv-vtotal / 2) lowlim) ((gv-vtotal / 2) uplim)) { @@ -317,6 +332,8 @@ printf( See the manpage of grfconfig for more information about the new mode definition file.\n); +(void)fclose(fp); +(void)close(grffd); return (1); }
CVS commit: src/usr.sbin/kvm_mkdb
Module Name:src Committed By: wiz Date: Tue Jan 4 09:36:13 UTC 2011 Modified Files: src/usr.sbin/kvm_mkdb: nlist_aout.c Log Message: Fix fd leaks in error cases. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/kvm_mkdb/nlist_aout.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/kvm_mkdb/nlist_aout.c diff -u src/usr.sbin/kvm_mkdb/nlist_aout.c:1.8 src/usr.sbin/kvm_mkdb/nlist_aout.c:1.9 --- src/usr.sbin/kvm_mkdb/nlist_aout.c:1.8 Thu Aug 7 11:25:23 2003 +++ src/usr.sbin/kvm_mkdb/nlist_aout.c Tue Jan 4 09:36:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nlist_aout.c,v 1.8 2003/08/07 11:25:23 agc Exp $ */ +/* $NetBSD: nlist_aout.c,v 1.9 2011/01/04 09:36:13 wiz Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -66,7 +66,7 @@ #if 0 static char sccsid[] = from: @(#)nlist.c 8.1 (Berkeley) 6/6/93; #else -__RCSID($NetBSD: nlist_aout.c,v 1.8 2003/08/07 11:25:23 agc Exp $); +__RCSID($NetBSD: nlist_aout.c,v 1.9 2011/01/04 09:36:13 wiz Exp $); #endif #endif /* not lint */ @@ -125,12 +125,16 @@ /* Read in exec structure. */ nr = read(fd, ebuf, sizeof(struct exec)); - if (nr != sizeof(struct exec)) + if (nr != sizeof(struct exec)) { + (void)close(fd); return (-1); + } /* Check magic number. */ - if (N_BADMAG(ebuf)) + if (N_BADMAG(ebuf)) { + (void)close(fd); return (-1); + } /* * We've recognized it as an a.out binary. From here
CVS commit: src/usr.sbin/ldpd
Module Name:src Committed By: wiz Date: Tue Jan 4 09:42:21 UTC 2011 Modified Files: src/usr.sbin/ldpd: mpls_interface.c Log Message: Fix memory leak in error case. Found by cppcheck. XXX: so_tag has same problem? To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/ldpd/mpls_interface.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/ldpd/mpls_interface.c diff -u src/usr.sbin/ldpd/mpls_interface.c:1.2 src/usr.sbin/ldpd/mpls_interface.c:1.3 --- src/usr.sbin/ldpd/mpls_interface.c:1.2 Thu Dec 9 00:10:59 2010 +++ src/usr.sbin/ldpd/mpls_interface.c Tue Jan 4 09:42:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: mpls_interface.c,v 1.2 2010/12/09 00:10:59 christos Exp $ */ +/* $NetBSD: mpls_interface.c,v 1.3 2011/01/04 09:42:21 wiz Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -198,6 +198,7 @@ so_ifa = malloc(sizeof(*so_ifa)); if (!so_ifa) { fatalp(Out of memory\n); + free(so_nexthop); return LDP_E_MEMORY; } memcpy(so_ifa, so_oldifa, so_oldifa-sa.sa_len);
CVS commit: src/usr.sbin/lpr/lpc
Module Name:src Committed By: wiz Date: Tue Jan 4 09:43:39 UTC 2011 Modified Files: src/usr.sbin/lpr/lpc: cmds.c Log Message: Fix fd leak in error cases. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/lpr/lpc/cmds.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/lpr/lpc/cmds.c diff -u src/usr.sbin/lpr/lpc/cmds.c:1.22 src/usr.sbin/lpr/lpc/cmds.c:1.23 --- src/usr.sbin/lpr/lpc/cmds.c:1.22 Mon Jul 13 19:05:41 2009 +++ src/usr.sbin/lpr/lpc/cmds.c Tue Jan 4 09:43:39 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cmds.c,v 1.22 2009/07/13 19:05:41 roy Exp $ */ +/* $NetBSD: cmds.c,v 1.23 2011/01/04 09:43:39 wiz Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -36,7 +36,7 @@ #if 0 static char sccsid[] = @(#)cmds.c 8.2 (Berkeley) 4/28/95; #else -__RCSID($NetBSD: cmds.c,v 1.22 2009/07/13 19:05:41 roy Exp $); +__RCSID($NetBSD: cmds.c,v 1.23 2011/01/04 09:43:39 wiz Exp $); #endif #endif /* not lint */ @@ -563,6 +563,8 @@ if (fd 0 || flock(fd, LOCK_EX) 0) { printf(\tcannot create status file\n); seteuid(uid); + if (fd = 0) + (void)close(fd); return; } seteuid(uid);
CVS commit: src/usr.sbin/makefs/cd9660
Module Name:src Committed By: wiz Date: Tue Jan 4 09:48:21 UTC 2011 Modified Files: src/usr.sbin/makefs/cd9660: cd9660_write.c Log Message: Fix fd leaks in error cases. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/makefs/cd9660/cd9660_write.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/makefs/cd9660/cd9660_write.c diff -u src/usr.sbin/makefs/cd9660/cd9660_write.c:1.13 src/usr.sbin/makefs/cd9660/cd9660_write.c:1.14 --- src/usr.sbin/makefs/cd9660/cd9660_write.c:1.13 Fri Oct 22 00:49:15 2010 +++ src/usr.sbin/makefs/cd9660/cd9660_write.c Tue Jan 4 09:48:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_write.c,v 1.13 2010/10/22 00:49:15 christos Exp $ */ +/* $NetBSD: cd9660_write.c,v 1.14 2011/01/04 09:48:21 wiz Exp $ */ /* * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan @@ -37,7 +37,7 @@ #include sys/cdefs.h #if defined(__RCSID) !defined(__lint) -__RCSID($NetBSD: cd9660_write.c,v 1.13 2010/10/22 00:49:15 christos Exp $); +__RCSID($NetBSD: cd9660_write.c,v 1.14 2011/01/04 09:48:21 wiz Exp $); #endif /* !__lint */ static int cd9660_write_volume_descriptors(FILE *); @@ -460,6 +460,7 @@ if (ferror(rf)) { warn(%s: fread, __func__); free(buf); + (void)fclose(rf); return 0; } @@ -467,6 +468,7 @@ if (ferror(fd)) { warn(%s: fwrite, __func__); free(buf); + (void)fclose(rf); return 0; } sector++;
CVS commit: src/sys/rump/librump/rumpvfs
Module Name:src Committed By: pooka Date: Tue Jan 4 09:49:16 UTC 2011 Modified Files: src/sys/rump/librump/rumpvfs: rumpfs.c Log Message: Need to check for VNOVAL when setting attrs. To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/sys/rump/librump/rumpvfs/rumpfs.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/rump/librump/rumpvfs/rumpfs.c diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.80 src/sys/rump/librump/rumpvfs/rumpfs.c:1.81 --- src/sys/rump/librump/rumpvfs/rumpfs.c:1.80 Tue Jan 4 00:09:43 2011 +++ src/sys/rump/librump/rumpvfs/rumpfs.c Tue Jan 4 09:49:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpfs.c,v 1.80 2011/01/04 00:09:43 pooka Exp $ */ +/* $NetBSD: rumpfs.c,v 1.81 2011/01/04 09:49:16 pooka Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: rumpfs.c,v 1.80 2011/01/04 00:09:43 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: rumpfs.c,v 1.81 2011/01/04 09:49:16 pooka Exp $); #include sys/param.h #include sys/atomic.h @@ -780,7 +780,21 @@ struct vattr *vap = ap-a_vap; struct rumpfs_node *rn = vp-v_data; - memcpy(rn-rn_va, vap, sizeof(rn-rn_va)); +#define SETIFVAL(a,t) if (vap-a != (t)VNOVAL) rn-rn_va.a = vap-a + SETIFVAL(va_mode, mode_t); + SETIFVAL(va_uid, uid_t); + SETIFVAL(va_gid, gid_t); + SETIFVAL(va_atime.tv_sec, time_t); + SETIFVAL(va_ctime.tv_sec, time_t); + SETIFVAL(va_mtime.tv_sec, time_t); + SETIFVAL(va_birthtime.tv_sec, time_t); + SETIFVAL(va_atime.tv_nsec, long); + SETIFVAL(va_ctime.tv_nsec, long); + SETIFVAL(va_mtime.tv_nsec, long); + SETIFVAL(va_birthtime.tv_nsec, long); + SETIFVAL(va_flags, u_long); +#undef SETIFVAL + if (vp-v_type == VREG vap-va_size != VSIZENOTSET) uvm_vnp_setsize(vp, vap-va_size); return 0;
CVS commit: src/usr.sbin/pstat
Module Name:src Committed By: wiz Date: Tue Jan 4 09:58:03 UTC 2011 Modified Files: src/usr.sbin/pstat: pstat.c Log Message: Fix memory leak in error case. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/usr.sbin/pstat/pstat.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/pstat/pstat.c diff -u src/usr.sbin/pstat/pstat.c:1.116 src/usr.sbin/pstat/pstat.c:1.117 --- src/usr.sbin/pstat/pstat.c:1.116 Thu Nov 19 02:52:54 2009 +++ src/usr.sbin/pstat/pstat.c Tue Jan 4 09:58:03 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pstat.c,v 1.116 2009/11/19 02:52:54 enami Exp $ */ +/* $NetBSD: pstat.c,v 1.117 2011/01/04 09:58:03 wiz Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = @(#)pstat.c 8.16 (Berkeley) 5/9/95; #else -__RCSID($NetBSD: pstat.c,v 1.116 2009/11/19 02:52:54 enami Exp $); +__RCSID($NetBSD: pstat.c,v 1.117 2011/01/04 09:58:03 wiz Exp $); #endif #endif /* not lint */ @@ -926,6 +926,7 @@ err(1, malloc); if (sysctl(mib, 6, buf + offset, len, NULL, 0) == -1) { warn(sysctl: 2nd KERN_FILE2); + free(buf); return (-1); } *abuf = buf;
CVS commit: src/usr.sbin/pwd_mkdb
Module Name:src Committed By: wiz Date: Tue Jan 4 10:01:51 UTC 2011 Modified Files: src/usr.sbin/pwd_mkdb: pwd_mkdb.c Log Message: Fix fd leaks in error cases. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/pwd_mkdb/pwd_mkdb.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/pwd_mkdb/pwd_mkdb.c diff -u src/usr.sbin/pwd_mkdb/pwd_mkdb.c:1.52 src/usr.sbin/pwd_mkdb/pwd_mkdb.c:1.53 --- src/usr.sbin/pwd_mkdb/pwd_mkdb.c:1.52 Wed Aug 18 08:06:39 2010 +++ src/usr.sbin/pwd_mkdb/pwd_mkdb.c Tue Jan 4 10:01:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pwd_mkdb.c,v 1.52 2010/08/18 08:06:39 christos Exp $ */ +/* $NetBSD: pwd_mkdb.c,v 1.53 2011/01/04 10:01:51 wiz Exp $ */ /* * Copyright (c) 2000, 2009 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ The NetBSD Foundation, Inc. All rights reserved.\ Copyright (c) 1991, 1993, 1994\ The Regents of the University of California. All rights reserved.); -__RCSID($NetBSD: pwd_mkdb.c,v 1.52 2010/08/18 08:06:39 christos Exp $); +__RCSID($NetBSD: pwd_mkdb.c,v 1.53 2011/01/04 10:01:51 wiz Exp $); #endif /* not lint */ #if HAVE_NBTOOL_CONFIG_H @@ -645,19 +645,24 @@ if ((from_fd = open(from, O_RDONLY, 0)) 0) mkpw_error(Cannot open `%s', from); - if ((to_fd = open(to, O_WRONLY | O_CREAT | O_EXCL, mode)) 0) + if ((to_fd = open(to, O_WRONLY | O_CREAT | O_EXCL, mode)) 0) { + (void)close(from_fd); mkpw_error(Cannot open `%s', to); + } while ((rcount = read(from_fd, buf, MAXBSIZE)) 0) { wcount = write(to_fd, buf, (size_t)rcount); - if (rcount != wcount || wcount == -1) + if (rcount != wcount || wcount == -1) { + (void)close(from_fd); + (void)close(to_fd); goto on_error; + } } - if (rcount 0) - goto on_error; close(from_fd); if (close(to_fd)) goto on_error; + if (rcount 0) + goto on_error; return; on_error:
CVS commit: src/usr.sbin/rpc.pcnfsd
Module Name:src Committed By: wiz Date: Tue Jan 4 10:05:55 UTC 2011 Modified Files: src/usr.sbin/rpc.pcnfsd: pcnfsd_print.c Log Message: Use pclose() after popen(). Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/rpc.pcnfsd/pcnfsd_print.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/rpc.pcnfsd/pcnfsd_print.c diff -u src/usr.sbin/rpc.pcnfsd/pcnfsd_print.c:1.10 src/usr.sbin/rpc.pcnfsd/pcnfsd_print.c:1.11 --- src/usr.sbin/rpc.pcnfsd/pcnfsd_print.c:1.10 Fri Aug 7 13:55:22 2009 +++ src/usr.sbin/rpc.pcnfsd/pcnfsd_print.c Tue Jan 4 10:05:55 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pcnfsd_print.c,v 1.10 2009/08/07 13:55:22 wiz Exp $ */ +/* $NetBSD: pcnfsd_print.c,v 1.11 2011/01/04 10:05:55 wiz Exp $ */ /* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_print.c 1.7 92/01/24 19:58:58 SMI */ /* @@ -573,7 +573,7 @@ last = curr; } - (void) fclose(p); + (void) pclose(p); /* ** Now add on the virtual printers, if any
CVS commit: src/usr.sbin/sesd/srcs
Module Name:src Committed By: wiz Date: Tue Jan 4 10:10:39 UTC 2011 Modified Files: src/usr.sbin/sesd/srcs: sesd.c Log Message: Fix fd leak in error case. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/sesd/srcs/sesd.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/sesd/srcs/sesd.c diff -u src/usr.sbin/sesd/srcs/sesd.c:1.5 src/usr.sbin/sesd/srcs/sesd.c:1.6 --- src/usr.sbin/sesd/srcs/sesd.c:1.5 Sat Apr 18 13:57:44 2009 +++ src/usr.sbin/sesd/srcs/sesd.c Tue Jan 4 10:10:39 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sesd.c,v 1.5 2009/04/18 13:57:44 lukem Exp $ */ +/* $NetBSD: sesd.c,v 1.6 2011/01/04 10:10:39 wiz Exp $ */ /* $FreeBSD: $ */ /* $OpenBSD: $ */ /* @@ -102,6 +102,7 @@ if (ioctl(fd, SESIOC_INIT, NULL) 0) { fprintf(stderr, %s: SESIOC_INIT fails- %s\n, v[dev], strerror(errno)); + (void) close(fd); return (1); } (void) close(fd);
CVS commit: src/usr.sbin/sup/source
Module Name:src Committed By: wiz Date: Tue Jan 4 10:14:25 UTC 2011 Modified Files: src/usr.sbin/sup/source: scan.c Log Message: Fix fd leaks in error cases. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/sup/source/scan.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/sup/source/scan.c diff -u src/usr.sbin/sup/source/scan.c:1.27 src/usr.sbin/sup/source/scan.c:1.28 --- src/usr.sbin/sup/source/scan.c:1.27 Sat Oct 17 20:46:03 2009 +++ src/usr.sbin/sup/source/scan.c Tue Jan 4 10:14:25 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: scan.c,v 1.27 2009/10/17 20:46:03 christos Exp $ */ +/* $NetBSD: scan.c,v 1.28 2011/01/04 10:14:25 wiz Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -968,9 +968,9 @@ if (scanF == NULL) goto out; if (fprintf(scanF, V%d\n, SCANVERSION) 0) - goto out; + goto closeout; if (Tprocess(listT, recordone, scanF) != SCMOK) - goto out; + goto closeout; if (fclose(scanF) != 0) goto out; if (rename(tname, fname) 0) { @@ -983,6 +983,8 @@ tbuf[1].tv_usec = 0; (void) utimes(fname, tbuf); return; +closeout: + (void) fclose(scanF); out: goaway(Can't write scan file temp %s for %s, tname, collname); }
CVS commit: src/usr.sbin/ldpd
Module Name:src Committed By: kefren Date: Tue Jan 4 10:18:42 UTC 2011 Modified Files: src/usr.sbin/ldpd: mpls_interface.c Log Message: Fix more memory leaks in case malloc fails To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/ldpd/mpls_interface.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/ldpd/mpls_interface.c diff -u src/usr.sbin/ldpd/mpls_interface.c:1.3 src/usr.sbin/ldpd/mpls_interface.c:1.4 --- src/usr.sbin/ldpd/mpls_interface.c:1.3 Tue Jan 4 09:42:21 2011 +++ src/usr.sbin/ldpd/mpls_interface.c Tue Jan 4 10:18:42 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: mpls_interface.c,v 1.3 2011/01/04 09:42:21 wiz Exp $ */ +/* $NetBSD: mpls_interface.c,v 1.4 2011/01/04 10:18:42 kefren Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -83,10 +83,12 @@ * let's loop until we have it.. */ - so_dest = make_inet_union(inet_ntoa(*addr)); - if (len != 32) - so_pref = from_cidr_to_union(len); - + if ((so_dest = make_inet_union(inet_ntoa(*addr))) == NULL) + return LDP_E_MEMORY; + if (len != 32 (so_pref = from_cidr_to_union(len)) == NULL) { + free(so_dest); + return LDP_E_MEMORY; + } do { if (kount == rlookup) { debugp(No route for this prefix\n); @@ -166,16 +168,25 @@ so_dest = make_mpls_union(lab-binding); so_nexthop = malloc(sizeof(*so_nexthop)); if (!so_nexthop) { + free(so_dest); fatalp(Out of memory\n); return LDP_E_MEMORY; } memcpy(so_nexthop, so_gate, so_gate-sa.sa_len); - so_tag = make_mpls_union(label); + if ((so_tag = make_mpls_union(label)) == NULL) { + free(so_dest); + free(so_nexthop); + fatalp(Out of memory\n); + return LDP_E_MEMORY; + } if (add_route(so_dest, NULL, so_nexthop, NULL, so_tag, FREESO, RTM_ADD) != LDP_E_OK) return LDP_E_ROUTE_ERROR; /* Now, let's add tag to IPv4 route and point it to mpls interface */ - so_dest = make_inet_union(inet_ntoa(*addr)); + if ((so_dest = make_inet_union(inet_ntoa(*addr))) == NULL) { + fatalp(Out of memory\n); + return LDP_E_MEMORY; + } /* if prefixlen == 32 check if it's inserted as host * and treat it as host. It may also be set as /32 prefix @@ -183,12 +194,18 @@ */ if ((len == 32) (rgp-m_rtm.rtm_flags RTF_HOST)) so_pref = NULL; - else - so_pref = from_cidr_to_union(len); + else if ((so_pref = from_cidr_to_union(len)) == NULL) { + free(so_dest); + fatalp(Out of memory\n); + return LDP_E_MEMORY; + } /* Add tag to route */ so_nexthop = malloc(sizeof(*so_nexthop)); if (!so_nexthop) { + free(so_dest); + if (so_pref != NULL) + free(so_pref); fatalp(Out of memory\n); return LDP_E_MEMORY; } @@ -196,9 +213,13 @@ so_tag = make_mpls_union(label); if (so_oldifa != NULL) { so_ifa = malloc(sizeof(*so_ifa)); - if (!so_ifa) { - fatalp(Out of memory\n); + if (so_ifa == NULL) { + free(so_dest); + if (so_pref != NULL) +free(so_pref); + free(so_tag); free(so_nexthop); + fatalp(Out of memory\n); return LDP_E_MEMORY; } memcpy(so_ifa, so_oldifa, so_oldifa-sa.sa_len);
CVS commit: src/usr.sbin/sup/source
Module Name:src Committed By: wiz Date: Tue Jan 4 10:23:40 UTC 2011 Modified Files: src/usr.sbin/sup/source: scan.c Log Message: unifdef -U RCSSTAT This code was added in 1.2 by brezak with changes for the commit message: Change sys/dir.h to dirent.h and looks like it never worked. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/sup/source/scan.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/sup/source/scan.c diff -u src/usr.sbin/sup/source/scan.c:1.28 src/usr.sbin/sup/source/scan.c:1.29 --- src/usr.sbin/sup/source/scan.c:1.28 Tue Jan 4 10:14:25 2011 +++ src/usr.sbin/sup/source/scan.c Tue Jan 4 10:23:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: scan.c,v 1.28 2011/01/04 10:14:25 wiz Exp $ */ +/* $NetBSD: scan.c,v 1.29 2011/01/04 10:23:40 wiz Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -166,11 +166,6 @@ extern int trace; /* trace directories */ extern int newonly; /* new files only */ -#ifdef RCSSTAT -extern char *rcs_branch; -extern int candorcs; -#endif - /* *** STATIC R O U T I N E S*** */ @@ -644,27 +639,6 @@ } if (access(name, R_OK) 0) return; -#ifdef RCSSTAT - if (candorcs) { - char rcs_release[STRINGLENGTH]; - int status; - if (rcs_branch != NULL) -#ifdef CVS - sprintf(rcs_release, -r %s, rcs_branch); -#else - sprintf(rcs_release, -r%s, rcs_branch); -#endif - else - rcs_release[0] = '\0'; -#ifdef CVS - sprintf(sys_com, cvs -d %s -r -l -Q co -p %s %s %s\n, cvs_root, rcs_release, name, rcs_file); -#else - status = runp(rcsstat, rcsstat, -q, rcs_release, name, 0); -#endif - if (status != 0) - return; - } -#endif listname(fullname, statbuf); }
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: wiz Date: Tue Jan 4 10:26:56 UTC 2011 Modified Files: src/usr.sbin/traceroute: as.c Log Message: Fix possible NULL pointer dereference in #ifdef AS_DEBUG_FILE. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/traceroute/as.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/traceroute/as.c diff -u src/usr.sbin/traceroute/as.c:1.2 src/usr.sbin/traceroute/as.c:1.3 --- src/usr.sbin/traceroute/as.c:1.2 Mon Apr 28 20:24:17 2008 +++ src/usr.sbin/traceroute/as.c Tue Jan 4 10:26:56 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: as.c,v 1.2 2008/04/28 20:24:17 martin Exp $ */ +/* $NetBSD: as.c,v 1.3 2011/01/04 10:26:56 wiz Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -119,10 +119,12 @@ asn-as_f = f; #ifdef AS_DEBUG_FILE - asn-as_debug = fopen(AS_DEBUG_FILE, w); - if (asn-as_debug) { - (void)fprintf(asn-as_debug, !!\n); - (void)fflush(asn-as_debug); + if (asn) { + asn-as_debug = fopen(AS_DEBUG_FILE, w); + if (asn-as_debug) { + (void)fprintf(asn-as_debug, !!\n); + (void)fflush(asn-as_debug); + } } #endif /* AS_DEBUG_FILE */
CVS commit: src/usr.sbin/user
Module Name:src Committed By: wiz Date: Tue Jan 4 10:30:21 UTC 2011 Modified Files: src/usr.sbin/user: user.c Log Message: Close masterfd after reading from it. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/usr.sbin/user/user.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/user/user.c diff -u src/usr.sbin/user/user.c:1.125 src/usr.sbin/user/user.c:1.126 --- src/usr.sbin/user/user.c:1.125 Thu Dec 31 19:59:31 2009 +++ src/usr.sbin/user/user.c Tue Jan 4 10:30:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.125 2009/12/31 19:59:31 mlelstv Exp $ */ +/* $NetBSD: user.c,v 1.126 2011/01/04 10:30:21 wiz Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -33,7 +33,7 @@ #ifndef lint __COPYRIGHT(@(#) Copyright (c) 1999\ The NetBSD Foundation, Inc. All rights reserved.); -__RCSID($NetBSD: user.c,v 1.125 2009/12/31 19:59:31 mlelstv Exp $); +__RCSID($NetBSD: user.c,v 1.126 2011/01/04 10:30:21 wiz Exp $); #endif #include sys/types.h @@ -1115,6 +1115,7 @@ short write to /etc/ptmp, login_name); } } + (void)close(masterfd); /* if no uid was specified, get next one in [low_uid..high_uid] range */ sync_uid_gid = (strcmp(up-u_primgrp, =uid) == 0); if (up-u_uid == -1) {
CVS commit: src/usr.sbin/videomode
Module Name:src Committed By: wiz Date: Tue Jan 4 10:32:34 UTC 2011 Modified Files: src/usr.sbin/videomode: videomode.c Log Message: Fix fd leaks. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/videomode/videomode.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/videomode/videomode.c diff -u src/usr.sbin/videomode/videomode.c:1.7 src/usr.sbin/videomode/videomode.c:1.8 --- src/usr.sbin/videomode/videomode.c:1.7 Sat Jan 17 22:01:32 2009 +++ src/usr.sbin/videomode/videomode.c Tue Jan 4 10:32:34 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: videomode.c,v 1.7 2009/01/17 22:01:32 he Exp $ */ +/* $NetBSD: videomode.c,v 1.8 2011/01/04 10:32:34 wiz Exp $ */ /* * Copyright (c) 1995 Christian E. Hopps @@ -132,14 +132,17 @@ dump_vm(vm); (void)printf(\n); } - if (m = 0) + if (m = 0) { + (void)close(grffd); return; + } for (m = 1; m = num_vm; m++) { vm.mode_num = m; if (ioctl(grffd, GRFGETVMODE, vm) == -1) break; dump_vm(vm); } + (void)close(grffd); } void @@ -150,6 +153,7 @@ grffd = get_grf(); (void)ioctl(grffd, GRFSETVMODE, m); + (void)close(grffd); } void
CVS commit: src/tests/lib/libc
Module Name:src Committed By: pgoyette Date: Tue Jan 4 12:44:48 UTC 2011 Modified Files: src/tests/lib/libc: t_protoent.sh Log Message: Now that PR/44311 is fixed we can remove the expected-failure from this test. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/t_protoent.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/t_protoent.sh diff -u src/tests/lib/libc/t_protoent.sh:1.1 src/tests/lib/libc/t_protoent.sh:1.2 --- src/tests/lib/libc/t_protoent.sh:1.1 Sun Jan 2 22:03:25 2011 +++ src/tests/lib/libc/t_protoent.sh Tue Jan 4 12:44:48 2011 @@ -1,4 +1,4 @@ -# $NetBSD: t_protoent.sh,v 1.1 2011/01/02 22:03:25 pgoyette Exp $ +# $NetBSD: t_protoent.sh,v 1.2 2011/01/04 12:44:48 pgoyette Exp $ # # Copyright (c) 2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -82,7 +82,6 @@ # run test program $(atf_get_srcdir)/h_protoent | sed 's/ *$//' | sort out - atf_expect_fail PR misc/44311: protocol entry for manet is wrong diff -u exp out || \ atf_fail Observed output does not match reference output }
CVS commit: src/regress/lib/libc
Module Name:src Committed By: pgoyette Date: Tue Jan 4 14:22:06 UTC 2011 Modified Files: src/regress/lib/libc: Makefile Removed Files: src/regress/lib/libc/atexit: Makefile atexit.c expected Log Message: The atexit test has been atf-ified. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/regress/lib/libc/Makefile cvs rdiff -u -r1.1 -r0 src/regress/lib/libc/atexit/Makefile \ src/regress/lib/libc/atexit/expected cvs rdiff -u -r1.2 -r0 src/regress/lib/libc/atexit/atexit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/regress/lib/libc/Makefile diff -u src/regress/lib/libc/Makefile:1.71 src/regress/lib/libc/Makefile:1.72 --- src/regress/lib/libc/Makefile:1.71 Sun Jan 2 22:10:23 2011 +++ src/regress/lib/libc/Makefile Tue Jan 4 14:22:06 2011 @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.71 2011/01/02 22:10:23 pgoyette Exp $ +# $NetBSD: Makefile,v 1.72 2011/01/04 14:22:06 pgoyette Exp $ -SUBDIR+= atexit citrus db divrem getaddrinfo int_fmtio locale \ +SUBDIR+= citrus db divrem getaddrinfo int_fmtio locale \ nsdispatch regex rpc sys time .include bsd.own.mk
CVS commit: src/sys/rump
Module Name:src Committed By: pooka Date: Tue Jan 4 16:23:36 UTC 2011 Modified Files: src/sys/rump/include/machine: cpu.h src/sys/rump/librump/rumpkern: Makefile.rumpkern rump.c rumpcpu_generic.c Log Message: Add SMP support for all architectures. tested on sparc64 by martin To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/rump/include/machine/cpu.h cvs rdiff -u -r1.104 -r1.105 src/sys/rump/librump/rumpkern/Makefile.rumpkern cvs rdiff -u -r1.214 -r1.215 src/sys/rump/librump/rumpkern/rump.c cvs rdiff -u -r1.2 -r1.3 src/sys/rump/librump/rumpkern/rumpcpu_generic.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/rump/include/machine/cpu.h diff -u src/sys/rump/include/machine/cpu.h:1.13 src/sys/rump/include/machine/cpu.h:1.14 --- src/sys/rump/include/machine/cpu.h:1.13 Thu Dec 2 21:20:39 2010 +++ src/sys/rump/include/machine/cpu.h Tue Jan 4 16:23:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.13 2010/12/02 21:20:39 pooka Exp $ */ +/* $NetBSD: cpu.h,v 1.14 2011/01/04 16:23:35 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -40,6 +40,8 @@ cpuid_t ci_cpuid; struct lwp *ci_curlwp; + struct cpu_info *ci_next; + /* * XXX: horrible workaround for vax lock.h. * I eventually want to nuke rump include/machine, so don't waste @@ -77,7 +79,14 @@ #define curlwp rumpuser_get_curlwp() #define curcpu() (curlwp-l_cpu) -#define cpu_number() 0 /* XXX: not good enuf */ +#define cpu_number() (cpu_index(curcpu)) + +extern struct cpu_info *rumpcpu_info_list; +#define CPU_INFO_ITERATOR int +#define CPU_INFO_FOREACH(_cii_, _ci_) _cii_ = 0, _ci_ = rumpcpu_info_list; \ + _ci_ != NULL; _ci_ = _ci_-ci_next +#define CPU_IS_PRIMARY(_ci_) (_ci_-ci_index == 0) + #endif /* !_LOCORE */ Index: src/sys/rump/librump/rumpkern/Makefile.rumpkern diff -u src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.104 src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.105 --- src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.104 Fri Dec 17 00:53:16 2010 +++ src/sys/rump/librump/rumpkern/Makefile.rumpkern Tue Jan 4 16:23:36 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.rumpkern,v 1.104 2010/12/17 00:53:16 joerg Exp $ +# $NetBSD: Makefile.rumpkern,v 1.105 2011/01/04 16:23:36 pooka Exp $ # .include ${RUMPTOP}/Makefile.rump @@ -25,12 +25,6 @@ SRCS+= locks.c #SRCS+= locks_up.c -# Does the arch support multiple processors? -.if ${MACHINE_ARCH} == i386 || ${MACHINE_ARCH} == x86_64 -RUMP_SMP= # defined -CPPFLAGS.rump.c+= -DRUMP_SMP -.endif - MKREPRO?=no .if ${MKREPRO} == yes @@ -180,20 +174,14 @@ # Some architectures require a little special massage with atomic # compare-and-swap. This is because the kernel version is using -# instructions or routines unavailable to us in userspace. We -# use a very simple CAS routine which (correctly) assumes non-SMP -# and no preemption. If some of these archs later develop MP -# support, switch them to use atomic_cas_generic.c +# instructions or routines unavailable to us in userspace. # .if ${MACHINE_CPU} == arm || ${MACHINE_CPU} == hppa \ || ${MACHINE_CPU} == mips || ${MACHINE_CPU} == sh3 \ || ${MACHINE_CPU} == vax || ${MACHINE_ARCH} == m68000 CPPFLAGS+= -I${RUMPTOP}/../../common/lib/libc/atomic -.ifdef RUMP_SMP SRCS+= atomic_cas_generic.c -.else -SRCS+= rump_atomic_cas_up.c -.endif +#SRCS+= rump_atomic_cas_up.c .endif .include bsd.lib.mk Index: src/sys/rump/librump/rumpkern/rump.c diff -u src/sys/rump/librump/rumpkern/rump.c:1.214 src/sys/rump/librump/rumpkern/rump.c:1.215 --- src/sys/rump/librump/rumpkern/rump.c:1.214 Sun Jan 2 12:52:25 2011 +++ src/sys/rump/librump/rumpkern/rump.c Tue Jan 4 16:23:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.214 2011/01/02 12:52:25 pooka Exp $ */ +/* $NetBSD: rump.c,v 1.215 2011/01/04 16:23:36 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: rump.c,v 1.214 2011/01/02 12:52:25 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: rump.c,v 1.215 2011/01/04 16:23:36 pooka Exp $); #include sys/systm.h #define ELFSIZE ARCH_ELFSIZE @@ -255,8 +255,6 @@ if (rumpuser_getenv(RUMP_NCPU, buf, sizeof(buf), error) == 0) error = 0; - /* non-x86 is missing CPU_INFO_FOREACH() support */ -#ifdef RUMP_SMP if (error == 0) { numcpu = strtoll(buf, NULL, 10); if (numcpu 1) @@ -264,11 +262,6 @@ } else { numcpu = rumpuser_getnhostcpu(); } -#else - if (error == 0) - printf(NCPU limited to 1 on this machine architecture\n); - numcpu = 1; -#endif rump_cpus_bootstrap(numcpu); rumpuser_gettime(sec, nsec, error); Index: src/sys/rump/librump/rumpkern/rumpcpu_generic.c diff -u src/sys/rump/librump/rumpkern/rumpcpu_generic.c:1.2 src/sys/rump/librump/rumpkern/rumpcpu_generic.c:1.3 ---
CVS commit: src/tests/fs/tmpfs
Module Name:src Committed By: pooka Date: Tue Jan 4 16:25:20 UTC 2011 Modified Files: src/tests/fs/tmpfs: t_renamerace.c Log Message: Remove arch check now that rump smp is available on all host archs. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/fs/tmpfs/t_renamerace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/tmpfs/t_renamerace.c diff -u src/tests/fs/tmpfs/t_renamerace.c:1.10 src/tests/fs/tmpfs/t_renamerace.c:1.11 --- src/tests/fs/tmpfs/t_renamerace.c:1.10 Sun Jan 2 12:58:17 2011 +++ src/tests/fs/tmpfs/t_renamerace.c Tue Jan 4 16:25:20 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_renamerace.c,v 1.10 2011/01/02 12:58:17 pooka Exp $ */ +/* $NetBSD: t_renamerace.c,v 1.11 2011/01/04 16:25:20 pooka Exp $ */ /* * Modified for rump and atf from a program supplied @@ -80,16 +80,6 @@ pthread_t pt[2]; /* - * Check that we are running on an SMP-capable arch. It should - * be a rump capability, but after the CPU_INFO_FOREACH is - * fixed, it will be every arch (for rump), so don't bother. - */ - if (uname(un) == -1) - atf_tc_fail_errno(uname); - if (strcmp(un.machine, i386) != 0 strcmp(un.machine, amd64) != 0) - atf_tc_skip(i386 or amd64 required (have %s), un.machine); - - /* * Force SMP regardless of how many host CPUs there are. * Deadlock is highly unlikely to trigger otherwise. */
CVS commit: src/sys/arch/i386/stand/cdboot
Module Name:src Committed By: jakllsch Date: Tue Jan 4 16:53:05 UTC 2011 Modified Files: src/sys/arch/i386/stand/cdboot: cdboot.S Log Message: Relocate buffers to not coincide with new location of executable text. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/cdboot/cdboot.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/cdboot/cdboot.S diff -u src/sys/arch/i386/stand/cdboot/cdboot.S:1.11 src/sys/arch/i386/stand/cdboot/cdboot.S:1.12 --- src/sys/arch/i386/stand/cdboot/cdboot.S:1.11 Sat Oct 24 12:57:17 2009 +++ src/sys/arch/i386/stand/cdboot/cdboot.S Tue Jan 4 16:53:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cdboot.S,v 1.11 2009/10/24 12:57:17 dsl Exp $ */ +/* $NetBSD: cdboot.S,v 1.12 2011/01/04 16:53:05 jakllsch Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -41,8 +41,8 @@ #define BOOT_ADDR 0x7c00 #define BLOCK_SIZE 2048 /* Default for ISO 9660 */ #define VD_LBA 16 /* LBA of Volume Descriptor (VD) */ -#define PVD_ADDR 0x1000 /* Where Primary VD is loaded */ -#define ROOTDIR_ADDR 0x1800 /* Where Root Directory is loaded */ +#define PVD_ADDR end /* Where Primary VD is loaded */ +#define ROOTDIR_ADDR end+BLOCK_SIZE /* Where Root Directory is loaded */ #define LOADER_ADDR SECONDARY_LOAD_ADDRESS #ifdef BOOT_FROM_FAT
CVS commit: src/sys/rump
Module Name:src Committed By: pooka Date: Tue Jan 4 17:00:19 UTC 2011 Modified Files: src/sys/rump/include/rump: rump_syscalls_compat.h src/sys/rump/librump/rumpvfs: compat.c Log Message: Add NetBSD 5 compat wrapping for *utimes() To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/rump/include/rump/rump_syscalls_compat.h cvs rdiff -u -r1.7 -r1.8 src/sys/rump/librump/rumpvfs/compat.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/rump/include/rump/rump_syscalls_compat.h diff -u src/sys/rump/include/rump/rump_syscalls_compat.h:1.4 src/sys/rump/include/rump/rump_syscalls_compat.h:1.5 --- src/sys/rump/include/rump/rump_syscalls_compat.h:1.4 Mon Aug 30 10:08:39 2010 +++ src/sys/rump/include/rump/rump_syscalls_compat.h Tue Jan 4 17:00:19 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_syscalls_compat.h,v 1.4 2010/08/30 10:08:39 pooka Exp $ */ +/* $NetBSD: rump_syscalls_compat.h,v 1.5 2011/01/04 17:00:19 pooka Exp $ */ /*- * Copyright (c) 2010 Antti Kantee. All Rights Reserved. @@ -45,6 +45,9 @@ #define rump_sys_fstat(a,b) rump_sys_nb5_fstat(a,b) #define rump_sys_pollts(a,b,c,d) rump_sys_nb5_pollts(a,b,c,d) #define rump_sys_select(a,b,c,d,e) rump_sys_nb5_select(a,b,c,d,e) +#define rump_sys_utimes(a,b) rump_sys_nb5_utimes(a,b) +#define rump_sys_lutimes(a,b) rump_sys_nb5_lutimes(a,b) +#define rump_sys_futimes(a,b) rump_sys_nb5_futimes(a,b) #endif /* __NetBSD_Prereq */ #endif /* __NetBSD__ */ #endif /* _KERNEL */ @@ -62,6 +65,9 @@ int rump_sys_nb5_pollts(struct pollfd *, size_t, const struct timespec *, const void *); int rump_sys_nb5_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +int rump_sys_nb5_utimes(const char *, const struct timeval *); +int rump_sys_nb5_lutimes(const char *, const struct timeval *); +int rump_sys_nb5_futimes(int, const struct timeval *); #ifdef _END_DECLS _END_DECLS Index: src/sys/rump/librump/rumpvfs/compat.c diff -u src/sys/rump/librump/rumpvfs/compat.c:1.7 src/sys/rump/librump/rumpvfs/compat.c:1.8 --- src/sys/rump/librump/rumpvfs/compat.c:1.7 Mon Aug 30 10:08:39 2010 +++ src/sys/rump/librump/rumpvfs/compat.c Tue Jan 4 17:00:19 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.7 2010/08/30 10:08:39 pooka Exp $ */ +/* $NetBSD: compat.c,v 1.8 2011/01/04 17:00:19 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: compat.c,v 1.7 2010/08/30 10:08:39 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: compat.c,v 1.8 2011/01/04 17:00:19 pooka Exp $); #include sys/param.h #include sys/kmem.h @@ -140,6 +140,66 @@ return retval; } +int +rump_sys_nb5_utimes(const char *path, const struct timeval times[2]) +{ + struct compat_50_sys_utimes_args args; + register_t retval = 0; + int error = 0; + + SPARG(args, path) = path; + SPARG(args, tptr) = (const struct timeval50 *)times; + + rump_schedule(); + error = compat_50_sys_utimes(curlwp, args, retval); + if (error) { + retval = -1; + rumpuser_seterrno(error); + } + rump_unschedule(); + return retval; +} + +int +rump_sys_nb5_lutimes(const char *path, const struct timeval times[2]) +{ + struct compat_50_sys_lutimes_args args; + register_t retval = 0; + int error = 0; + + SPARG(args, path) = path; + SPARG(args, tptr) = (const struct timeval50 *)times; + + rump_schedule(); + error = compat_50_sys_lutimes(curlwp, args, retval); + if (error) { + retval = -1; + rumpuser_seterrno(error); + } + rump_unschedule(); + return retval; +} + +int +rump_sys_nb5_futimes(int fd, const struct timeval times[2]) +{ + struct compat_50_sys_futimes_args args; + register_t retval = 0; + int error = 0; + + SPARG(args, fd) = fd; + SPARG(args, tptr) = (const struct timeval50 *)times; + + rump_schedule(); + error = compat_50_sys_futimes(curlwp, args, retval); + if (error) { + retval = -1; + rumpuser_seterrno(error); + } + rump_unschedule(); + return retval; +} + /* * XXX: types. But I don't want to start playing compat games in * the userspace namespace too
CVS commit: src/lib/libc/string
Module Name:src Committed By: martin Date: Tue Jan 4 17:14:07 UTC 2011 Modified Files: src/lib/libc/string: swab.c Log Message: Special-case the (unlikely in practice) call with len = 2 - previously the code would not have swapped anything. Problem pointed out by sparc64 automatic test run. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/lib/libc/string/swab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/string/swab.c diff -u src/lib/libc/string/swab.c:1.17 src/lib/libc/string/swab.c:1.18 --- src/lib/libc/string/swab.c:1.17 Sun Apr 18 11:39:39 2010 +++ src/lib/libc/string/swab.c Tue Jan 4 17:14:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: swab.c,v 1.17 2010/04/18 11:39:39 apb Exp $ */ +/* $NetBSD: swab.c,v 1.18 2011/01/04 17:14:07 martin Exp $ */ /* * Copyright (c) 1988, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = @(#)swab.c 8.1 (Berkeley) 6/4/93; #else -__RCSID($NetBSD: swab.c,v 1.17 2010/04/18 11:39:39 apb Exp $); +__RCSID($NetBSD: swab.c,v 1.18 2011/01/04 17:14:07 martin Exp $); #endif #endif /* LIBC_SCCS and not lint */ @@ -61,6 +61,12 @@ fp = (const char *)from; tp = (char *)to; #define STEP temp = *fp++,*tp++ = *fp++,*tp++ = temp + + if (__predict_false(len == 1)) { + STEP; + return; + } + /* round to multiple of 8 */ while ((--len % 8) != 0) STEP;
CVS commit: src/sbin/dkctl
Module Name:src Committed By: spz Date: Tue Jan 4 21:42:10 UTC 2011 Modified Files: src/sbin/dkctl: dkctl.8 Log Message: add notes what 'device' is and also rub in that addwedge doesn't create stuff on disk a bit more. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sbin/dkctl/dkctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/dkctl/dkctl.8 diff -u src/sbin/dkctl/dkctl.8:1.21 src/sbin/dkctl/dkctl.8:1.22 --- src/sbin/dkctl/dkctl.8:1.21 Tue May 18 23:33:03 2010 +++ src/sbin/dkctl/dkctl.8 Tue Jan 4 21:42:10 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: dkctl.8,v 1.21 2010/05/18 23:33:03 wiz Exp $ +.\ $NetBSD: dkctl.8,v 1.22 2011/01/04 21:42:10 spz Exp $ .\ .\ Copyright 2002 Wasabi Systems, Inc. .\ All rights reserved. @@ -52,6 +52,8 @@ in various ways. It is used by specifying a disk to manipulate, the command to perform, and any arguments the command may require. +.Ar device +is the disk (wdN, sdN, ...) containing the wedges unless noted otherwise. If .Nm is called without any command, it displays strategy, cache, and all of @@ -120,6 +122,11 @@ and spanning .Ar blkcnt blocks. +You need to create the partition first with +.Xr fdisk 8 +or +.Xr gpt 8 , +dkctl will just name it. The wedge will have the volume name .Ar name and the partition type @@ -153,6 +160,8 @@ from the specified disk. .It Ic getwedgeinfo Display information about the specified disk wedge. +.Ar device +in this case is the wedge name. .It Ic listwedges List all of the wedges configured on the specified disk. .It Ic strategy Op Ar name
CVS commit: src/sbin/ccdconfig
Module Name:src Committed By: wiz Date: Tue Jan 4 23:31:30 UTC 2011 Modified Files: src/sbin/ccdconfig: ccdconfig.c Log Message: Fix file descriptor leak. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sbin/ccdconfig/ccdconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/ccdconfig/ccdconfig.c diff -u src/sbin/ccdconfig/ccdconfig.c:1.49 src/sbin/ccdconfig/ccdconfig.c:1.50 --- src/sbin/ccdconfig/ccdconfig.c:1.49 Mon Mar 16 12:52:07 2009 +++ src/sbin/ccdconfig/ccdconfig.c Tue Jan 4 23:31:29 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ccdconfig.c,v 1.49 2009/03/16 12:52:07 lukem Exp $ */ +/* $NetBSD: ccdconfig.c,v 1.50 2011/01/04 23:31:29 wiz Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #ifndef lint __COPYRIGHT(@(#) Copyright (c) 1996, 1997\ The NetBSD Foundation, Inc. All rights reserved.); -__RCSID($NetBSD: ccdconfig.c,v 1.49 2009/03/16 12:52:07 lukem Exp $); +__RCSID($NetBSD: ccdconfig.c,v 1.50 2011/01/04 23:31:29 wiz Exp $); #endif #include sys/param.h @@ -471,9 +471,11 @@ cp = unknown; } warn(ioctl (%s): %s, cp, path); + (void)close(fd); return (1); } + (void)close(fd); return (0); }
CVS commit: src/sbin/ldconfig
Module Name:src Committed By: wiz Date: Tue Jan 4 23:34:06 UTC 2011 Modified Files: src/sbin/ldconfig: ldconfig.c Log Message: Fix file descriptor leak. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sbin/ldconfig/ldconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/ldconfig/ldconfig.c diff -u src/sbin/ldconfig/ldconfig.c:1.47 src/sbin/ldconfig/ldconfig.c:1.48 --- src/sbin/ldconfig/ldconfig.c:1.47 Thu May 13 17:52:12 2010 +++ src/sbin/ldconfig/ldconfig.c Tue Jan 4 23:34:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ldconfig.c,v 1.47 2010/05/13 17:52:12 tnozaki Exp $ */ +/* $NetBSD: ldconfig.c,v 1.48 2011/01/04 23:34:06 wiz Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: ldconfig.c,v 1.47 2010/05/13 17:52:12 tnozaki Exp $); +__RCSID($NetBSD: ldconfig.c,v 1.48 2011/01/04 23:34:06 wiz Exp $); #endif @@ -467,20 +467,20 @@ if (write(fd, hdr, sizeof(struct hints_header)) != sizeof(struct hints_header)) { warn(%s, _PATH_LD_HINTS); - goto out; + goto fdout; } if ((size_t)write(fd, blist, hdr.hh_nbucket * sizeof(struct hints_bucket)) != hdr.hh_nbucket * sizeof(struct hints_bucket)) { warn(%s, _PATH_LD_HINTS); - goto out; + goto fdout; } if (write(fd, strtab, strtab_sz) != strtab_sz) { warn(%s, _PATH_LD_HINTS); - goto out; + goto fdout; } if (fchmod(fd, 0444) == -1) { warn(%s, _PATH_LD_HINTS); - goto out; + goto fdout; } if (close(fd) != 0) { warn(%s, _PATH_LD_HINTS); @@ -501,6 +501,8 @@ free(blist); free(strtab); return 0; +fdout: + (void)close(fd); out: free(blist); free(strtab);
CVS commit: src/sbin/mount_portal
Module Name:src Committed By: wiz Date: Tue Jan 4 23:36:23 UTC 2011 Modified Files: src/sbin/mount_portal: pt_filter.c Log Message: Use pclose for popened handles. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sbin/mount_portal/pt_filter.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/mount_portal/pt_filter.c diff -u src/sbin/mount_portal/pt_filter.c:1.10 src/sbin/mount_portal/pt_filter.c:1.11 --- src/sbin/mount_portal/pt_filter.c:1.10 Mon Apr 28 20:23:09 2008 +++ src/sbin/mount_portal/pt_filter.c Tue Jan 4 23:36:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pt_filter.c,v 1.10 2008/04/28 20:23:09 martin Exp $ */ +/* $NetBSD: pt_filter.c,v 1.11 2011/01/04 23:36:23 wiz Exp $ */ /* * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: pt_filter.c,v 1.10 2008/04/28 20:23:09 martin Exp $); +__RCSID($NetBSD: pt_filter.c,v 1.11 2011/01/04 23:36:23 wiz Exp $); #endif/* not lint */ #include stdio.h @@ -149,7 +149,7 @@ if ((seteuid((uid_t) 0) 0) || (setegid((gid_t) 0) 0)) { error = errno; syslog(LOG_WARNING, setcred: %m); - fclose(fp); + pclose(fp); fp = NULL; } } @@ -193,7 +193,7 @@ if ((seteuid((uid_t) 0) 0) || (setegid((gid_t) 0) 0)) { error = errno; syslog(LOG_WARNING, setcred: %m); - fclose(fp); + pclose(fp); fp = NULL; } }
CVS commit: src/sbin/newfs_udf
Module Name:src Committed By: wiz Date: Tue Jan 4 23:42:48 UTC 2011 Modified Files: src/sbin/newfs_udf: newfs_udf.c Log Message: Fix memory leaks. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sbin/newfs_udf/newfs_udf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_udf/newfs_udf.c diff -u src/sbin/newfs_udf/newfs_udf.c:1.8 src/sbin/newfs_udf/newfs_udf.c:1.9 --- src/sbin/newfs_udf/newfs_udf.c:1.8 Thu Sep 17 10:37:28 2009 +++ src/sbin/newfs_udf/newfs_udf.c Tue Jan 4 23:42:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs_udf.c,v 1.8 2009/09/17 10:37:28 reinoud Exp $ */ +/* $NetBSD: newfs_udf.c,v 1.9 2011/01/04 23:42:48 wiz Exp $ */ /* * Copyright (c) 2006, 2008 Reinoud Zandijk @@ -848,8 +848,10 @@ /* block is bad */ printf(BAD block at %08d + %d \n, loc, layout.blockingnr); - if ((error = udf_register_bad_block(loc))) + if ((error = udf_register_bad_block(loc))) { +free(buffer); return error; + } num_errors ++; } loc += layout.blockingnr; @@ -868,8 +870,10 @@ /* block is bad */ printf(BAD block at %08d + %d \n, loc, layout.blockingnr); - if ((error = udf_register_bad_block(loc))) + if ((error = udf_register_bad_block(loc))) { +free(buffer); return error; + } num_errors ++; } loc += layout.blockingnr; @@ -904,8 +908,10 @@ /* wipe at least 6 times 2048 byte `sectors' */ for (cnt = 0; cnt 6 *dpos; cnt++) { pos = layout.iso9660_vrs + cnt; - if ((error = udf_write_sector(iso9660_vrs_desc, pos))) + if ((error = udf_write_sector(iso9660_vrs_desc, pos))) { +free(iso9660_vrs_desc); return error; + } } /* common VRS fields in all written out ISO descriptors */ @@ -915,8 +921,10 @@ /* BEA01, NSR[23], TEA01 */ memcpy(iso9660_vrs_desc-identifier, BEA01, 5); - if ((error = udf_write_sector(iso9660_vrs_desc, pos))) + if ((error = udf_write_sector(iso9660_vrs_desc, pos))) { + free(iso9660_vrs_desc); return error; + } pos += dpos; if (context.dscrver == 2) @@ -924,15 +932,20 @@ else memcpy(iso9660_vrs_desc-identifier, NSR03, 5); ; - if ((error = udf_write_sector(iso9660_vrs_desc, pos))) + if ((error = udf_write_sector(iso9660_vrs_desc, pos))) { + free(iso9660_vrs_desc); return error; + } pos += dpos; memcpy(iso9660_vrs_desc-identifier, TEA01, 5); - if ((error = udf_write_sector(iso9660_vrs_desc, pos))) + if ((error = udf_write_sector(iso9660_vrs_desc, pos))) { + free(iso9660_vrs_desc); return error; + } } + free(iso9660_vrs_desc); /* return success */ return 0; } @@ -1062,14 +1075,18 @@ loc = (format_flags FORMAT_TRACK512) ? layout.vds1 : ti.track_start; for (; loc layout.part_start_lba; loc++) { - if ((error = udf_write_sector(zero_dscr, loc))) + if ((error = udf_write_sector(zero_dscr, loc))) { + free(zero_dscr); return error; + } } + free(zero_dscr); /* Create anchors */ for (cnt = 0; cnt 3; cnt++) { - if ((error = udf_create_anchor(cnt))) + if ((error = udf_create_anchor(cnt))) { return error; + } } /*
CVS commit: src/sbin/wdogctl
Module Name:src Committed By: wiz Date: Tue Jan 4 23:48:45 UTC 2011 Modified Files: src/sbin/wdogctl: wdogctl.c Log Message: Fix fd leaks. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sbin/wdogctl/wdogctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/wdogctl/wdogctl.c diff -u src/sbin/wdogctl/wdogctl.c:1.18 src/sbin/wdogctl/wdogctl.c:1.19 --- src/sbin/wdogctl/wdogctl.c:1.18 Mon Mar 16 13:37:45 2009 +++ src/sbin/wdogctl/wdogctl.c Tue Jan 4 23:48:44 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: wdogctl.c,v 1.18 2009/03/16 13:37:45 lukem Exp $ */ +/* $NetBSD: wdogctl.c,v 1.19 2011/01/04 23:48:44 wiz Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -35,7 +35,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: wdogctl.c,v 1.18 2009/03/16 13:37:45 lukem Exp $); +__RCSID($NetBSD: wdogctl.c,v 1.19 2011/01/04 23:48:44 wiz Exp $); #endif @@ -200,6 +200,8 @@ if (ioctl(fd, WDOGIOC_SMODE, wm) == -1) err(EXIT_FAILURE, WDOGIOC_SMODE); + + (void)close(fd); } void @@ -219,6 +221,8 @@ if (ioctl(fd, WDOGIOC_TICKLE) == -1) syslog(LOG_EMERG, unable to tickle watchdog timer %s: %m, wm.wm_name); + + (void)close(fd); return; } @@ -316,6 +320,8 @@ err(EXIT_FAILURE, open %s, _PATH_WATCHDOG); if (ioctl(fd, WDOGIOC_TICKLE) == -1) fprintf(stderr, Cannot tickle timer\n); + + (void)close(fd); } void @@ -331,6 +337,7 @@ if (ioctl(fd, WDOGIOC_WHICH, wm) == -1) { printf(No watchdog timer running.\n); + (void)close(fd); return; } mode = wm.wm_mode WDOG_MODE_MASK;
CVS commit: src/lib/libc/gmon
Module Name:src Committed By: wiz Date: Wed Jan 5 00:03:52 UTC 2011 Modified Files: src/lib/libc/gmon: gmon.c Log Message: Fix fdleak in #ifdef DEBUG. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/lib/libc/gmon/gmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gmon/gmon.c diff -u src/lib/libc/gmon/gmon.c:1.32 src/lib/libc/gmon/gmon.c:1.33 --- src/lib/libc/gmon/gmon.c:1.32 Mon Mar 1 19:52:38 2010 +++ src/lib/libc/gmon/gmon.c Wed Jan 5 00:03:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: gmon.c,v 1.32 2010/03/01 19:52:38 christos Exp $ */ +/* $NetBSD: gmon.c,v 1.33 2011/01/05 00:03:52 wiz Exp $ */ /* * Copyright (c) 2003, 2004 Wasabi Systems, Inc. @@ -69,7 +69,7 @@ #if 0 static char sccsid[] = @(#)gmon.c 8.1 (Berkeley) 6/4/93; #else -__RCSID($NetBSD: gmon.c,v 1.32 2010/03/01 19:52:38 christos Exp $); +__RCSID($NetBSD: gmon.c,v 1.33 2011/01/05 00:03:52 wiz Exp $); #endif #endif @@ -441,6 +441,7 @@ logfd = open(gmon.log, O_CREAT|O_TRUNC|O_WRONLY, 0664); if (logfd 0) { warn(%s: Cannot open `%s', __func__, gmon.log); + (void)close(fd); return; } len = snprintf(buf2, sizeof buf2, [mcleanup1] kcount %p ssiz %lu\n,
CVS commit: src/lib/libc/net
Module Name:src Committed By: wiz Date: Wed Jan 5 00:09:43 UTC 2011 Modified Files: src/lib/libc/net: hesiod.c Log Message: Fix fdleak in error case. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/lib/libc/net/hesiod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/net/hesiod.c diff -u src/lib/libc/net/hesiod.c:1.24 src/lib/libc/net/hesiod.c:1.25 --- src/lib/libc/net/hesiod.c:1.24 Wed Oct 19 22:56:42 2005 +++ src/lib/libc/net/hesiod.c Wed Jan 5 00:09:43 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hesiod.c,v 1.24 2005/10/19 22:56:42 christos Exp $ */ +/* $NetBSD: hesiod.c,v 1.25 2011/01/05 00:09:43 wiz Exp $ */ /* Copyright (c) 1996 by Internet Software Consortium. * @@ -51,7 +51,7 @@ #Id: hesiod_p.h,v 1.1 1996/12/08 21:39:37 ghudson Exp #); __IDSTRING(rcsid_hescompat_c, #Id: hescompat.c,v 1.1.2.1 1996/12/16 08:37:45 ghudson Exp #); -__RCSID($NetBSD: hesiod.c,v 1.24 2005/10/19 22:56:42 christos Exp $); +__RCSID($NetBSD: hesiod.c,v 1.25 2011/01/05 00:09:43 wiz Exp $); #endif /* LIBC_SCCS and not lint */ #include namespace.h @@ -378,6 +378,7 @@ *which = strdup(data); if (!*which) { errno = ENOMEM; +(void)fclose(fp); return -1; } } else {
CVS commit: src/lib/librumpuser
Module Name:src Committed By: wiz Date: Wed Jan 5 00:19:20 UTC 2011 Modified Files: src/lib/librumpuser: rumpuser.c Log Message: Fix fdleak in error case. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/lib/librumpuser/rumpuser.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/librumpuser/rumpuser.c diff -u src/lib/librumpuser/rumpuser.c:1.10 src/lib/librumpuser/rumpuser.c:1.11 --- src/lib/librumpuser/rumpuser.c:1.10 Mon Nov 15 15:23:32 2010 +++ src/lib/librumpuser/rumpuser.c Wed Jan 5 00:19:20 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpuser.c,v 1.10 2010/11/15 15:23:32 pooka Exp $ */ +/* $NetBSD: rumpuser.c,v 1.11 2011/01/05 00:19:20 wiz Exp $ */ /* * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved. @@ -27,7 +27,7 @@ #include sys/cdefs.h #if !defined(lint) -__RCSID($NetBSD: rumpuser.c,v 1.10 2010/11/15 15:23:32 pooka Exp $); +__RCSID($NetBSD: rumpuser.c,v 1.11 2011/01/05 00:19:20 wiz Exp $); #endif /* !lint */ /* thank the maker for this */ @@ -159,6 +159,7 @@ if (ioctl(fd, DIOCGDINFO, lab) == -1) { seterror(errno); + (void)close(fd); rv = -1; goto out; }
CVS commit: src/sbin/resize_ffs
Module Name:src Committed By: riz Date: Wed Jan 5 02:18:16 UTC 2011 Modified Files: src/sbin/resize_ffs: Makefile TODO resize_ffs.8 resize_ffs.c Log Message: Add support for byteswapped file systems (big-endian on little-endian host, and vice versa), to fix PR#44203. Add support for growing (but not yet shrinking) UFS2 file systems. Partially addresses PR#44205. While I'm here, reformat the code for closer adherence to KNF. Fairly extensive testing was performed, using the shortly-to-be-committed updated ATF tests. Patch posted to tech-userlevel on 21 December 2010, no comments. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sbin/resize_ffs/Makefile cvs rdiff -u -r1.7 -r1.8 src/sbin/resize_ffs/TODO cvs rdiff -u -r1.9 -r1.10 src/sbin/resize_ffs/resize_ffs.8 cvs rdiff -u -r1.24 -r1.25 src/sbin/resize_ffs/resize_ffs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/resize_ffs/Makefile diff -u src/sbin/resize_ffs/Makefile:1.2 src/sbin/resize_ffs/Makefile:1.3 --- src/sbin/resize_ffs/Makefile:1.2 Sun Apr 26 05:57:48 2009 +++ src/sbin/resize_ffs/Makefile Wed Jan 5 02:18:15 2011 @@ -1,8 +1,13 @@ -# $NetBSD: Makefile,v 1.2 2009/04/26 05:57:48 lukem Exp $ +# $NetBSD: Makefile,v 1.3 2011/01/05 02:18:15 riz Exp $ + +.include bsd.own.mk WARNS?= 3 # XXX: sign-compare issues PROG=resize_ffs MAN=resize_ffs.8 +SRCS=resize_ffs.c ffs_bswap.c + +.PATH: ${NETBSDSRCDIR}/sys/ufs/ffs .include bsd.prog.mk Index: src/sbin/resize_ffs/TODO diff -u src/sbin/resize_ffs/TODO:1.7 src/sbin/resize_ffs/TODO:1.8 --- src/sbin/resize_ffs/TODO:1.7 Wed Dec 8 15:23:53 2010 +++ src/sbin/resize_ffs/TODO Wed Jan 5 02:18:15 2011 @@ -1,6 +1,6 @@ resize_ffs(8) TODO list -* Add support for swapped byte order -* Fix support for disk blocks of size other than 512 bytes -* Extend to support UFS2. Probably growth first, then shrinking separately. +* Test and likely fix support for disk blocks of size other than 512 bytes +* Support shrinking UFS2 file systems +* Make the output a bit more verbose, similar to newfs(8) * Expand the testing done in src/tests/sbin/resize_ffs Index: src/sbin/resize_ffs/resize_ffs.8 diff -u src/sbin/resize_ffs/resize_ffs.8:1.9 src/sbin/resize_ffs/resize_ffs.8:1.10 --- src/sbin/resize_ffs/resize_ffs.8:1.9 Mon Dec 20 00:49:23 2010 +++ src/sbin/resize_ffs/resize_ffs.8 Wed Jan 5 02:18:15 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: resize_ffs.8,v 1.9 2010/12/20 00:49:23 riz Exp $ +.\ $NetBSD: resize_ffs.8,v 1.10 2011/01/05 02:18:15 riz Exp $ .\ .\ As its sole author, I explicitly place this man page in the public .\ domain. Anyone may use it in any way for any purpose (though I would @@ -9,22 +9,22 @@ .\ X Against HTML mo...@rodents.montreal.qc.ca .\ / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B .\ -.Dd October 30, 2010 +.Dd January 4, 2011 .Dt RESIZE_FFS 8 .Os .Sh NAME .Nm resize_ffs -.Nd resize an on-disk file system +.Nd resize a file system on disk or in a file .Sh SYNOPSIS .Nm .Op Fl y .Op Fl s Ar size -.Ar file-system-raw-device +.Ar special .Sh DESCRIPTION .Nm -resizes a file system on disk. -.Ar file-system-raw-device -is the name of the raw disk device where the file system resides; +resizes a file system. +.Ar special +is the name of the raw disk device or file where the file system resides; (Sectors are almost always 512 bytes, and .Nm can both grow and shrink file systems. @@ -53,7 +53,7 @@ .Nm will grow the file system to the underlying device size which is determined from -.Ar file-system-raw-device . +.Ar special . .Pp The options are as follows: .Bl -tag -width indent @@ -66,10 +66,6 @@ .Nm . .El .Sh WARNING -.Nm -should still be considered experimental. -It still needs to be validated with a rigorous regression test -suite. .Em Interrupting .Nm .Em may leave your file system in an inconsistent state and require a @@ -88,16 +84,7 @@ It's probably wise to .Xr fsck 8 the file system before and after, just to be safe. -.\ Remove this when (if) fsck gets fixed. -.Pp -There is a bug somewhere in -.Xr fsck 8 ; -it does not check certain data structures enough. -A past version of this program had a bug that produced corrupted -rotation layout summary tables, which would panic the kernel. -This bug is believed fixed, and there are currently no -known bugs in the program. -However, you should be aware that just because +You should be aware that just because .Xr fsck 8 is happy with the file system does not mean it is intact. .Sh EXIT STATUS @@ -127,15 +114,16 @@ .Sh AUTHORS .An der Mouse .Aq mo...@rodents.montreal.qc.ca +(primary author) +.An Jeff Rizzo +.Aq r...@netbsd.org +(Byteswapped file system and UFS2 support) .Pp A big bug-finding kudos goes to John Kohl for finding the rotational layout bug referred to in the .Sx WARNING section above. .Sh BUGS -Has not been tested
CVS commit: src
Module Name:src Committed By: riz Date: Wed Jan 5 02:25:27 UTC 2011 Modified Files: src/distrib/sets/lists/tests: mi src/tests/sbin/resize_ffs: Makefile common.sh t_grow.sh t_shrink.sh Added Files: src/tests/sbin/resize_ffs: t_grow_swapped.sh t_shrink_swapped.sh Log Message: Update resize_ffs tests for byteswapped file system support, and for UFS2 growth support. Also, reduce the number of tests run by default while still maintaining decent coverage of features and block sizes. Anyone working on resize_Ffs should run the tests with RESIZE_FFS_ALL_TESTS set in the environment, which adds a lot more testing. To generate a diff of this commit: cvs rdiff -u -r1.206 -r1.207 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.2 -r1.3 src/tests/sbin/resize_ffs/Makefile cvs rdiff -u -r1.5 -r1.6 src/tests/sbin/resize_ffs/common.sh cvs rdiff -u -r1.6 -r1.7 src/tests/sbin/resize_ffs/t_grow.sh \ src/tests/sbin/resize_ffs/t_shrink.sh cvs rdiff -u -r0 -r1.1 src/tests/sbin/resize_ffs/t_grow_swapped.sh \ src/tests/sbin/resize_ffs/t_shrink_swapped.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.206 src/distrib/sets/lists/tests/mi:1.207 --- src/distrib/sets/lists/tests/mi:1.206 Tue Jan 4 22:30:41 2011 +++ src/distrib/sets/lists/tests/mi Wed Jan 5 02:25:27 2011 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.206 2011/01/04 22:30:41 pgoyette Exp $ +# $NetBSD: mi,v 1.207 2011/01/05 02:25:27 riz Exp $ # # Note: don't delete entries from here - mark them as obsolete instead. # @@ -1818,8 +1818,9 @@ ./usr/tests/sbin/resize_ffs tests-sbin-tests ./usr/tests/sbin/resize_ffs/Atffile tests-sbin-tests atf ./usr/tests/sbin/resize_ffs/t_grow tests-sbin-tests atf +./usr/tests/sbin/resize_ffs/t_grow_swapped tests-sbin-tests atf ./usr/tests/sbin/resize_ffs/t_resize_ffs tests-obsolete obsolete -./usr/tests/sbin/resize_ffs/t_shrink tests-sbin-tests atf +./usr/tests/sbin/resize_ffs/t_shrink_swapped tests-sbin-tests atf ./usr/tests/sbin/resize_ffs/testdata.md5 tests-sbin-tests atf ./usr/tests/sbin/resize_ffs/testdata.tar.gz.base64 tests-sbin-tests atf ./usr/tests/systests-sys-tests Index: src/tests/sbin/resize_ffs/Makefile diff -u src/tests/sbin/resize_ffs/Makefile:1.2 src/tests/sbin/resize_ffs/Makefile:1.3 --- src/tests/sbin/resize_ffs/Makefile:1.2 Thu Dec 9 05:19:02 2010 +++ src/tests/sbin/resize_ffs/Makefile Wed Jan 5 02:25:27 2011 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.2 2010/12/09 05:19:02 riz Exp $ +# $NetBSD: Makefile,v 1.3 2011/01/05 02:25:27 riz Exp $ .include bsd.own.mk TESTSDIR= ${TESTSBASE}/sbin/resize_ffs -.for name in t_grow t_shrink +.for name in t_grow t_shrink t_grow_swapped t_shrink_swapped TESTS_SH+= ${name} TESTS_SH_SRC_${name}= common.sh ${name}.sh .endfor Index: src/tests/sbin/resize_ffs/common.sh diff -u src/tests/sbin/resize_ffs/common.sh:1.5 src/tests/sbin/resize_ffs/common.sh:1.6 --- src/tests/sbin/resize_ffs/common.sh:1.5 Thu Dec 16 17:16:07 2010 +++ src/tests/sbin/resize_ffs/common.sh Wed Jan 5 02:25:27 2011 @@ -100,7 +100,7 @@ resize_ffs() { - echo in shrink_ffs: $...@} + echo in resize_ffs: $...@} local bs=$1 local fragsz=$2 local osize=$3 @@ -110,7 +110,7 @@ local swap=$7 mkdir -p mnt echo bs is ${bs} numdata is ${numdata} - echo shrinking fs with blocksize ${bs} + echo resizing fs with blocksize ${bs} # we want no more than 16K/inode to allow test files to copy. local fpi=$((fragsz * 4)) @@ -147,5 +147,4 @@ check_data_range $((remove + 1)) ${numdata} fi umount mnt - rm -f ${IMG} # probably unnecessary } Index: src/tests/sbin/resize_ffs/t_grow.sh diff -u src/tests/sbin/resize_ffs/t_grow.sh:1.6 src/tests/sbin/resize_ffs/t_grow.sh:1.7 --- src/tests/sbin/resize_ffs/t_grow.sh:1.6 Thu Dec 16 17:50:13 2010 +++ src/tests/sbin/resize_ffs/t_grow.sh Wed Jan 5 02:25:27 2011 @@ -1,4 +1,4 @@ -# $NetBSD: t_grow.sh,v 1.6 2010/12/16 17:50:13 riz Exp $ +# $NetBSD: t_grow.sh,v 1.7 2011/01/05 02:25:27 riz Exp $ # # Copyright (c) 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -35,10 +35,37 @@ # determined manually based on the maximum number that will fit in the # created fs. 'level' is the fs-level (-O 0,1,2) passed to newfs. # If 'swap' is included, byteswap the fs + +# v0 == newfs -O0 (4.3BSD layout, ffsv1 superblock) +test_case grow_16M_v0_4096 resize_ffs 4096 512 32768 131072 0 28 +test_case grow_16M_v0_8192 resize_ffs 8192 1024 32768 131072 0 28 +test_case grow_16M_v0_16384 resize_ffs 16384 2048 32768 131072 0 29 +test_case grow_16M_v0_32768 resize_ffs 32768 4096 32768 131072 0 28 +test_case grow_16M_v0_65536 resize_ffs 65536 8192 32768 131072 0 26 +# these grow_24M grow a smaller amount; sometimes there's different issues +test_case grow_24M_v0_4096 resize_ffs 4096 512 49152 65536 0 41 +test_case grow_24M_v0_8192
CVS commit: src/tests/sbin/resize_ffs
Module Name:src Committed By: riz Date: Wed Jan 5 03:04:13 UTC 2011 Modified Files: src/tests/sbin/resize_ffs: common.sh Log Message: All of the generated tests require root, for rump_ffs. Spotted by nj...@. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/sbin/resize_ffs/common.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/sbin/resize_ffs/common.sh diff -u src/tests/sbin/resize_ffs/common.sh:1.6 src/tests/sbin/resize_ffs/common.sh:1.7 --- src/tests/sbin/resize_ffs/common.sh:1.6 Wed Jan 5 02:25:27 2011 +++ src/tests/sbin/resize_ffs/common.sh Wed Jan 5 03:04:13 2011 @@ -24,6 +24,9 @@ local check_function=${1}; shift atf_test_case ${name} cleanup + eval ${name}_head() { \ + atf_set require.user root ; \ + } eval ${name}_body() { \ ${check_function} $...@} ; \ }
CVS commit: src/doc
Module Name:src Committed By: riz Date: Wed Jan 5 03:49:57 UTC 2011 Modified Files: src/doc: CHANGES Log Message: Note resize_ffs(8) changes. To generate a diff of this commit: cvs rdiff -u -r1.1483 -r1.1484 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.1483 src/doc/CHANGES:1.1484 --- src/doc/CHANGES:1.1483 Mon Jan 3 11:35:04 2011 +++ src/doc/CHANGES Wed Jan 5 03:49:57 2011 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: $Revision: 1.1483 $ +# LIST OF CHANGES FROM LAST RELEASE: $Revision: 1.1484 $ # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -816,3 +816,5 @@ auvitek(4): Add a driver for Auvitek AU0828 family USB video capture controllers. [jmcneill 20101227] dhcpcd(8): Import dhcpcd-5.2.10. [roy 20110103] + resize_ffs(8): support byteswapped file systems, and support + growing ufs2 file systems. [riz 20110104]
CVS commit: src/sys/arch/hp700/include
Module Name:src Committed By: skrll Date: Wed Jan 5 07:40:16 UTC 2011 Modified Files: src/sys/arch/hp700/include: autoconf.h Log Message: Unwrap short line. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/hp700/include/autoconf.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/hp700/include/autoconf.h diff -u src/sys/arch/hp700/include/autoconf.h:1.15 src/sys/arch/hp700/include/autoconf.h:1.16 --- src/sys/arch/hp700/include/autoconf.h:1.15 Tue Jan 4 10:42:34 2011 +++ src/sys/arch/hp700/include/autoconf.h Wed Jan 5 07:40:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.h,v 1.15 2011/01/04 10:42:34 skrll Exp $ */ +/* $NetBSD: autoconf.h,v 1.16 2011/01/05 07:40:16 skrll Exp $ */ /* $OpenBSD: autoconf.h,v 1.10 2001/05/05 22:33:42 art Exp $ */ @@ -86,8 +86,8 @@ void (*)(device_t, struct confargs *)); int mbprint(void *, const char *); -int mbsubmatch(device_t, struct cfdata *, - const int *, void *); +int mbsubmatch(device_t, struct cfdata *, const int *, void *); + int clock_intr(void *); void dumpconf(void);
CVS commit: src/sys/dev/acpi
Module Name:src Committed By: jruoho Date: Wed Jan 5 07:58:04 UTC 2011 Modified Files: src/sys/dev/acpi: acpi.c Log Message: Make a two-pass scan for acpinodebus. This should ensure that devices such as acpiec(4) are attached before anything else. Numerous bugs are expected to be fixed with this change. To generate a diff of this commit: cvs rdiff -u -r1.225 -r1.226 src/sys/dev/acpi/acpi.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/acpi/acpi.c diff -u src/sys/dev/acpi/acpi.c:1.225 src/sys/dev/acpi/acpi.c:1.226 --- src/sys/dev/acpi/acpi.c:1.225 Mon Jan 3 08:50:23 2011 +++ src/sys/dev/acpi/acpi.c Wed Jan 5 07:58:04 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi.c,v 1.225 2011/01/03 08:50:23 jruoho Exp $ */ +/* $NetBSD: acpi.c,v 1.226 2011/01/05 07:58:04 jruoho Exp $ */ /*- * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. @@ -100,7 +100,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: acpi.c,v 1.225 2011/01/03 08:50:23 jruoho Exp $); +__KERNEL_RCSID(0, $NetBSD: acpi.c,v 1.226 2011/01/05 07:58:04 jruoho Exp $); #include opt_acpi.h #include opt_pcifixup.h @@ -192,6 +192,14 @@ NULL }; +/* + * Devices that should be attached early. + */ +static const char * const acpi_early_ids[] = { + PNP0C09, /* acpiec(4) */ + NULL +}; + static int acpi_match(device_t, cfdata_t, void *); static int acpi_submatch(device_t, cfdata_t, const int *, void *); static void acpi_attach(device_t, device_t, void *); @@ -212,6 +220,7 @@ #endif static int acpi_rescan(device_t, const char *, const int *); +static void acpi_rescan_early(struct acpi_softc *); static void acpi_rescan_nodes(struct acpi_softc *); static void acpi_rescan_capabilities(device_t); static int acpi_print(void *aux, const char *); @@ -940,8 +949,13 @@ { struct acpi_softc *sc = device_private(self); - if (ifattr_match(ifattr, acpinodebus)) + /* + * A two-pass scan for acpinodebus. + */ + if (ifattr_match(ifattr, acpinodebus)) { + acpi_rescan_early(sc); acpi_rescan_nodes(sc); + } if (ifattr_match(ifattr, acpiapmbus) sc-sc_apmbus == NULL) sc-sc_apmbus = config_found_ia(sc-sc_dev, @@ -951,6 +965,41 @@ } static void +acpi_rescan_early(struct acpi_softc *sc) +{ + struct acpi_attach_args aa; + struct acpi_devnode *ad; + + /* + * First scan for devices such as acpiec(4) that + * should be always attached before anything else. + * We want these devices to attach regardless of + * the device status and other restrictions. + */ + SIMPLEQ_FOREACH(ad, sc-ad_head, ad_list) { + + if (ad-ad_device != NULL) + continue; + + if (ad-ad_devinfo-Type != ACPI_TYPE_DEVICE) + continue; + + if (acpi_match_hid(ad-ad_devinfo, acpi_early_ids) == 0) + continue; + + aa.aa_node = ad; + aa.aa_iot = sc-sc_iot; + aa.aa_memt = sc-sc_memt; + aa.aa_pc = sc-sc_pc; + aa.aa_pciflags = sc-sc_pciflags; + aa.aa_ic = sc-sc_ic; + + ad-ad_device = config_found_ia(sc-sc_dev, + acpinodebus, aa, acpi_print); + } +} + +static void acpi_rescan_nodes(struct acpi_softc *sc) { struct acpi_attach_args aa;