Module Name: src Committed By: matt Date: Wed Apr 21 05:26:35 UTC 2010
Modified Files: src/sbin/atactl [matt-nb5-mips64]: atactl.c src/sbin/dkctl [matt-nb5-mips64]: dkctl.8 dkctl.c src/sbin/drvctl [matt-nb5-mips64]: drvctl.8 drvctl.c src/sbin/fdisk [matt-nb5-mips64]: fdisk.c src/sbin/fsck_ext2fs [matt-nb5-mips64]: main.c src/sbin/fsck_ffs [matt-nb5-mips64]: extern.h setup.c wapbl.c src/sbin/ifconfig [matt-nb5-mips64]: af_link.c ifconfig.8 ifconfig.c parse.c util.c util.h vlan.c src/sbin/newfs [matt-nb5-mips64]: newfs.c src/sbin/newfs_msdos [matt-nb5-mips64]: newfs_msdos.c src/sbin/newfs_udf [matt-nb5-mips64]: newfs_udf.8 udf_create.c src/sbin/ping [matt-nb5-mips64]: ping.c src/sbin/raidctl [matt-nb5-mips64]: raidctl.8 raidctl.c src/sbin/savecore [matt-nb5-mips64]: savecore.c src/sbin/tunefs [matt-nb5-mips64]: tunefs.c src/sbin/wsconsctl [matt-nb5-mips64]: wsconsctl.8 Log Message: sync to netbsd-5 To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.52.8.1 src/sbin/atactl/atactl.c cvs rdiff -u -r1.17 -r1.17.32.1 src/sbin/dkctl/dkctl.8 cvs rdiff -u -r1.16 -r1.16.32.1 src/sbin/dkctl/dkctl.c cvs rdiff -u -r1.5 -r1.5.16.1 src/sbin/drvctl/drvctl.8 cvs rdiff -u -r1.6 -r1.6.16.1 src/sbin/drvctl/drvctl.c cvs rdiff -u -r1.116.6.1 -r1.116.6.1.4.1 src/sbin/fdisk/fdisk.c cvs rdiff -u -r1.32 -r1.32.8.1 src/sbin/fsck_ext2fs/main.c cvs rdiff -u -r1.24 -r1.24.8.1 src/sbin/fsck_ffs/extern.h cvs rdiff -u -r1.84 -r1.84.8.1 src/sbin/fsck_ffs/setup.c cvs rdiff -u -r1.2 -r1.2.10.1 src/sbin/fsck_ffs/wapbl.c cvs rdiff -u -r1.3 -r1.3.8.1 src/sbin/ifconfig/af_link.c cvs rdiff -u -r1.94 -r1.94.8.1 src/sbin/ifconfig/ifconfig.8 cvs rdiff -u -r1.213.2.1 -r1.213.2.1.4.1 src/sbin/ifconfig/ifconfig.c cvs rdiff -u -r1.12 -r1.12.6.1 src/sbin/ifconfig/parse.c cvs rdiff -u -r1.8 -r1.8.6.1 src/sbin/ifconfig/util.c cvs rdiff -u -r1.6 -r1.6.8.1 src/sbin/ifconfig/util.h cvs rdiff -u -r1.12 -r1.12.8.1 src/sbin/ifconfig/vlan.c cvs rdiff -u -r1.102 -r1.102.8.1 src/sbin/newfs/newfs.c cvs rdiff -u -r1.27.2.2 -r1.27.2.2.4.1 src/sbin/newfs_msdos/newfs_msdos.c cvs rdiff -u -r1.4.4.1 -r1.4.4.1.4.1 src/sbin/newfs_udf/newfs_udf.8 cvs rdiff -u -r1.12.4.2 -r1.12.4.2.4.1 src/sbin/newfs_udf/udf_create.c cvs rdiff -u -r1.87 -r1.87.16.1 src/sbin/ping/ping.c cvs rdiff -u -r1.56 -r1.56.8.1 src/sbin/raidctl/raidctl.8 cvs rdiff -u -r1.39.4.1 -r1.39.4.1.4.1 src/sbin/raidctl/raidctl.c cvs rdiff -u -r1.76.2.1 -r1.76.2.1.4.1 src/sbin/savecore/savecore.c cvs rdiff -u -r1.37 -r1.37.8.1 src/sbin/tunefs/tunefs.c cvs rdiff -u -r1.25.6.1 -r1.25.6.1.2.1 src/sbin/wsconsctl/wsconsctl.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/atactl/atactl.c diff -u src/sbin/atactl/atactl.c:1.52 src/sbin/atactl/atactl.c:1.52.8.1 --- src/sbin/atactl/atactl.c:1.52 Mon Aug 25 00:45:56 2008 +++ src/sbin/atactl/atactl.c Wed Apr 21 05:26:33 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: atactl.c,v 1.52 2008/08/25 00:45:56 dholland Exp $ */ +/* $NetBSD: atactl.c,v 1.52.8.1 2010/04/21 05:26:33 matt Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: atactl.c,v 1.52 2008/08/25 00:45:56 dholland Exp $"); +__RCSID("$NetBSD: atactl.c,v 1.52.8.1 2010/04/21 05:26:33 matt Exp $"); #endif @@ -856,9 +856,9 @@ device_identify(int argc, char *argv[]) { struct ataparams *inqbuf; - char model[sizeof(inqbuf->atap_model)]; - char revision[sizeof(inqbuf->atap_revision)]; - char serial[sizeof(inqbuf->atap_serial)]; + char model[sizeof(inqbuf->atap_model)+1]; + char revision[sizeof(inqbuf->atap_revision)+1]; + char serial[sizeof(inqbuf->atap_serial)+1]; int needswap = 0; /* No arguments. */ Index: src/sbin/dkctl/dkctl.8 diff -u src/sbin/dkctl/dkctl.8:1.17 src/sbin/dkctl/dkctl.8:1.17.32.1 --- src/sbin/dkctl/dkctl.8:1.17 Thu Jan 12 20:28:29 2006 +++ src/sbin/dkctl/dkctl.8 Wed Apr 21 05:26:33 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: dkctl.8,v 1.17 2006/01/12 20:28:29 wiz Exp $ +.\" $NetBSD: dkctl.8,v 1.17.32.1 2010/04/21 05:26:33 matt Exp $ .\" .\" Copyright 2002 Wasabi Systems, Inc. .\" All rights reserved. @@ -33,7 +33,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd December 26, 2005 +.Dd July 30, 2009 .Dt DKCTL 8 .Os .Sh NAME @@ -118,6 +118,24 @@ .Ar name and the partition type .Ar ptype . +Valid choices for ptype would be +.Ar unused , +.Ar swap , +.Ar ffs , +.Ar lfs , +.Ar ext2fs , +.Ar cd9660 , +.Ar ados , +.Ar hfs , +.Ar msdos , +.Ar filecore , +.Ar raidframe , +.Ar ccd , +.Ar appleufs , +.Ar ntfs , +and +.Ar cgd . +.Pp The device name of the virtual block device assigned to the wedge will be displayed after the wedge has been successfully created. See Index: src/sbin/dkctl/dkctl.c diff -u src/sbin/dkctl/dkctl.c:1.16 src/sbin/dkctl/dkctl.c:1.16.32.1 --- src/sbin/dkctl/dkctl.c:1.16 Sat Jun 17 02:16:19 2006 +++ src/sbin/dkctl/dkctl.c Wed Apr 21 05:26:33 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: dkctl.c,v 1.16 2006/06/17 02:16:19 christos Exp $ */ +/* $NetBSD: dkctl.c,v 1.16.32.1 2010/04/21 05:26:33 matt Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -41,7 +41,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: dkctl.c,v 1.16 2006/06/17 02:16:19 christos Exp $"); +__RCSID("$NetBSD: dkctl.c,v 1.16.32.1 2010/04/21 05:26:33 matt Exp $"); #endif @@ -533,6 +533,9 @@ if (ioctl(fd, DIOCAWEDGE, &dkw) == -1) err(1, "%s: addwedge", dvname); + else + printf("%s created successfully.\n", dkw.dkw_devname); + } void Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.5 src/sbin/drvctl/drvctl.8:1.5.16.1 --- src/sbin/drvctl/drvctl.8:1.5 Sat Feb 16 02:00:37 2008 +++ src/sbin/drvctl/drvctl.8 Wed Apr 21 05:26:33 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: drvctl.8,v 1.5 2008/02/16 02:00:37 dyoung Exp $ +.\" $NetBSD: drvctl.8,v 1.5.16.1 2010/04/21 05:26:33 matt Exp $ .\" .\" Copyright (c) 2004 .\" Matthias Drochner. All rights reserved. @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd Feburary 15, 2008 +.Dd April 20, 2009 .Dt DRVCTL 8 .Os .Sh NAME @@ -40,8 +40,9 @@ .Fl d .Ar device .Nm +.Op Fl n .Fl l -.Ar device +.Op Ar device .Nm .Fl p .Ar device @@ -78,6 +79,22 @@ List the children of the device specified by the .Ar device argument. +If +.Ar device +is not specified, list roots of the device tree instead. +Output comes in two columns. +The first column is +.Ar device , +or +.Dq root +if +.Ar device +is not specified. +The second column is the child. +.It Fl n +Suppress first column in +.Fl l +output. .It Fl p Get the properties for the device specified by the .Ar device Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.6 src/sbin/drvctl/drvctl.c:1.6.16.1 --- src/sbin/drvctl/drvctl.c:1.6 Sun Jan 27 01:38:33 2008 +++ src/sbin/drvctl/drvctl.c Wed Apr 21 05:26:33 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.6 2008/01/27 01:38:33 dyoung Exp $ */ +/* $NetBSD: drvctl.c,v 1.6.16.1 2010/04/21 05:26:33 matt Exp $ */ /* * Copyright (c) 2004 @@ -26,6 +26,7 @@ * SUCH DAMAGE. */ +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -35,7 +36,7 @@ #include <sys/ioctl.h> #include <sys/drvctlio.h> -#define OPTS "QRSa:dlpr" +#define OPTS "QRSa:dlnpr" #define OPEN_MODE(mode) \ (((mode) == 'd' || (mode) == 'r') ? O_RDWR \ @@ -49,7 +50,7 @@ fprintf(stderr, "Usage: %s -r [-a attribute] busdevice [locator ...]\n" " %s -d device\n" - " %s -l device\n" + " %s [-n] -l [device]\n" " %s -p device\n" " %s -Q device\n" " %s -R device\n" @@ -62,6 +63,7 @@ int main(int argc, char **argv) { + bool nflag = false; int c, mode; char *attr = 0; extern char *optarg; @@ -95,6 +97,9 @@ case 'a': attr = optarg; break; + case 'n': + nflag = true; + break; case '?': default: usage(); @@ -104,7 +109,7 @@ argc -= optind; argv += optind; - if (argc < 1 || mode == 0) + if ((argc < 1 && mode != 'l') || mode == 0) usage(); fd = open(DRVCTLDEV, OPEN_MODE(mode), 0); @@ -134,7 +139,10 @@ err(3, "DRVDETACHDEV"); break; case 'l': - strlcpy(laa.l_devname, argv[0], sizeof(laa.l_devname)); + if (argc == 0) + *laa.l_devname = '\0'; + else + strlcpy(laa.l_devname, argv[0], sizeof(laa.l_devname)); if (ioctl(fd, DRVLISTDEV, &laa) == -1) err(3, "DRVLISTDEV"); @@ -149,8 +157,13 @@ if (laa.l_children > children) err(6, "DRVLISTDEV: number of children grew"); - for (i = 0; i < laa.l_children; i++) - printf("%s %s\n", laa.l_devname, laa.l_childname[i]); + for (i = 0; i < (int)laa.l_children; i++) { + if (!nflag) { + printf("%s ", + (argc == 0) ? "root" : laa.l_devname); + } + printf("%s\n", laa.l_childname[i]); + } break; case 'r': memset(&raa, 0, sizeof(raa)); Index: src/sbin/fdisk/fdisk.c diff -u src/sbin/fdisk/fdisk.c:1.116.6.1 src/sbin/fdisk/fdisk.c:1.116.6.1.4.1 --- src/sbin/fdisk/fdisk.c:1.116.6.1 Mon Apr 20 23:16:45 2009 +++ src/sbin/fdisk/fdisk.c Wed Apr 21 05:26:33 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: fdisk.c,v 1.116.6.1 2009/04/20 23:16:45 snj Exp $ */ +/* $NetBSD: fdisk.c,v 1.116.6.1.4.1 2010/04/21 05:26:33 matt Exp $ */ /* * Mach Operating System @@ -39,7 +39,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fdisk.c,v 1.116.6.1 2009/04/20 23:16:45 snj Exp $"); +__RCSID("$NetBSD: fdisk.c,v 1.116.6.1.4.1 2010/04/21 05:26:33 matt Exp $"); #endif /* not lint */ #define MBRPTYPENAMES @@ -246,7 +246,7 @@ int read_s0(daddr_t, struct mbr_sector *); int write_mbr(void); int yesno(const char *, ...); -int decimal(const char *, int, int, int, int); +int64_t decimal(const char *, int64_t, int, int64_t, int64_t); #define DEC_SEC 1 /* asking for a sector number */ #define DEC_RND 2 /* round to end of first track */ #define DEC_RND_0 4 /* round 0 to size of a track */ @@ -2618,20 +2618,20 @@ return (first == 'y' || first == 'Y'); } -int -decimal(const char *prompt, int dflt, int flags, int minval, int maxval) +int64_t +decimal(const char *prompt, int64_t dflt, int flags, int64_t minval, int64_t maxval) { - int acc = 0; + int64_t acc = 0; char *cp; char ch; for (;;) { if (flags & DEC_SEC) { - printf("%s: [%d..%dcyl default: %d, %dcyl, %uMB] ", + printf("%s: [%" PRId64 "..%" PRId64 "dcyl default: %" PRId64 ", %" PRId64 "dcyl, %uMB] ", prompt, SEC_TO_CYL(minval), SEC_TO_CYL(maxval), dflt, SEC_TO_CYL(dflt), SEC_TO_MB(dflt)); } else - printf("%s: [%d..%d default: %d] ", + printf("%s: [%" PRId64 "..%" PRId64 " default: %" PRId64 "] ", prompt, minval, maxval, dflt); if (!fgets(lbuf, LBUF, stdin)) @@ -2647,7 +2647,7 @@ return maxval; if (isdigit((unsigned char)*cp) || *cp == '-') { - acc = strtol(lbuf, &cp, 10); + acc = strtoll(lbuf, &cp, 10); if (flags & DEC_SEC) { ch = *cp; if (ch == 'g' || ch == 'G') { @@ -2686,7 +2686,7 @@ if (acc >= minval && acc <= maxval) return acc; - printf("%d is not between %d and %d.\n", acc, minval, maxval); + printf("%" PRId64 " is not between %" PRId64 " and %" PRId64 ".\n", acc, minval, maxval); } } Index: src/sbin/fsck_ext2fs/main.c diff -u src/sbin/fsck_ext2fs/main.c:1.32 src/sbin/fsck_ext2fs/main.c:1.32.8.1 --- src/sbin/fsck_ext2fs/main.c:1.32 Sun Oct 12 20:49:43 2008 +++ src/sbin/fsck_ext2fs/main.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.32 2008/10/12 20:49:43 wiz Exp $ */ +/* $NetBSD: main.c,v 1.32.8.1 2010/04/21 05:26:34 matt Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -68,7 +68,7 @@ #if 0 static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94"; #else -__RCSID("$NetBSD: main.c,v 1.32 2008/10/12 20:49:43 wiz Exp $"); +__RCSID("$NetBSD: main.c,v 1.32.8.1 2010/04/21 05:26:34 matt Exp $"); #endif #endif /* not lint */ @@ -107,7 +107,7 @@ sync(); skipclean = 1; - while ((ch = getopt(argc, argv, "b:dfm:npqUy")) != -1) { + while ((ch = getopt(argc, argv, "b:dfm:npPqUy")) != -1) { switch (ch) { case 'b': skipclean = 0; Index: src/sbin/fsck_ffs/extern.h diff -u src/sbin/fsck_ffs/extern.h:1.24 src/sbin/fsck_ffs/extern.h:1.24.8.1 --- src/sbin/fsck_ffs/extern.h:1.24 Sat Aug 30 10:46:16 2008 +++ src/sbin/fsck_ffs/extern.h Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.24 2008/08/30 10:46:16 bouyer Exp $ */ +/* $NetBSD: extern.h,v 1.24.8.1 2010/04/21 05:26:34 matt Exp $ */ /* * Copyright (c) 1994 James A. Jegers @@ -82,6 +82,7 @@ int setup(const char *, const char *); void voidquit(int); +int check_wapbl(void); void replay_wapbl(void); void cleanup_wapbl(void); int read_wapbl(char *, long, daddr_t); Index: src/sbin/fsck_ffs/setup.c diff -u src/sbin/fsck_ffs/setup.c:1.84 src/sbin/fsck_ffs/setup.c:1.84.8.1 --- src/sbin/fsck_ffs/setup.c:1.84 Sat Aug 30 10:46:16 2008 +++ src/sbin/fsck_ffs/setup.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: setup.c,v 1.84 2008/08/30 10:46:16 bouyer Exp $ */ +/* $NetBSD: setup.c,v 1.84.8.1 2010/04/21 05:26:34 matt Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95"; #else -__RCSID("$NetBSD: setup.c,v 1.84 2008/08/30 10:46:16 bouyer Exp $"); +__RCSID("$NetBSD: setup.c,v 1.84.8.1 2010/04/21 05:26:34 matt Exp $"); #endif #endif /* not lint */ @@ -173,24 +173,35 @@ doskipclean = 0; pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag); } - if (sblock->fs_flags & FS_DOWAPBL) { - if (preen) { + /* ffs_superblock_layout() == 2 */ + if (sblock->fs_magic != FS_UFS1_MAGIC || + (sblock->fs_old_flags & FS_FLAGS_UPDATED) != 0) { + /* can have WAPBL */ + if (check_wapbl() != 0) { + doskipclean = 0; + } + if (sblock->fs_flags & FS_DOWAPBL) { + if (preen) { + if (!quiet) + pwarn("file system is journaled; " + "not checking\n"); + return (-1); + } if (!quiet) - pwarn("file system is journaled; not checking\n"); - return (-1); + pwarn("** File system is journaled; " + "replaying journal\n"); + replay_wapbl(); + doskipclean = 0; + sblock->fs_flags &= ~FS_DOWAPBL; + sbdirty(); + /* Although we may have updated the superblock from + * the journal, we are still going to do a full check, + * so we don't bother to re-read the superblock from + * the journal. + * XXX, instead we could re-read the superblock and + * then not force doskipclean = 0 + */ } - if (!quiet) - pwarn("** File system is journaled; replaying journal\n"); - replay_wapbl(); - doskipclean = 0; - sblock->fs_flags &= ~FS_DOWAPBL; - sbdirty(); - /* Although we may have updated the superblock from the - * journal, we are still going to do a full check, so we - * don't bother to re-read the superblock from the journal. - * XXX, instead we could re-read the superblock and then not - * force doskipclean = 0 - */ } if (debug) printf("clean = %d\n", sblock->fs_clean); Index: src/sbin/fsck_ffs/wapbl.c diff -u src/sbin/fsck_ffs/wapbl.c:1.2 src/sbin/fsck_ffs/wapbl.c:1.2.10.1 --- src/sbin/fsck_ffs/wapbl.c:1.2 Thu Jul 31 05:38:04 2008 +++ src/sbin/fsck_ffs/wapbl.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wapbl.c,v 1.2 2008/07/31 05:38:04 simonb Exp $ */ +/* $NetBSD: wapbl.c,v 1.2.10.1 2010/04/21 05:26:34 matt Exp $ */ /*- * Copyright (c) 2005,2008 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wapbl.c,v 1.2 2008/07/31 05:38:04 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wapbl.c,v 1.2.10.1 2010/04/21 05:26:34 matt Exp $"); #include <sys/stat.h> #include <sys/time.h> @@ -89,60 +89,8 @@ void replay_wapbl(void) { - uint64_t addr, count, blksize; int error; - if (debug) - wapbl_debug_print = WAPBL_PRINT_ERROR | WAPBL_PRINT_REPLAY; - if (debug > 1) - wapbl_debug_print |= WAPBL_PRINT_IO; - - if (sblock->fs_journal_version != UFS_WAPBL_VERSION) { - pfatal("INVALID JOURNAL VERSION %d", - sblock->fs_journal_version); - if (reply("CONTINUE") == 0) { - exit(FSCK_EXIT_CHECK_FAILED); - } - return; - } - - switch (sblock->fs_journal_location) { - case UFS_WAPBL_JOURNALLOC_NONE: - pfatal("INVALID JOURNAL LOCATION 'NONE'"); - if (reply("CONTINUE") == 0) { - exit(FSCK_EXIT_CHECK_FAILED); - } - return; - - case UFS_WAPBL_JOURNALLOC_END_PARTITION: - addr = sblock->fs_journallocs[UFS_WAPBL_EPART_ADDR]; - count = sblock->fs_journallocs[UFS_WAPBL_EPART_COUNT]; - blksize = sblock->fs_journallocs[UFS_WAPBL_EPART_BLKSZ]; - break; - - case UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM: - addr = sblock->fs_journallocs[UFS_WAPBL_INFS_ADDR]; - count = sblock->fs_journallocs[UFS_WAPBL_INFS_COUNT]; - blksize = sblock->fs_journallocs[UFS_WAPBL_INFS_BLKSZ]; - break; - - default: - pfatal("INVALID JOURNAL LOCATION %d", - sblock->fs_journal_location); - if (reply("CONTINUE") == 0) { - exit(FSCK_EXIT_CHECK_FAILED); - } - return; - } - - error = wapbl_replay_start(&wapbl_replay, 0, addr, count, blksize); - if (error) { - pfatal("UNABLE TO READ JOURNAL FOR REPLAY"); - if (reply("CONTINUE") == 0) { - exit(FSCK_EXIT_CHECK_FAILED); - } - return; - } if (!nflag) { error = wapbl_replay_write(wapbl_replay, 0); if (error) { @@ -200,3 +148,125 @@ return 0; } + +int +check_wapbl(void) +{ + uint64_t addr = 0, count = 0, blksize = 0; + int error; + int ret = 0; + if (debug) + wapbl_debug_print = WAPBL_PRINT_ERROR | WAPBL_PRINT_REPLAY; + if (debug > 1) + wapbl_debug_print |= WAPBL_PRINT_IO; + + if (sblock->fs_flags & FS_DOWAPBL) { + if (sblock->fs_journal_version != UFS_WAPBL_VERSION) { + pfatal("INVALID JOURNAL VERSION %d", + sblock->fs_journal_version); + if (reply("CONTINUE") == 0) { + exit(FSCK_EXIT_CHECK_FAILED); + } + pwarn("CLEARING EXISTING JOURNAL\n"); + sblock->fs_flags &= ~FS_DOWAPBL; + sbdirty(); + ret = FSCK_EXIT_CHECK_FAILED; + } else { + switch(sblock->fs_journal_location) { + case UFS_WAPBL_JOURNALLOC_END_PARTITION: + addr = + sblock->fs_journallocs[UFS_WAPBL_EPART_ADDR]; + count = + sblock->fs_journallocs[UFS_WAPBL_EPART_COUNT]; + blksize = + sblock->fs_journallocs[UFS_WAPBL_EPART_BLKSZ]; + break; + case UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM: + addr = + sblock->fs_journallocs[UFS_WAPBL_INFS_ADDR]; + count = + sblock->fs_journallocs[UFS_WAPBL_INFS_COUNT]; + blksize = + sblock->fs_journallocs[UFS_WAPBL_INFS_BLKSZ]; + break; + default: + pfatal("INVALID JOURNAL LOCATION %d", + sblock->fs_journal_location); + if (reply("CONTINUE") == 0) { + exit(FSCK_EXIT_CHECK_FAILED); + } + pwarn("CLEARING EXISTING JOURNAL\n"); + sblock->fs_flags &= ~FS_DOWAPBL; + sblock->fs_journal_location = + UFS_WAPBL_JOURNALLOC_NONE; + sbdirty(); + ret = FSCK_EXIT_CHECK_FAILED; + break; + } + if (sblock->fs_flags & FS_DOWAPBL) { + error = wapbl_replay_start( + &wapbl_replay, 0, addr, count, blksize); + if (error) { + pfatal( + "UNABLE TO READ JOURNAL FOR REPLAY"); + if (reply("CONTINUE") == 0) { + exit(FSCK_EXIT_CHECK_FAILED); + } + pwarn("CLEARING EXISTING JOURNAL\n"); + sblock->fs_flags &= ~FS_DOWAPBL; + sbdirty(); + ret = FSCK_EXIT_CHECK_FAILED; + } + } + } + } + /* + * at this time fs_journal_flags can only be 0, + * UFS_WAPBL_FLAGS_CREATE_LOG or UFS_WAPBL_FLAGS_CLEAR_LOG. + * We can't have both flags at the same time. + */ + switch (sblock->fs_journal_flags) { + case 0: + break; + case UFS_WAPBL_FLAGS_CREATE_LOG: + case UFS_WAPBL_FLAGS_CLEAR_LOG: + switch(sblock->fs_journal_location) { + case UFS_WAPBL_JOURNALLOC_END_PARTITION: + case UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM: + break; + case UFS_WAPBL_JOURNALLOC_NONE: + if (sblock->fs_journal_flags == + UFS_WAPBL_FLAGS_CLEAR_LOG) + break; + /* FALLTHROUGH */ + default: + pfatal("INVALID JOURNAL LOCATION %d", + sblock->fs_journal_location); + if (reply("CONTINUE") == 0) { + exit(FSCK_EXIT_CHECK_FAILED); + } + pwarn("CLEARING JOURNAL FLAGS\n"); + sblock->fs_journal_flags = 0; + sblock->fs_journal_location = + UFS_WAPBL_JOURNALLOC_NONE; + sbdirty(); + ret = FSCK_EXIT_CHECK_FAILED; + break; + } + break; + default: + pfatal("INVALID JOURNAL FLAGS %d", + sblock->fs_journal_flags); + if (reply("CONTINUE") == 0) { + exit(FSCK_EXIT_CHECK_FAILED); + } + pwarn("CLEARING JOURNAL FLAGS\n"); + sblock->fs_journal_flags = 0; + sblock->fs_journal_location = + UFS_WAPBL_JOURNALLOC_NONE; + sbdirty(); + ret = FSCK_EXIT_CHECK_FAILED; + break; + } + return ret; +} Index: src/sbin/ifconfig/af_link.c diff -u src/sbin/ifconfig/af_link.c:1.3 src/sbin/ifconfig/af_link.c:1.3.8.1 --- src/sbin/ifconfig/af_link.c:1.3 Wed Jul 2 07:44:14 2008 +++ src/sbin/ifconfig/af_link.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: af_link.c,v 1.3 2008/07/02 07:44:14 dyoung Exp $ */ +/* $NetBSD: af_link.c,v 1.3.8.1 2010/04/21 05:26:34 matt Exp $ */ /*- * Copyright (c) 2008 David Young. All rights reserved. @@ -27,7 +27,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: af_link.c,v 1.3 2008/07/02 07:44:14 dyoung Exp $"); +__RCSID("$NetBSD: af_link.c,v 1.3.8.1 2010/04/21 05:26:34 matt Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -74,56 +74,7 @@ static void link_status(prop_dictionary_t env, prop_dictionary_t oenv, bool force) { - const char *delim, *ifname; - int i, s; - struct ifaddrs *ifa, *ifap; - const struct sockaddr_dl *sdl; - struct if_laddrreq iflr; - const uint8_t *octets; - - if ((ifname = getifname(env)) == NULL) - err(EXIT_FAILURE, "%s: getifname", __func__); - - if ((s = getsock(AF_LINK)) == -1) - err(EXIT_FAILURE, "%s: getsock", __func__); - - if (getifaddrs(&ifap) == -1) - err(EXIT_FAILURE, "%s: getifaddrs", __func__); - - memset(&iflr, 0, sizeof(iflr)); - - strlcpy(iflr.iflr_name, ifname, sizeof(iflr.iflr_name)); - - for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { - if (strcmp(ifname, ifa->ifa_name) != 0) - continue; - if (ifa->ifa_addr->sa_family != AF_LINK) - continue; - if (ifa->ifa_data != NULL) - continue; - - sdl = satocsdl(ifa->ifa_addr); - - memcpy(&iflr.addr, ifa->ifa_addr, MIN(ifa->ifa_addr->sa_len, - sizeof(iflr.addr))); - iflr.flags = IFLR_PREFIX; - iflr.prefixlen = sdl->sdl_alen * NBBY; - - if (ioctl(s, SIOCGLIFADDR, &iflr) == -1) - err(EXIT_FAILURE, "%s: ioctl", __func__); - - if ((iflr.flags & IFLR_ACTIVE) != 0) - continue; - - octets = (const uint8_t *)&sdl->sdl_data[sdl->sdl_nlen]; - - delim = "\tlink "; - for (i = 0; i < sdl->sdl_alen; i++) { - printf("%s%02" PRIx8, delim, octets[i]); - delim = ":"; - } - printf("\n"); - } + print_link_addresses(env, false); } static int Index: src/sbin/ifconfig/ifconfig.8 diff -u src/sbin/ifconfig/ifconfig.8:1.94 src/sbin/ifconfig/ifconfig.8:1.94.8.1 --- src/sbin/ifconfig/ifconfig.8:1.94 Tue Sep 30 09:41:41 2008 +++ src/sbin/ifconfig/ifconfig.8 Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: ifconfig.8,v 1.94 2008/09/30 09:41:41 wiz Exp $ +.\" $NetBSD: ifconfig.8,v 1.94.8.1 2010/04/21 05:26:34 matt Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. Index: src/sbin/ifconfig/ifconfig.c diff -u src/sbin/ifconfig/ifconfig.c:1.213.2.1 src/sbin/ifconfig/ifconfig.c:1.213.2.1.4.1 --- src/sbin/ifconfig/ifconfig.c:1.213.2.1 Sat Apr 4 18:22:54 2009 +++ src/sbin/ifconfig/ifconfig.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ifconfig.c,v 1.213.2.1 2009/04/04 18:22:54 snj Exp $ */ +/* $NetBSD: ifconfig.c,v 1.213.2.1.4.1 2010/04/21 05:26:34 matt Exp $ */ /*- * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1983, 1993\ The Regents of the University of California. All rights reserved."); -__RCSID("$NetBSD: ifconfig.c,v 1.213.2.1 2009/04/04 18:22:54 snj Exp $"); +__RCSID("$NetBSD: ifconfig.c,v 1.213.2.1.4.1 2010/04/21 05:26:34 matt Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -126,7 +126,7 @@ static int setifmtu(prop_dictionary_t, prop_dictionary_t); static int setifnetmask(prop_dictionary_t, prop_dictionary_t); static int setifprefixlen(prop_dictionary_t, prop_dictionary_t); -static void status(const struct sockaddr_dl *, prop_dictionary_t, +static void status(const struct sockaddr *, prop_dictionary_t, prop_dictionary_t); static void usage(void); @@ -724,7 +724,7 @@ { struct ifaddrs *ifap, *ifa; struct ifreq ifr; - const struct sockaddr_dl *sdl = NULL; + const struct sockaddr *sdl = NULL; prop_dictionary_t env, oenv; int idx; char *p; @@ -754,7 +754,7 @@ if (ifname != NULL && strcmp(ifname, ifa->ifa_name) != 0) continue; if (ifa->ifa_addr->sa_family == AF_LINK) - sdl = (const struct sockaddr_dl *) ifa->ifa_addr; + sdl = ifa->ifa_addr; if (p && strcmp(p, ifa->ifa_name) == 0) continue; if (!prop_dictionary_set_cstring(env, "if", ifa->ifa_name)) @@ -1144,7 +1144,7 @@ * specified, show it and it only; otherwise, show them all. */ void -status(const struct sockaddr_dl *sdl, prop_dictionary_t env, +status(const struct sockaddr *sdl, prop_dictionary_t env, prop_dictionary_t oenv) { const struct if_data *ifi; @@ -1152,7 +1152,6 @@ statistics_func_t *statistics_f; struct ifdatareq ifdr; struct ifreq ifr; - char hbuf[NI_MAXHOST]; char fbuf[BUFSIZ]; int af, s; const char *ifname; @@ -1202,11 +1201,7 @@ SIMPLEQ_FOREACH(status_f, &status_funcs, f_next) (*status_f->f_func)(env, oenv); - if (sdl != NULL && - getnameinfo((const struct sockaddr *)sdl, sdl->sdl_len, - hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) == 0 && - hbuf[0] != '\0') - printf("\taddress: %s\n", hbuf); + print_link_addresses(env, true); media_status(env, oenv); @@ -1215,7 +1210,7 @@ estrlcpy(ifdr.ifdr_name, ifname, sizeof(ifdr.ifdr_name)); - if (ioctl(s, zflag ? SIOCZIFDATA:SIOCGIFDATA, &ifdr) == -1) + if (ioctl(s, zflag ? SIOCZIFDATA : SIOCGIFDATA, &ifdr) == -1) err(EXIT_FAILURE, zflag ? "SIOCZIFDATA" : "SIOCGIFDATA"); ifi = &ifdr.ifdr_data; Index: src/sbin/ifconfig/parse.c diff -u src/sbin/ifconfig/parse.c:1.12 src/sbin/ifconfig/parse.c:1.12.6.1 --- src/sbin/ifconfig/parse.c:1.12 Fri Aug 1 22:29:14 2008 +++ src/sbin/ifconfig/parse.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.12 2008/08/01 22:29:14 dyoung Exp $ */ +/* $NetBSD: parse.c,v 1.12.6.1 2010/04/21 05:26:34 matt Exp $ */ /*- * Copyright (c) 2008 David Young. All rights reserved. @@ -27,7 +27,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: parse.c,v 1.12 2008/08/01 22:29:14 dyoung Exp $"); +__RCSID("$NetBSD: parse.c,v 1.12.6.1 2010/04/21 05:26:34 matt Exp $"); #endif /* not lint */ #include <err.h> @@ -685,8 +685,7 @@ o = u->u_obj; break; case KW_T_STR: - o = (prop_object_t)prop_data_create_data_nocopy(u->u_str, - strlen(u->u_str)); + o = (prop_object_t)prop_string_create_cstring_nocopy(u->u_str); if (o == NULL) goto err; break; Index: src/sbin/ifconfig/util.c diff -u src/sbin/ifconfig/util.c:1.8 src/sbin/ifconfig/util.c:1.8.6.1 --- src/sbin/ifconfig/util.c:1.8 Wed Jul 2 07:44:15 2008 +++ src/sbin/ifconfig/util.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.8 2008/07/02 07:44:15 dyoung Exp $ */ +/* $NetBSD: util.c,v 1.8.6.1 2010/04/21 05:26:34 matt Exp $ */ /*- * Copyright (c) 2008 David Young. All rights reserved. @@ -27,12 +27,13 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: util.c,v 1.8 2008/07/02 07:44:15 dyoung Exp $"); +__RCSID("$NetBSD: util.c,v 1.8.6.1 2010/04/21 05:26:34 matt Exp $"); #endif /* not lint */ #include <ctype.h> #include <err.h> #include <errno.h> +#include <netdb.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> @@ -40,9 +41,14 @@ #include <unistd.h> #include <util.h> +#include <sys/param.h> +#include <sys/types.h> #include <sys/socket.h> +#include <ifaddrs.h> + #include <sys/ioctl.h> #include <net/if.h> +#include <net/if_dl.h> #include <netinet/in.h> /* XXX */ #include "env.h" @@ -230,6 +236,58 @@ return direct_ioctl(env, cmd, &ifr); } +void +print_link_addresses(prop_dictionary_t env, bool print_active_only) +{ + char hbuf[NI_MAXHOST]; + const char *ifname; + int s; + struct ifaddrs *ifa, *ifap; + const struct sockaddr_dl *sdl; + struct if_laddrreq iflr; + + if ((ifname = getifname(env)) == NULL) + err(EXIT_FAILURE, "%s: getifname", __func__); + + if ((s = getsock(AF_LINK)) == -1) + err(EXIT_FAILURE, "%s: getsock", __func__); + + if (getifaddrs(&ifap) == -1) + err(EXIT_FAILURE, "%s: getifaddrs", __func__); + + memset(&iflr, 0, sizeof(iflr)); + + strlcpy(iflr.iflr_name, ifname, sizeof(iflr.iflr_name)); + + for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { + if (strcmp(ifname, ifa->ifa_name) != 0) + continue; + if (ifa->ifa_addr->sa_family != AF_LINK) + continue; + + sdl = satocsdl(ifa->ifa_addr); + + memcpy(&iflr.addr, ifa->ifa_addr, MIN(ifa->ifa_addr->sa_len, + sizeof(iflr.addr))); + iflr.flags = IFLR_PREFIX; + iflr.prefixlen = sdl->sdl_alen * NBBY; + + if (ioctl(s, SIOCGLIFADDR, &iflr) == -1) + err(EXIT_FAILURE, "%s: ioctl", __func__); + + if (((iflr.flags & IFLR_ACTIVE) != 0) != print_active_only) + continue; + + if (getnameinfo(ifa->ifa_addr, ifa->ifa_addr->sa_len, + hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) == 0 && + hbuf[0] != '\0') { + printf("\t%s %s\n", + print_active_only ? "address:" : "link", hbuf); + } + } + freeifaddrs(ifap); +} + #ifdef INET6 /* KAME idiosyncrasy */ void Index: src/sbin/ifconfig/util.h diff -u src/sbin/ifconfig/util.h:1.6 src/sbin/ifconfig/util.h:1.6.8.1 --- src/sbin/ifconfig/util.h:1.6 Wed Jul 2 07:44:15 2008 +++ src/sbin/ifconfig/util.h Wed Apr 21 05:26:34 2010 @@ -13,6 +13,7 @@ SIMPLEQ_ENTRY(afswtch) af_next; }; +void print_link_addresses(prop_dictionary_t, bool); const char *get_string(const char *, const char *, u_int8_t *, int *); const struct afswtch *lookup_af_byname(const char *); const struct afswtch *lookup_af_bynum(int); Index: src/sbin/ifconfig/vlan.c diff -u src/sbin/ifconfig/vlan.c:1.12 src/sbin/ifconfig/vlan.c:1.12.8.1 --- src/sbin/ifconfig/vlan.c:1.12 Tue Jul 15 21:27:58 2008 +++ src/sbin/ifconfig/vlan.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: vlan.c,v 1.12 2008/07/15 21:27:58 dyoung Exp $ */ +/* $NetBSD: vlan.c,v 1.12.8.1 2010/04/21 05:26:34 matt Exp $ */ /* * Copyright (c) 1983, 1993 @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: vlan.c,v 1.12 2008/07/15 21:27:58 dyoung Exp $"); +__RCSID("$NetBSD: vlan.c,v 1.12.8.1 2010/04/21 05:26:34 matt Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -140,17 +140,17 @@ if (getvlan(env, &vlr, false) == -1) err(EXIT_FAILURE, "%s: getsock", __func__); - if (!prop_dictionary_get_int64(env, "vlantag", &tag)) { - errno = ENOENT; - return -1; - } - if (!prop_dictionary_get_cstring_nocopy(env, "vlanif", &parent)) { errno = ENOENT; return -1; } strlcpy(vlr.vlr_parent, parent, sizeof(vlr.vlr_parent)); - if (strcmp(parent, "") != 0) + if (strcmp(parent, "") == 0) + ; + else if (!prop_dictionary_get_int64(env, "vlantag", &tag)) { + errno = ENOENT; + return -1; + } else vlr.vlr_tag = (unsigned short)tag; if (indirect_ioctl(env, SIOCSETVLAN, &vlr) == -1) Index: src/sbin/newfs/newfs.c diff -u src/sbin/newfs/newfs.c:1.102 src/sbin/newfs/newfs.c:1.102.8.1 --- src/sbin/newfs/newfs.c:1.102 Fri Aug 1 15:32:30 2008 +++ src/sbin/newfs/newfs.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs.c,v 1.102 2008/08/01 15:32:30 simonb Exp $ */ +/* $NetBSD: newfs.c,v 1.102.8.1 2010/04/21 05:26:34 matt Exp $ */ /* * Copyright (c) 1983, 1989, 1993, 1994 @@ -78,7 +78,7 @@ #if 0 static char sccsid[] = "@(#)newfs.c 8.13 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: newfs.c,v 1.102 2008/08/01 15:32:30 simonb Exp $"); +__RCSID("$NetBSD: newfs.c,v 1.102.8.1 2010/04/21 05:26:34 matt Exp $"); #endif #endif /* not lint */ @@ -468,6 +468,10 @@ special = device; if (fsi < 0 || fstat(fsi, &sb) == -1) err(1, "%s: open for read", special); + if (S_ISBLK(sb.st_mode)) { + errx(1, "%s is a block device. use raw device", + special); + } if (!Nflag) { fso = open(special, O_WRONLY, 0); Index: src/sbin/newfs_msdos/newfs_msdos.c diff -u src/sbin/newfs_msdos/newfs_msdos.c:1.27.2.2 src/sbin/newfs_msdos/newfs_msdos.c:1.27.2.2.4.1 --- src/sbin/newfs_msdos/newfs_msdos.c:1.27.2.2 Mon Feb 2 20:52:42 2009 +++ src/sbin/newfs_msdos/newfs_msdos.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs_msdos.c,v 1.27.2.2 2009/02/02 20:52:42 snj Exp $ */ +/* $NetBSD: newfs_msdos.c,v 1.27.2.2.4.1 2010/04/21 05:26:34 matt Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,7 +33,7 @@ static const char rcsid[] = "$FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $"; #else -__RCSID("$NetBSD: newfs_msdos.c,v 1.27.2.2 2009/02/02 20:52:42 snj Exp $"); +__RCSID("$NetBSD: newfs_msdos.c,v 1.27.2.2.4.1 2010/04/21 05:26:34 matt Exp $"); #endif #endif /* not lint */ @@ -800,7 +800,7 @@ if (!bpb->hds) bpb->hds = ckgeom(fname, geo.dg_ntracks, "drive heads"); if (!bpb->bsec) - bpb->bsec = geo.dg_secperunit; + bpb->bsec = dkw.dkw_size; } } Index: src/sbin/newfs_udf/newfs_udf.8 diff -u src/sbin/newfs_udf/newfs_udf.8:1.4.4.1 src/sbin/newfs_udf/newfs_udf.8:1.4.4.1.4.1 --- src/sbin/newfs_udf/newfs_udf.8:1.4.4.1 Wed Feb 18 00:37:00 2009 +++ src/sbin/newfs_udf/newfs_udf.8 Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: newfs_udf.8,v 1.4.4.1 2009/02/18 00:37:00 snj Exp $ +.\" $NetBSD: newfs_udf.8,v 1.4.4.1.4.1 2010/04/21 05:26:34 matt Exp $ .\" .\" Copyright (c) 2008 Reinoud Zandijk .\" All rights reserved. @@ -70,7 +70,7 @@ .Ar setlabel . For strict conformance and interchange, don't set this manually. .It Fl M -Disable metadata partion creation when selected UDF version or media dictates +Disable metadata partition creation when selected UDF version or media dictates this. For strict conformance and interchange, don't disable this unless its causing problems. .It Fl s Ar size Index: src/sbin/newfs_udf/udf_create.c diff -u src/sbin/newfs_udf/udf_create.c:1.12.4.2 src/sbin/newfs_udf/udf_create.c:1.12.4.2.4.1 --- src/sbin/newfs_udf/udf_create.c:1.12.4.2 Wed Feb 18 00:37:00 2009 +++ src/sbin/newfs_udf/udf_create.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: udf_create.c,v 1.12.4.2 2009/02/18 00:37:00 snj Exp $ */ +/* $NetBSD: udf_create.c,v 1.12.4.2.4.1 2010/04/21 05:26:34 matt Exp $ */ /* * Copyright (c) 2006, 2008 Reinoud Zandijk @@ -28,7 +28,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: udf_create.c,v 1.12.4.2 2009/02/18 00:37:00 snj Exp $"); +__RCSID("$NetBSD: udf_create.c,v 1.12.4.2.4.1 2010/04/21 05:26:34 matt Exp $"); #endif /* not lint */ #include <stdio.h> @@ -309,7 +309,7 @@ printf("\tsparable size\t\t%d\n", layout.sparable_area_size); printf("\tsparable\t\t%d\n", layout.sparable_area); } - printf("\tpartion start lba\t%d\n", layout.part_start_lba); + printf("\tpartition start lba\t%d\n", layout.part_start_lba); printf("\tpartition size\t\t%d KiB, %d MiB\n", (layout.part_size_lba * sector_size) / 1024, (layout.part_size_lba * sector_size) / (1024*1024)); @@ -782,7 +782,7 @@ context.part_size[log_part] = layout.part_size_lba; context.part_free[log_part] = layout.part_size_lba; - /* increment number of partions and length */ + /* increment number of partitions and length */ logvol->n_pm = udf_rw32(log_part + 1); logvol->mt_l = udf_rw32(udf_rw32(logvol->mt_l) + pmap1_size); @@ -820,7 +820,7 @@ context.part_size[log_part] = 0xffffffff; context.part_free[log_part] = 0xffffffff; - /* increment number of partions and length */ + /* increment number of partitions and length */ logvol->n_pm = udf_rw32(log_part + 1); logvol->mt_l = udf_rw32(udf_rw32(logvol->mt_l) + pmapv_size); @@ -875,7 +875,7 @@ context.part_size[log_part] = layout.part_size_lba; context.part_free[log_part] = layout.part_size_lba; - /* increment number of partions and length */ + /* increment number of partitions and length */ logvol->n_pm = udf_rw32(log_part + 1); logvol->mt_l = udf_rw32(udf_rw32(logvol->mt_l) + pmaps_size); @@ -962,7 +962,7 @@ context.part_size[log_part] = layout.meta_part_size_lba; context.part_free[log_part] = layout.meta_part_size_lba; - /* increment number of partions and length */ + /* increment number of partitions and length */ logvol->n_pm = udf_rw32(log_part + 1); logvol->mt_l = udf_rw32(udf_rw32(logvol->mt_l) + pmapv_size); @@ -1055,7 +1055,7 @@ assert(lvid); assert(logvol); - lvid->integrity_type = udf_rw16(type); + lvid->integrity_type = udf_rw32(type); num_partmappings = udf_rw32(logvol->n_pm); @@ -1298,7 +1298,7 @@ fid->file_char = UDF_FILE_CHAR_DIR | UDF_FILE_CHAR_PAR; fid->icb = *parent; fid->icb.longad_uniqueid = udf_rw32((uint32_t) unique_id); - fid->tag.desc_crc_len = fidsize - UDF_DESC_TAG_LENGTH; + fid->tag.desc_crc_len = udf_rw16(fidsize - UDF_DESC_TAG_LENGTH); /* we have to do the fid here explicitly for simplicity */ udf_validate_tag_and_crc_sums((union dscrptr *) fid); @@ -1792,7 +1792,7 @@ free(extattr); - /* writeout VAT locations (partion offsets) */ + /* writeout VAT locations (partition offsets) */ vat_pos = (uint32_t *) (fe->data + udf_rw32(fe->l_ea)); vat_pos[layout.rootdir] = udf_rw32(layout.rootdir); vat_pos[layout.fsd ] = udf_rw32(layout.fsd); Index: src/sbin/ping/ping.c diff -u src/sbin/ping/ping.c:1.87 src/sbin/ping/ping.c:1.87.16.1 --- src/sbin/ping/ping.c:1.87 Tue Jan 8 20:03:09 2008 +++ src/sbin/ping/ping.c Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ping.c,v 1.87 2008/01/08 20:03:09 seanb Exp $ */ +/* $NetBSD: ping.c,v 1.87.16.1 2010/04/21 05:26:34 matt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -58,7 +58,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: ping.c,v 1.87 2008/01/08 20:03:09 seanb Exp $"); +__RCSID("$NetBSD: ping.c,v 1.87.16.1 2010/04/21 05:26:34 matt Exp $"); #endif #include <stdio.h> @@ -155,6 +155,7 @@ u_char *packet; int packlen; int pingflags = 0, options; +int pongflags = 0; char *fill_pat; int s; /* Socket file descriptor */ @@ -1017,8 +1018,31 @@ if (tot_len != opack_ip->ip_len) { PR_PACK_SUB(); - (void)printf("\nwrong total length %d instead of %d", - tot_len, opack_ip->ip_len); + switch (opack_ip->ip_len - tot_len) { + case MAX_IPOPTLEN: + if ((pongflags & F_RECORD_ROUTE) != 0) + break; + if ((pingflags & F_RECORD_ROUTE) == 0) + goto out; + pongflags |= F_RECORD_ROUTE; + (void)printf("\nremote host does not " + "support record route"); + break; + case 8: + if ((pongflags & F_SOURCE_ROUTE) != 0) + break; + if ((pingflags & F_SOURCE_ROUTE) == 0) + goto out; + pongflags |= F_SOURCE_ROUTE; + (void)printf("\nremote host does not " + "support source route"); + break; + default: + out: + (void)printf("\nwrong total length %d " + "instead of %d", tot_len, opack_ip->ip_len); + break; + } } if (!dupflag) { Index: src/sbin/raidctl/raidctl.8 diff -u src/sbin/raidctl/raidctl.8:1.56 src/sbin/raidctl/raidctl.8:1.56.8.1 --- src/sbin/raidctl/raidctl.8:1.56 Thu Aug 28 21:24:30 2008 +++ src/sbin/raidctl/raidctl.8 Wed Apr 21 05:26:34 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: raidctl.8,v 1.56 2008/08/28 21:24:30 wiz Exp $ +.\" $NetBSD: raidctl.8,v 1.56.8.1 2010/04/21 05:26:34 matt Exp $ .\" .\" Copyright (c) 1998, 2002 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -53,7 +53,7 @@ .\" any improvements or extensions that they make and grant Carnegie the .\" rights to redistribute these changes. .\" -.Dd August 26, 2008 +.Dd November 17, 2009 .Dt RAIDCTL 8 .Os .Sh NAME @@ -96,6 +96,16 @@ .Fl I Ar serial_number Ar dev .Nm .Op Fl v +.Fl m Ar dev +.Nm +.Op Fl v +.Fl M +.Oo yes | no | set +.Ar params +.Oc +.Ar dev +.Nm +.Op Fl v .Fl p Ar dev .Nm .Op Fl v @@ -222,6 +232,44 @@ This step .Em MUST be performed when a new RAID set is created. +.It Fl m Ar dev +Display status information about the parity map on the RAID set, if any. +If used with +.Fl v +then the current contents of the parity map will be output (in +hexadecimal format) as well. +.It Fl M Ic yes Ar dev +.\"XXX should there be a section with more info on the parity map feature? +Enable the use of a parity map on the RAID set; this is the default, +and greatly reduces the time taken to check parity after unclean +shutdowns at the cost of some very slight overhead during normal +operation. +Changes to this setting will take effect the next time the set is +configured. +Note that RAID-0 sets, having no parity, will not use a parity map in +any case. +.It Fl M Ic no Ar dev +Disable the use of a parity map on the RAID set; doing this is not +recommended. +This will take effect the next time the set is configured. +.It Fl M Ic set Ar cooldown Ar tickms Ar regions Ar dev +Alter the parameters of the parity map; parameters to leave unchanged +can be given as 0, and trailing zeroes may be omitted. +.\"XXX should this explanation be deferred to another section as well? +The RAID set is divided into +.Ar regions +regions; each region is marked dirty for at most +.Ar cooldown +intervals of +.Ar tickms +milliseconds each after a write to it, and at least +.Ar cooldown +\- 1 such intervals. +Changes to +.Ar regions +take effect the next time is configured, while changes to the other +parameters are applied immediately. +The default parameters are expected to be reasonable for most workloads. .It Fl p Ar dev Check the status of the parity on the RAID set. Displays a status message, @@ -1396,7 +1444,7 @@ Since there are 4 data sectors per stripe, the maximum data per stripe is 64 blocks (32K) or 128 blocks (64K). Again, empirical measurement will provide the best indicators of which -values will yeild better performance. +values will yield better performance. .Pp The parameters used for the file system are also critical to good performance. For Index: src/sbin/raidctl/raidctl.c diff -u src/sbin/raidctl/raidctl.c:1.39.4.1 src/sbin/raidctl/raidctl.c:1.39.4.1.4.1 --- src/sbin/raidctl/raidctl.c:1.39.4.1 Sun Feb 1 23:41:37 2009 +++ src/sbin/raidctl/raidctl.c Wed Apr 21 05:26:35 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: raidctl.c,v 1.39.4.1 2009/02/01 23:41:37 snj Exp $ */ +/* $NetBSD: raidctl.c,v 1.39.4.1.4.1 2010/04/21 05:26:35 matt Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: raidctl.c,v 1.39.4.1 2009/02/01 23:41:37 snj Exp $"); +__RCSID("$NetBSD: raidctl.c,v 1.39.4.1.4.1 2010/04/21 05:26:35 matt Exp $"); #endif @@ -82,13 +82,15 @@ static void do_meter(int, u_long); static void get_bar(char *, double, int); static void get_time_string(char *, int); +static void rf_output_pmstat(int, int); +static void rf_pm_configure(int, int, char *, int[]); int verbose; int main(int argc,char *argv[]) { - int ch; + int ch, i; int num_options; unsigned long action; char config_filename[PATH_MAX]; @@ -96,6 +98,8 @@ char name[PATH_MAX]; char component[PATH_MAX]; char autoconf[10]; + char *parityconf = NULL; + int parityparams[3]; int do_output; int do_recon; int do_rewrite; @@ -117,7 +121,7 @@ force = 0; openmode = O_RDWR; /* default to read/write */ - while ((ch = getopt(argc, argv, "a:A:Bc:C:f:F:g:GiI:l:r:R:sSpPuv")) + while ((ch = getopt(argc, argv, "a:A:Bc:C:f:F:g:GiI:l:mM:r:R:sSpPuv")) != -1) switch(ch) { case 'a': @@ -181,6 +185,23 @@ serial_number = atoi(optarg); num_options++; break; + case 'm': + action = RAIDFRAME_PARITYMAP_STATUS; + openmode = O_RDONLY; + num_options++; + break; + case 'M': + action = RAIDFRAME_PARITYMAP_SET_DISABLE; + parityconf = strdup(optarg); + num_options++; + /* XXXjld: should rf_pm_configure do the atoi()s? */ + i = 0; + while (i < 3 && optind < argc && + isdigit((int)argv[optind][0])) + parityparams[i++] = atoi(argv[optind++]); + while (i < 3) + parityparams[i++] = 0; + break; case 'l': action = RAIDFRAME_SET_COMPONENT_LABEL; strlcpy(component, optarg, sizeof(component)); @@ -308,6 +329,12 @@ else rf_get_device_status(fd); break; + case RAIDFRAME_PARITYMAP_STATUS: + rf_output_pmstat(fd, raidID); + break; + case RAIDFRAME_PARITYMAP_SET_DISABLE: + rf_pm_configure(fd, raidID, parityconf, parityparams); + break; case RAIDFRAME_REBUILD_IN_PLACE: rebuild_in_place(fd, component); break; @@ -455,6 +482,105 @@ } static void +rf_output_pmstat(int fd, int raidID) +{ + char srs[7]; + int i, j, dr; + int dis; + struct rf_pmstat st; + + do_ioctl(fd, RAIDFRAME_PARITYMAP_STATUS, &st, + "RAIDFRAME_PARITYMAP_STATUS"); + if (st.enabled) { + if (0 > humanize_number(srs, 7, st.region_size * DEV_BSIZE, + "B", HN_AUTOSCALE, HN_NOSPACE)) + strlcpy(srs, "???", 7); + + printf("raid%d: parity map enabled with %u regions of %s\n", + raidID, st.params.regions, srs); + printf("raid%d: regions marked clean after %d intervals of" + " %d.%03ds\n", raidID, st.params.cooldown, + st.params.tickms / 1000, st.params.tickms % 1000); + printf("raid%d: write/sync/clean counters " + "%"PRIu64"/%"PRIu64"/%"PRIu64"\n", raidID, + st.ctrs.nwrite, st.ctrs.ncachesync, st.ctrs.nclearing); + + dr = 0; + for (i = 0; i < RF_PARITYMAP_NREG; i++) + if (isset(st.dirty, i)) + dr++; + printf("raid%d: %d dirty region%s\n", raidID, dr, + dr == 1 ? "" : "s"); + + if (verbose > 0) { + for (i = 0; i < RF_PARITYMAP_NBYTE; i += 32) { + printf(" "); + for (j = i; j < RF_PARITYMAP_NBYTE + && j < i + 32; j++) + printf("%x%x", st.dirty[j] & 15, + (st.dirty[j] >> 4) & 15); + printf("\n"); + } + } + } else { + printf("raid%d: parity map disabled\n", raidID); + } + + do_ioctl(fd, RAIDFRAME_PARITYMAP_GET_DISABLE, &dis, + "RAIDFRAME_PARITYMAP_GET_DISABLE"); + printf("raid%d: parity map will %s %sabled on next configure\n", + raidID, dis == st.enabled ? "be" : "remain", dis ? "dis" : "en"); +} + +static void +rf_pm_configure(int fd, int raidID, char *parityconf, int parityparams[]) +{ + int dis; + struct rf_pmparams params; + + if (strcasecmp(parityconf, "yes") == 0) + dis = 0; + else if (strcasecmp(parityconf, "no") == 0) + dis = 1; + else if (strcasecmp(parityconf, "set") == 0) { + params.cooldown = parityparams[0]; + params.tickms = parityparams[1]; + params.regions = parityparams[2]; + + do_ioctl(fd, RAIDFRAME_PARITYMAP_SET_PARAMS, ¶ms, + "RAIDFRAME_PARITYMAP_SET_PARAMS"); + + if (params.cooldown != 0 || params.tickms != 0) { + printf("raid%d: parity cleaned after", raidID); + if (params.cooldown != 0) + printf(" %d", params.cooldown); + printf(" intervals"); + if (params.tickms != 0) { + printf(" of %d.%03ds", params.tickms / 1000, + params.tickms % 1000); + } + printf("\n"); + } + if (params.regions != 0) + printf("raid%d: will use %d regions on next" + " configuration\n", raidID, params.regions); + + return; + /* XXX the control flow here could be prettier. */ + } else { + fprintf(stderr, "%s: \"%s\" is not a valid parity map command" + "\n", getprogname(), parityconf); + exit(1); + } + + do_ioctl(fd, RAIDFRAME_PARITYMAP_SET_DISABLE, &dis, + "RAIDFRAME_PARITYMAP_SET_DISABLE"); + printf("raid%d: parity map will be %sabled on next configure\n", + raidID, dis ? "dis" : "en"); +} + + +static void rf_output_configuration(int fd, const char *name) { RF_DeviceConfig_t device_config; @@ -1022,7 +1148,7 @@ const char *progname = getprogname(); fprintf(stderr, "usage: %s [-v] -a component dev\n", progname); - fprintf(stderr, " %s [-v] -A yes | no | root dev\n", progname); + fprintf(stderr, " %s [-v] -A [yes | no | root] dev\n", progname); fprintf(stderr, " %s [-v] -B dev\n", progname); fprintf(stderr, " %s [-v] -c config_file dev\n", progname); fprintf(stderr, " %s [-v] -C config_file dev\n", progname); @@ -1032,6 +1158,9 @@ fprintf(stderr, " %s [-v] -G dev\n", progname); fprintf(stderr, " %s [-v] -i dev\n", progname); fprintf(stderr, " %s [-v] -I serial_number dev\n", progname); + fprintf(stderr, " %s [-v] -m dev\n", progname); + fprintf(stderr, " %s [-v] -M [yes | no | set params] dev\n", + progname); fprintf(stderr, " %s [-v] -p dev\n", progname); fprintf(stderr, " %s [-v] -P dev\n", progname); fprintf(stderr, " %s [-v] -r component dev\n", progname); Index: src/sbin/savecore/savecore.c diff -u src/sbin/savecore/savecore.c:1.76.2.1 src/sbin/savecore/savecore.c:1.76.2.1.4.1 --- src/sbin/savecore/savecore.c:1.76.2.1 Tue Mar 24 20:46:43 2009 +++ src/sbin/savecore/savecore.c Wed Apr 21 05:26:35 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: savecore.c,v 1.76.2.1 2009/03/24 20:46:43 snj Exp $ */ +/* $NetBSD: savecore.c,v 1.76.2.1.4.1 2010/04/21 05:26:35 matt Exp $ */ /*- * Copyright (c) 1986, 1992, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)savecore.c 8.5 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: savecore.c,v 1.76.2.1 2009/03/24 20:46:43 snj Exp $"); +__RCSID("$NetBSD: savecore.c,v 1.76.2.1.4.1 2010/04/21 05:26:35 matt Exp $"); #endif #endif /* not lint */ @@ -910,11 +910,9 @@ struct statvfs fsbuf; char mbuf[100], path[MAXPATHLEN]; - if (stat(kernel, &st) < 0) { - syslog(LOG_ERR, "%s: %m", kernel); - exit(1); - } - kernelsize = st.st_blocks * S_BLKSIZE; + /* XXX assume a reasonable default, unless we find a kernel. */ + kernelsize = 20 * 1024 * 1024; + if (!stat(kernel, &st)) kernelsize = st.st_blocks * S_BLKSIZE; if (statvfs(dirname, &fsbuf) < 0) { syslog(LOG_ERR, "%s: %m", dirname); exit(1); Index: src/sbin/tunefs/tunefs.c diff -u src/sbin/tunefs/tunefs.c:1.37 src/sbin/tunefs/tunefs.c:1.37.8.1 --- src/sbin/tunefs/tunefs.c:1.37 Thu Jul 31 15:55:41 2008 +++ src/sbin/tunefs/tunefs.c Wed Apr 21 05:26:35 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: tunefs.c,v 1.37 2008/07/31 15:55:41 simonb Exp $ */ +/* $NetBSD: tunefs.c,v 1.37.8.1 2010/04/21 05:26:35 matt Exp $ */ /* * Copyright (c) 1983, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)tunefs.c 8.3 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: tunefs.c,v 1.37 2008/07/31 15:55:41 simonb Exp $"); +__RCSID("$NetBSD: tunefs.c,v 1.37.8.1 2010/04/21 05:26:35 matt Exp $"); #endif #endif /* not lint */ @@ -345,7 +345,7 @@ printf("\n"); printf("\tjournal log flags:"); if (sblock.fs_journal_flags & UFS_WAPBL_FLAGS_CREATE_LOG) - printf(" clear-log"); + printf(" create-log"); if (sblock.fs_journal_flags & UFS_WAPBL_FLAGS_CLEAR_LOG) printf(" clear-log"); printf("\n"); @@ -389,15 +389,6 @@ break; } - if (!in_fs_log) - errx(1, "Can't change size of non-in-filesystem log"); - - if (old_size == logfilesize && logfilesize > 0) { - /* no action */ - warnx("log file size remains unchanged at %lld", logfilesize); - return; - } - if (logfilesize == 0) { /* * Don't clear out the locators - the kernel might need @@ -410,6 +401,15 @@ return; } + if (!in_fs_log && logfilesize > 0 && old_size > 0) + errx(1, "Can't change size of non-in-filesystem log"); + + if (old_size == logfilesize && logfilesize > 0) { + /* no action */ + warnx("log file size remains unchanged at %lld", logfilesize); + return; + } + if (old_size == 0) { /* create new log of desired size next mount */ sblock.fs_journal_location = UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM; Index: src/sbin/wsconsctl/wsconsctl.8 diff -u src/sbin/wsconsctl/wsconsctl.8:1.25.6.1 src/sbin/wsconsctl/wsconsctl.8:1.25.6.1.2.1 --- src/sbin/wsconsctl/wsconsctl.8:1.25.6.1 Sun Jul 26 18:52:48 2009 +++ src/sbin/wsconsctl/wsconsctl.8 Wed Apr 21 05:26:35 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: wsconsctl.8,v 1.25.6.1 2009/07/26 18:52:48 snj Exp $ +.\" $NetBSD: wsconsctl.8,v 1.25.6.1.2.1 2010/04/21 05:26:35 matt Exp $ .\" .\" Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. .\" All rights reserved.