CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Sat May 29 17:41:51 UTC 2021 Modified Files: src/sbin/disklabel: main.c Log Message: first check, then copy To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.55 src/sbin/disklabel/main.c:1.56 --- src/sbin/disklabel/main.c:1.55 Mon Sep 28 22:58:52 2020 +++ src/sbin/disklabel/main.c Sat May 29 13:41:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.55 2020/09/29 02:58:52 msaitoh Exp $ */ +/* $NetBSD: main.c,v 1.56 2021/05/29 17:41:51 christos Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.55 2020/09/29 02:58:52 msaitoh Exp $"); +__RCSID("$NetBSD: main.c,v 1.56 2021/05/29 17:41:51 christos Exp $"); #endif #endif /* not lint */ @@ -1238,9 +1238,9 @@ find_label(int f, u_int sector) if (i == LABEL_OFFSET) continue; disk_lp = (void *)(bootarea + offset); - memcpy(&tlp, disk_lp, sizeof(tlp)); if ((char *)(disk_lp + 1) > bootarea + bootarea_len) break; + memcpy(&tlp, disk_lp, sizeof(tlp)); if (tlp.d_magic2 != tlp.d_magic) continue; if (read_all && (tlp.d_magic == DISKMAGIC_DELETED ||
CVS commit: src/sbin/disklabel
Module Name:src Committed By: kamil Date: Wed Jun 27 01:14:48 UTC 2018 Modified Files: src/sbin/disklabel: main.c Log Message: Avoid misaligned access in disklabel(8) in find_label() Introduce a new helper variable tlp and use it for memory access. Detected with MKSANITIZER/UBSan A patch by To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.49 src/sbin/disklabel/main.c:1.50 --- src/sbin/disklabel/main.c:1.49 Sun Apr 1 04:35:02 2018 +++ src/sbin/disklabel/main.c Wed Jun 27 01:14:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.49 2018/04/01 04:35:02 ryo Exp $ */ +/* $NetBSD: main.c,v 1.50 2018/06/27 01:14:48 kamil Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.49 2018/04/01 04:35:02 ryo Exp $"); +__RCSID("$NetBSD: main.c,v 1.50 2018/06/27 01:14:48 kamil Exp $"); #endif #endif /* not lint */ @@ -1189,7 +1189,7 @@ readlabel(int f) static struct disklabel * find_label(int f, u_int sector) { - struct disklabel *disk_lp, hlp; + struct disklabel *disk_lp, hlp, tlp; int i; off_t offset; const char *is_deleted; @@ -1209,30 +1209,31 @@ find_label(int f, u_int sector) /* Check expected offset first */ for (offset = LABEL_OFFSET, i = -4;; offset = i += 4) { is_deleted = ""; - disk_lp = (void *)(bootarea + offset); if (i == LABEL_OFFSET) continue; + disk_lp = (void *)(bootarea + offset); + memcpy(&tlp, disk_lp, sizeof(tlp)); if ((char *)(disk_lp + 1) > bootarea + bootarea_len) break; - if (disk_lp->d_magic2 != disk_lp->d_magic) + if (tlp.d_magic2 != tlp.d_magic) continue; - if (read_all && (disk_lp->d_magic == DISKMAGIC_DELETED || - disk_lp->d_magic == DISKMAGIC_DELETED_REV)) { - disk_lp->d_magic ^= ~0u; - disk_lp->d_magic2 ^= ~0u; + if (read_all && (tlp.d_magic == DISKMAGIC_DELETED || + tlp.d_magic == DISKMAGIC_DELETED_REV)) { + tlp.d_magic ^= ~0u; + tlp.d_magic2 ^= ~0u; is_deleted = "deleted "; } - if (target32toh(disk_lp->d_magic) != DISKMAGIC) { + if (target32toh(tlp.d_magic) != DISKMAGIC) { /* XXX: Do something about byte-swapped labels ? */ - if (target32toh(disk_lp->d_magic) == DISKMAGIC_REV && - target32toh(disk_lp->d_magic2) == DISKMAGIC_REV) + if (target32toh(tlp.d_magic) == DISKMAGIC_REV && + target32toh(tlp.d_magic2) == DISKMAGIC_REV) warnx("ignoring %sbyteswapped label" " at offset %jd from sector %u", is_deleted, (intmax_t)offset, sector); continue; } - if (target16toh(disk_lp->d_npartitions) > maxpartitions || - dkcksum_target(disk_lp) != 0) { + if (target16toh(tlp.d_npartitions) > maxpartitions || + dkcksum_target(&tlp) != 0) { if (verbose > 0) warnx("corrupt label found at offset %jd in " "sector %u", (intmax_t)offset, sector); @@ -1246,7 +1247,7 @@ find_label(int f, u_int sector) /* To print all the labels we have to do it here */ /* XXX: maybe we should compare them? */ - targettohlabel(&hlp, disk_lp); + targettohlabel(&hlp, &tlp); printf("# %ssector %u offset %jd bytes\n", is_deleted, sector, (intmax_t)offset); if (tflag) @@ -1256,7 +1257,8 @@ find_label(int f, u_int sector) showpartitions(stdout, &hlp, Cflag); } checklabel(&hlp); - htotargetlabel(disk_lp, &hlp); + htotargetlabel(&tlp, &hlp); + memcpy(disk_lp, &tlp, sizeof(tlp)); /* Remember we've found a label */ read_all = 2; }
CVS commit: src/sbin/disklabel
Module Name:src Committed By: chs Date: Thu Mar 9 00:18:23 UTC 2017 Modified Files: src/sbin/disklabel: main.c Log Message: use warnx() rather than warn() in a case where errno is not relevant. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.46 src/sbin/disklabel/main.c:1.47 --- src/sbin/disklabel/main.c:1.46 Sun Jan 31 18:57:29 2016 +++ src/sbin/disklabel/main.c Thu Mar 9 00:18:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.46 2016/01/31 18:57:29 christos Exp $ */ +/* $NetBSD: main.c,v 1.47 2017/03/09 00:18:23 chs Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.46 2016/01/31 18:57:29 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.47 2017/03/09 00:18:23 chs Exp $"); #endif #endif /* not lint */ @@ -387,7 +387,7 @@ setbyteorder(int new_byteorder) if ((!biendian_p || set_p) && byteorder != 0 && byteorder != new_byteorder) { - warn("changing %s byteorder to %s", + warnx("changing %s byteorder to %s", byteorder == LITTLE_ENDIAN ? "le" : "be", new_byteorder == LITTLE_ENDIAN ? "le" : "be"); }
CVS commit: src/sbin/disklabel
Module Name:src Committed By: snj Date: Sat Oct 15 06:23:29 UTC 2016 Modified Files: src/sbin/disklabel: disklabel.5 Log Message: revert part of revision 1.28. "e.g." is correct. bad igor! To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sbin/disklabel/disklabel.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/disklabel/disklabel.5 diff -u src/sbin/disklabel/disklabel.5:1.28 src/sbin/disklabel/disklabel.5:1.29 --- src/sbin/disklabel/disklabel.5:1.28 Sun Sep 11 01:59:10 2016 +++ src/sbin/disklabel/disklabel.5 Sat Oct 15 06:23:28 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: disklabel.5,v 1.28 2016/09/11 01:59:10 sevan Exp $ +.\" $NetBSD: disklabel.5,v 1.29 2016/10/15 06:23:28 snj Exp $ .\" .\" Copyright (c) 1987, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -136,7 +136,7 @@ struct disklabel { u_int32_t d_magic; /* the magic number */ u_int16_t d_type; /* drive type */ u_int16_t d_subtype; /* controller/d_type specific */ - char d_typename[16]; /* type name, e.g "eagle" */ + char d_typename[16]; /* type name, e.g. "eagle" */ /* * d_packname contains the pack identifier and is returned when
CVS commit: src/sbin/disklabel
Module Name:src Committed By: sevan Date: Sun Sep 11 02:10:31 UTC 2016 Modified Files: src/sbin/disklabel: disklabel.8 Log Message: Remove ignored Pp macro, highlighted by mandoc -Tlint. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sbin/disklabel/disklabel.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/disklabel/disklabel.8 diff -u src/sbin/disklabel/disklabel.8:1.66 src/sbin/disklabel/disklabel.8:1.67 --- src/sbin/disklabel/disklabel.8:1.66 Sun Sep 11 01:48:00 2016 +++ src/sbin/disklabel/disklabel.8 Sun Sep 11 02:10:31 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: disklabel.8,v 1.66 2016/09/11 01:48:00 sevan Exp $ +.\" $NetBSD: disklabel.8,v 1.67 2016/09/11 02:10:31 sevan Exp $ .\" .\" Copyright (c) 1987, 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -324,7 +324,6 @@ The utility appeared in .Bx 4.3 Tahoe . .Sh BUGS -.Pp The .Nm structure stored on disk cannot support partitions/disks greater than 2TB.
CVS commit: src/sbin/disklabel
Module Name:src Committed By: sevan Date: Sun Sep 11 01:59:10 UTC 2016 Modified Files: src/sbin/disklabel: disklabel.5 Log Message: Grammar fix suggested by textproc/igor. Syntax fix highlighted by mandoc -Tlint. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sbin/disklabel/disklabel.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/disklabel/disklabel.5 diff -u src/sbin/disklabel/disklabel.5:1.27 src/sbin/disklabel/disklabel.5:1.28 --- src/sbin/disklabel/disklabel.5:1.27 Sat Feb 25 01:55:00 2006 +++ src/sbin/disklabel/disklabel.5 Sun Sep 11 01:59:10 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: disklabel.5,v 1.27 2006/02/25 01:55:00 christos Exp $ +.\" $NetBSD: disklabel.5,v 1.28 2016/09/11 01:59:10 sevan Exp $ .\" .\" Copyright (c) 1987, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)disklabel.5.5 8.1 (Berkeley) 6/5/93 .\" -.Dd February 24, 2006 +.Dd September 11, 2016 .Dt DISKLABEL 5 .Os .Sh NAME @@ -136,7 +136,7 @@ struct disklabel { u_int32_t d_magic; /* the magic number */ u_int16_t d_type; /* drive type */ u_int16_t d_subtype; /* controller/d_type specific */ - char d_typename[16]; /* type name, e.g. "eagle" */ + char d_typename[16]; /* type name, e.g "eagle" */ /* * d_packname contains the pack identifier and is returned when @@ -404,8 +404,8 @@ struct partinfo { .Pp Disk specific ioctls are defined in .Pa sys/dkio.h . -.Pp .Bd -literal +.Pp /* * Disk-specific ioctls. */
CVS commit: src/sbin/disklabel
Module Name:src Committed By: sevan Date: Sun Sep 11 01:48:00 UTC 2016 Modified Files: src/sbin/disklabel: disklabel.8 Log Message: Document the version disklabel first appeared. Fix spelling mistakes. Replace contraction. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sbin/disklabel/disklabel.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/disklabel/disklabel.8 diff -u src/sbin/disklabel/disklabel.8:1.65 src/sbin/disklabel/disklabel.8:1.66 --- src/sbin/disklabel/disklabel.8:1.65 Wed Apr 29 17:07:11 2015 +++ src/sbin/disklabel/disklabel.8 Sun Sep 11 01:48:00 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: disklabel.8,v 1.65 2015/04/29 17:07:11 christos Exp $ +.\" $NetBSD: disklabel.8,v 1.66 2016/09/11 01:48:00 sevan Exp $ .\" .\" Copyright (c) 1987, 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 .\" -.Dd April 29, 2015 +.Dd September 11, 2016 .Dt DISKLABEL 8 .Os .Sh NAME @@ -197,7 +197,7 @@ Read/write the disk directly rather than requests on the kernel. When writing a label, the kernel will be told about the label before the label is written and asked to write afterwards. -This is the historic behaviour and can be supressed by specifying +This is the historic behaviour and can be suppressed by specifying .Fl F . .It Fl t Format the output as a @@ -250,7 +250,7 @@ command line, or writing the disklabel f .It 4 An I/O error of some sort occurred. .It 101..n -One or more warnings occured while reading the disklabel. +One or more warnings occurred while reading the disklabel. Subtract 100 to get the number of warnings detected. .El .Sh EXAMPLES @@ -266,7 +266,7 @@ as on-disk. .Pp .Dl Ic disklabel -i -I sd0 .Pp -As previous, but don't fail if there was no label on the disk yet; +As previous, but do not fail if there was no label on the disk yet; provide some default values instead. .Pp .Dl Ic disklabel -e -I sd0 @@ -318,6 +318,11 @@ partition. .Xr installboot 8 , .Xr mbrlabel 8 , .Xr mscdlabel 8 +.Sh HISTORY +The +.Nm +utility appeared in +.Bx 4.3 Tahoe . .Sh BUGS .Pp The
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Sun Jan 31 23:11:49 UTC 2016 Modified Files: src/sbin/disklabel: Makefile Log Message: fix broken patch To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sbin/disklabel/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/disklabel/Makefile diff -u src/sbin/disklabel/Makefile:1.71 src/sbin/disklabel/Makefile:1.72 --- src/sbin/disklabel/Makefile:1.71 Sun Jan 31 13:57:29 2016 +++ src/sbin/disklabel/Makefile Sun Jan 31 18:11:49 2016 @@ -1,44 +1,4 @@ -# $NetBSD: Makefile,v 1.71 2016/01/31 18:57:29 christos Exp $ -# Build a small disklabel (for tiny boot media) - -SRCDIR= ${.CURDIR}/../../../sbin/disklabel - -PROG= disklabel -SRCS= main.c dkcksum.c printlabel.c -#SRCS+= interact.c -NOMAN= # defined - -CPPFLAGS+= -DNO_INTERACT -CPPFLAGS+= -DNATIVELABEL_ONLY - -DPADD+= ${LIBUTIL} -LDADD+= -lutil - -# these have additional requirements on the alignment of a partition -.if (${MACHINE} == "sparc") || (${MACHINE} == "sparc64") \ - || (${MACHINE} == "sun3") -CPPFLAGS+= -DSTRICT_CYLINDER_ALIGNMENT -.endif - -.if (${MACHINE} == "acorn32" || ${MACHINE} == "acorn26") -# Support FileCore boot block -CPPFLAGS+= -DUSE_ACORN -.endif - -.if (${MACHINE_ARCH} == "alpha") -# alpha requires boot block checksum -CPPFLAGS+= -DALPHA_BOOTBLOCK_CKSUM -.endif - -.if (${MACHINE_ARCH} == "vax") -# vax requires labels in alternative sectors on SMD disk -CPPFLAGS+= -DVAX_ALTLABELS -.endif - -.include - -.PATH: ${SRCDIR} -# $NetBSD: Makefile,v 1.71 2016/01/31 18:57:29 christos Exp $ +# $NetBSD: Makefile,v 1.72 2016/01/31 23:11:49 christos Exp $ # @(#)Makefile 8.2 (Berkeley) 3/17/94 PROG= disklabel
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Sun Jan 31 18:57:29 UTC 2016 Modified Files: src/sbin/disklabel: Makefile bswap.c bswap.h interact.c main.c Log Message: PR/50729: Izumi Tsutsui: Add "SMALLPROG"-like options to disklabel(8) To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sbin/disklabel/Makefile cvs rdiff -u -r1.4 -r1.5 src/sbin/disklabel/bswap.c cvs rdiff -u -r1.2 -r1.3 src/sbin/disklabel/bswap.h cvs rdiff -u -r1.38 -r1.39 src/sbin/disklabel/interact.c cvs rdiff -u -r1.45 -r1.46 src/sbin/disklabel/main.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/disklabel/Makefile diff -u src/sbin/disklabel/Makefile:1.70 src/sbin/disklabel/Makefile:1.71 --- src/sbin/disklabel/Makefile:1.70 Fri May 3 12:05:12 2013 +++ src/sbin/disklabel/Makefile Sun Jan 31 13:57:29 2016 @@ -1,4 +1,44 @@ -# $NetBSD: Makefile,v 1.70 2013/05/03 16:05:12 matt Exp $ +# $NetBSD: Makefile,v 1.71 2016/01/31 18:57:29 christos Exp $ +# Build a small disklabel (for tiny boot media) + +SRCDIR= ${.CURDIR}/../../../sbin/disklabel + +PROG= disklabel +SRCS= main.c dkcksum.c printlabel.c +#SRCS+= interact.c +NOMAN= # defined + +CPPFLAGS+= -DNO_INTERACT +CPPFLAGS+= -DNATIVELABEL_ONLY + +DPADD+= ${LIBUTIL} +LDADD+= -lutil + +# these have additional requirements on the alignment of a partition +.if (${MACHINE} == "sparc") || (${MACHINE} == "sparc64") \ + || (${MACHINE} == "sun3") +CPPFLAGS+= -DSTRICT_CYLINDER_ALIGNMENT +.endif + +.if (${MACHINE} == "acorn32" || ${MACHINE} == "acorn26") +# Support FileCore boot block +CPPFLAGS+= -DUSE_ACORN +.endif + +.if (${MACHINE_ARCH} == "alpha") +# alpha requires boot block checksum +CPPFLAGS+= -DALPHA_BOOTBLOCK_CKSUM +.endif + +.if (${MACHINE_ARCH} == "vax") +# vax requires labels in alternative sectors on SMD disk +CPPFLAGS+= -DVAX_ALTLABELS +.endif + +.include + +.PATH: ${SRCDIR} +# $NetBSD: Makefile,v 1.71 2016/01/31 18:57:29 christos Exp $ # @(#)Makefile 8.2 (Berkeley) 3/17/94 PROG= disklabel Index: src/sbin/disklabel/bswap.c diff -u src/sbin/disklabel/bswap.c:1.4 src/sbin/disklabel/bswap.c:1.5 --- src/sbin/disklabel/bswap.c:1.4 Sat Jul 18 02:00:46 2015 +++ src/sbin/disklabel/bswap.c Sun Jan 31 13:57:29 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: bswap.c,v 1.4 2015/07/18 06:00:46 htodd Exp $ */ +/* $NetBSD: bswap.c,v 1.5 2016/01/31 18:57:29 christos Exp $ */ /*- * Copyright (c) 2009 Izumi Tsutsui. All rights reserved. @@ -55,6 +55,8 @@ * @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91 */ +#if !defined(NATIVELABEL_ONLY) + #if HAVE_NBTOOL_CONFIG_H #include "nbtool_config.h" #endif @@ -179,3 +181,5 @@ dkcksum_target(struct disklabel *lp) return dkcksum_sized(lp, npartitions); } + +#endif /* !NATIVELABEL_ONLY */ Index: src/sbin/disklabel/bswap.h diff -u src/sbin/disklabel/bswap.h:1.2 src/sbin/disklabel/bswap.h:1.3 --- src/sbin/disklabel/bswap.h:1.2 Fri May 3 12:05:12 2013 +++ src/sbin/disklabel/bswap.h Sun Jan 31 13:57:29 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: bswap.h,v 1.2 2013/05/03 16:05:12 matt Exp $ */ +/* $NetBSD: bswap.h,v 1.3 2016/01/31 18:57:29 christos Exp $ */ /*- * Copyright (c) 2009 Izumi Tsutsui. All rights reserved. @@ -38,6 +38,7 @@ #include #endif +#if !defined(NATIVELABEL_ONLY) extern int bswap_p; extern u_int maxpartitions; @@ -49,3 +50,13 @@ extern u_int maxpartitions; void htotargetlabel(struct disklabel *, const struct disklabel *); void targettohlabel(struct disklabel *, const struct disklabel *); uint16_t dkcksum_target(struct disklabel *); +#else +#define htotarget16(x) (x) +#define target16toh(x) (x) +#define htotarget32(x) (x) +#define target32toh(x) (x) + +#define htotargetlabel(dl, sl) do { *(dl) = *(sl); } while (0) +#define targettohlabel(dl, sl) do { *(dl) = *(sl); } while (0) +#define dkcksum_target(label) dkcksum(label) +#endif /* !NATIVELABEL_ONLY */ Index: src/sbin/disklabel/interact.c diff -u src/sbin/disklabel/interact.c:1.38 src/sbin/disklabel/interact.c:1.39 --- src/sbin/disklabel/interact.c:1.38 Fri May 3 12:05:12 2013 +++ src/sbin/disklabel/interact.c Sun Jan 31 13:57:29 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: interact.c,v 1.38 2013/05/03 16:05:12 matt Exp $ */ +/* $NetBSD: interact.c,v 1.39 2016/01/31 18:57:29 christos Exp $ */ /* * Copyright (c) 1997 Christos Zoulas. All rights reserved. @@ -24,13 +24,15 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if !defined(NO_INTERACT) + #if HAVE_NBTOOL_CONFIG_H #include "nbtool_config.h" #endif #include #ifndef lint -__RCSID("$NetBSD: interact.c,v 1.38 2013/05/03 16:05:12 matt Exp $"); +__RCSID("$NetBSD: interact.c,v 1.39 2016/01/31 18:57:29 christos Exp $"); #endif /* lint */ #include @@ -810,3 +812,5 @@ interact(struct disklabel *lp, int fd) return; } } + +#endif /* !NO_INTERACT */ Index: src/sbin/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.45 src/sbin/disklabel/main.c:1.46 --- src/
CVS commit: src/sbin/disklabel
Module Name:src Committed By: htodd Date: Sat Jul 18 06:00:46 UTC 2015 Modified Files: src/sbin/disklabel: bswap.c Log Message: Fix build. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sbin/disklabel/bswap.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/disklabel/bswap.c diff -u src/sbin/disklabel/bswap.c:1.3 src/sbin/disklabel/bswap.c:1.4 --- src/sbin/disklabel/bswap.c:1.3 Fri Jul 17 20:30:21 2015 +++ src/sbin/disklabel/bswap.c Sat Jul 18 06:00:46 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: bswap.c,v 1.3 2015/07/17 20:30:21 tsutsui Exp $ */ +/* $NetBSD: bswap.c,v 1.4 2015/07/18 06:00:46 htodd Exp $ */ /*- * Copyright (c) 2009 Izumi Tsutsui. All rights reserved. @@ -74,7 +74,7 @@ static void bswaplabel(struct disklabel *nlp, const struct disklabel *olp) { - int i; + u_int i; nlp->d_magic = bswap32(olp->d_magic); nlp->d_type = bswap16(olp->d_type);
CVS commit: src/sbin/disklabel
Module Name:src Committed By: tsutsui Date: Fri Jul 17 20:30:21 UTC 2015 Modified Files: src/sbin/disklabel: bswap.c Log Message: Fix botch in "make disklabel a MI tool" changes in rev 1.2. After that chanage, "MAXPARTITIONS" constant is not for the target port. If host's MAXPARTITIONS is larger than a value of the target label and target endianness is different from the build host, bswaplabel() could overwrite data beyond the disklabel and primary boot stored after LABELSECTOR in images might be corrupted. This fixes boot failure of sun2 liveimage built by "build.sh -U -m sun2 release live-image" on TME. Should be pulled up to netbsd-7. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sbin/disklabel/bswap.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/disklabel/bswap.c diff -u src/sbin/disklabel/bswap.c:1.2 src/sbin/disklabel/bswap.c:1.3 --- src/sbin/disklabel/bswap.c:1.2 Fri May 3 16:05:12 2013 +++ src/sbin/disklabel/bswap.c Fri Jul 17 20:30:21 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: bswap.c,v 1.2 2013/05/03 16:05:12 matt Exp $ */ +/* $NetBSD: bswap.c,v 1.3 2015/07/17 20:30:21 tsutsui Exp $ */ /*- * Copyright (c) 2009 Izumi Tsutsui. All rights reserved. @@ -120,7 +120,7 @@ bswaplabel(struct disklabel *nlp, const nlp->d_bbsize = bswap32(olp->d_bbsize); nlp->d_sbsize = bswap32(olp->d_sbsize); - for (i = 0; i < MAXPARTITIONS; i++) { + for (i = 0; i < maxpartitions; i++) { nlp->d_partitions[i].p_size = bswap32(olp->d_partitions[i].p_size); nlp->d_partitions[i].p_offset =
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Wed Apr 29 17:07:11 UTC 2015 Modified Files: src/sbin/disklabel: disklabel.8 Log Message: Add missing doc flags (B,M,m) To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sbin/disklabel/disklabel.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/disklabel/disklabel.8 diff -u src/sbin/disklabel/disklabel.8:1.64 src/sbin/disklabel/disklabel.8:1.65 --- src/sbin/disklabel/disklabel.8:1.64 Tue Aug 2 06:21:12 2011 +++ src/sbin/disklabel/disklabel.8 Wed Apr 29 13:07:11 2015 @@ -1,4 +1,4 @@ -.\" $NetBSD: disklabel.8,v 1.64 2011/08/02 10:21:12 wiz Exp $ +.\" $NetBSD: disklabel.8,v 1.65 2015/04/29 17:07:11 christos Exp $ .\" .\" Copyright (c) 1987, 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 .\" -.Dd July 25, 2011 +.Dd April 29, 2015 .Dt DISKLABEL 8 .Os .Sh NAME @@ -41,27 +41,37 @@ .Sh SYNOPSIS .\" disklabel: read label .Nm -.Op Fl ACDFrtv +.Op Fl ACDFmrtv +.Op Fl B Ar endian +.Op Fl M Ar machine .Ar disk .\" disklabel -e: read/modify/write using $EDITOR .Nm .Fl e -.Op Fl CDFIrv +.Op Fl CDFImrv +.Op Fl B Ar endian +.Op Fl M Ar machine .Ar disk .\" disklabel -i: read/modify/write using builtin commands .Nm .Fl i -.Op Fl DFIrv +.Op Fl DFImrv +.Op Fl B Ar endian +.Op Fl M Ar machine .Ar disk .\" disklabel -R: write from edited output .Nm .Fl R -.Op Fl DFrv +.Op Fl DFmrv +.Op Fl B Ar endian +.Op Fl M Ar machine .Ar disk Ar protofile .\" disklabel -w: write from disctab entry .Nm .Fl w -.Op Fl DFrv +.Op Fl DFmrv +.Op Fl B Ar endian +.Op Fl M Ar machine .Op Fl f Ar disktab .Ar disk Ar disktype .Oo Ar packid Oc @@ -126,6 +136,12 @@ Read all labels from the disk, including .Fl D . Implies .Fl r . +.It Fl B Ar endian +Specify the byteorder of the label to be written. +It should be: +.Dq be +or +.Dq le . .It Fl C Output the partition offset and size values in .Aq cylinder/head/sector @@ -170,6 +186,11 @@ Implies .It Fl f Ar disktab Specify the name of a file to use instead of .Pa /etc/disktab . +.It Fl M Ar machine +Specify the machine to generate a label for. +Defaults to the current machine it is compiled for. +.It Fl m +expect the label to have an MBR. .It Fl r Read/write the disk directly rather than using .Xr ioctl 2
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Mon Apr 27 17:05:58 UTC 2015 Modified Files: src/sbin/disklabel: main.c Log Message: fix mistake in previous To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.44 src/sbin/disklabel/main.c:1.45 --- src/sbin/disklabel/main.c:1.44 Sat Apr 25 17:43:53 2015 +++ src/sbin/disklabel/main.c Mon Apr 27 13:05:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.44 2015/04/25 21:43:53 christos Exp $ */ +/* $NetBSD: main.c,v 1.45 2015/04/27 17:05:58 christos Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.44 2015/04/25 21:43:53 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.45 2015/04/27 17:05:58 christos Exp $"); #endif #endif /* not lint */ @@ -198,8 +198,8 @@ int bswap_p; static const struct disklabel_params { const char *machine; - u_char labelusesmbr : 4; - u_char labelsector : 4; + u_char labelusesmbr : 1; + u_char labelsector : 7; u_char maxpartitions; u_char raw_part; u_char oldmaxpartitions; @@ -256,37 +256,37 @@ static const struct disklabel_params { { "macppc", 1, 0, 16, 2, 0, 64, BIG_ENDIAN }, /* powerpc */ { "pmon", 1, 0, 16, 2, 0, 64, 0 }, /* evbmips */ - { "prep", 1, 1, 0, 8, 2, 0, BIG_ENDIAN }, /* powerpc */ + { "prep", 1, 1, 8, 2, 0, 0, BIG_ENDIAN }, /* powerpc */ - { "dreamcast", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* sh3 */ - { "evbarm64", 1, 1, 0, 16, 2, 0, 0 }, /* aarch64 */ - { "evbcf", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* coldfire */ - { "evbppc-mbr", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ - { "evbsh3", 1, 1, 0, 16, 2, 0, 0 }, /* sh3 */ - { "hpcsh", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* sh3 */ - { "mmeye", 1, 1, 0, 16, 2, 0, 0 }, /* sh3 */ - { "or1k", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* or1k */ - { "riscv", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* riscv */ - - { "acorn26", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ - { "acorn32", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ - { "cats", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ - { "evbarm", 1, 1, 0, 16, 2, 8, 0 }, /* arm */ - { "iyonix", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ - { "netwinder", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ - { "shark", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ - - { "amd64", 1, 1, 0, 16, 3, 0, LITTLE_ENDIAN }, /* x86 */ - { "arc", 1, 1, 0, 16, 3, 0, LITTLE_ENDIAN }, /* mips */ - { "cobalt", 1, 1, 0, 16, 3, 0, LITTLE_ENDIAN }, /* mips */ - { "landisk", 1, 1, 0, 16, 3, 0, LITTLE_ENDIAN }, /* sh3 */ - - { "epoc32", 1, 1, 0, 16, 3, 8, LITTLE_ENDIAN }, /* arm */ - { "hpcarm", 1, 1, 0, 16, 3, 8, LITTLE_ENDIAN }, /* arm */ - { "hpcmips", 1, 1, 0, 16, 3, 8, LITTLE_ENDIAN }, /* mips */ - { "i386", 1, 1, 0, 16, 3, 8, LITTLE_ENDIAN }, /* x86 */ - { "ia64", 1, 1, 0, 16, 3, 8, LITTLE_ENDIAN }, /* x86 */ - { "zaurus", 1, 1, 0, 16, 3, 8, LITTLE_ENDIAN }, /* arm */ + { "dreamcast", 1, 1, 16, 2, 0, 0, LITTLE_ENDIAN }, /* sh3 */ + { "evbarm64", 1, 1, 16, 2, 0, 0, 0 }, /* aarch64 */ + { "evbcf", 1, 1, 16, 2, 0, 0, BIG_ENDIAN }, /* coldfire */ + { "evbppc-mbr", 1, 1, 16, 2, 0, 0, BIG_ENDIAN }, /* powerpc */ + { "evbsh3", 1, 1, 16, 2, 0, 0, 0 }, /* sh3 */ + { "hpcsh", 1, 1, 16, 2, 0, 0, LITTLE_ENDIAN }, /* sh3 */ + { "mmeye", 1, 1, 16, 2, 0, 0, 0 }, /* sh3 */ + { "or1k", 1, 1, 16, 2, 0, 0, BIG_ENDIAN }, /* or1k */ + { "riscv", 1, 1, 16, 2, 0, 0, LITTLE_ENDIAN }, /* riscv */ + + { "acorn26", 1, 1, 16, 2, 8, 0, LITTLE_ENDIAN }, /* arm */ + { "acorn32", 1, 1, 16, 2, 8, 0, LITTLE_ENDIAN }, /* arm */ + { "cats", 1, 1, 16, 2, 8, 0, LITTLE_ENDIAN }, /* arm */ + { "evbarm", 1, 1, 16, 2, 8, 0, 0 }, /* arm */ + { "iyonix", 1, 1, 16, 2, 8, 0, LITTLE_ENDIAN }, /* arm */ + { "netwinder", 1, 1, 16, 2, 8, 0, LITTLE_ENDIAN }, /* arm */ + { "shark", 1, 1, 16, 2, 8, 0, LITTLE_ENDIAN }, /* arm */ + + { "amd64", 1, 1, 16, 3, 0, 0, LITTLE_ENDIAN }, /* x86 */ + { "arc", 1, 1, 16, 3, 0, 0, LITTLE_ENDIAN }, /* mips */ + { "cobalt", 1, 1, 16, 3, 0, 0, LITTLE_ENDIAN }, /* mips */ + { "landisk", 1, 1, 16, 3, 0, 0, LITTLE_ENDIAN }, /* sh3 */ + + { "epoc32", 1, 1, 16, 3, 8, 0, LITTLE_ENDIAN }, /* arm */ + { "hpcarm", 1, 1, 16, 3, 8, 0, LITTLE_ENDIAN }, /* arm */ + { "hpcmips", 1, 1, 16, 3, 8, 0, LITTLE_ENDIAN }, /* mips */ + { "i386", 1, 1, 16, 3, 8, 0, LITTLE_ENDIAN }, /* x86 */ + { "ia64", 1, 1, 16, 3, 8, 0, LITTLE_ENDIAN }, /* x86 */ + { "zaurus", 1, 1, 16, 3, 8, 0, LITTLE_ENDIAN }, /* arm */ { NULL, 0, 0, 0, 0, 0, 0, 0 }, /* must b
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Sat Apr 25 21:43:53 UTC 2015 Modified Files: src/sbin/disklabel: main.c Log Message: make table smaller in size. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.43 src/sbin/disklabel/main.c:1.44 --- src/sbin/disklabel/main.c:1.43 Fri Jan 2 14:46:02 2015 +++ src/sbin/disklabel/main.c Sat Apr 25 17:43:53 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.43 2015/01/02 19:46:02 christos Exp $ */ +/* $NetBSD: main.c,v 1.44 2015/04/25 21:43:53 christos Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.43 2015/01/02 19:46:02 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.44 2015/04/25 21:43:53 christos Exp $"); #endif #endif /* not lint */ @@ -198,97 +198,97 @@ int bswap_p; static const struct disklabel_params { const char *machine; - int labelusesmbr; - u_int labelsector; - u_int labeloffset; - u_int maxpartitions; - u_int raw_part; - u_int oldmaxpartitions; - int byteorder; + u_char labelusesmbr : 4; + u_char labelsector : 4; + u_char maxpartitions; + u_char raw_part; + u_char oldmaxpartitions; + u_short labeloffset; + u_short byteorder; } disklabel_params[] = { - { "mvme68k", 0, 0, 0, 8, 2, 0, BIG_ENDIAN }, /* m68k */ - { "next68k", 0, 0, 0, 8, 2, 0, BIG_ENDIAN }, /* m68k */ + { "mvme68k", 0, 0, 8, 2, 0, 0, BIG_ENDIAN }, /* m68k */ + { "next68k", 0, 0, 8, 2, 0, 0, BIG_ENDIAN }, /* m68k */ - { "algor", 0, 0, 64, 8, 2, 0, LITTLE_ENDIAN }, /* mips */ - { "alpha", 0, 0, 64, 8, 2, 0, LITTLE_ENDIAN }, /* alpha */ - { "luna68k", 0, 0, 64, 8, 2, 0, BIG_ENDIAN }, /* m68k */ - { "mac68k", 0, 0, 64, 8, 2, 0, BIG_ENDIAN }, /* m68k */ - { "news68k", 0, 0, 64, 8, 2, 0, BIG_ENDIAN }, /* m68k */ - { "newsmips", 0, 0, 64, 8, 2, 0, BIG_ENDIAN }, /* mips */ - { "pmax", 0, 0, 64, 8, 2, 0, LITTLE_ENDIAN }, /* mips */ - { "sun2", 0, 0, 64, 8, 2, 0, BIG_ENDIAN }, /* m68k */ - { "sun68k", 0, 0, 64, 8, 2, 0, BIG_ENDIAN }, /* m68010 */ - { "x68k", 0, 0, 64, 8, 2, 0, BIG_ENDIAN }, /* m68010 */ - - { "vax", 0, 0, 64, 12, 2, 8, LITTLE_ENDIAN }, /* vax */ - - { "amiga", 0, 0, 64, 16, 2, 0, BIG_ENDIAN }, /* m68k */ - { "amigappc", 0, 0, 64, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ - { "evbmips", 0, 0, 64, 16, 2, 0, 0 }, /* mips */ - { "evbppc", 0, 0, 64, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ - - { "sparc", 0, 0, 128, 8, 2, 0, BIG_ENDIAN }, /* sun */ - { "sparc64", 0, 0, 128, 8, 2, 0, BIG_ENDIAN }, /* sun */ - { "sun3", 0, 0, 128, 8, 2, 0, BIG_ENDIAN }, /* sun */ - - { "atari", 0, 0, 516, 16, 2, 0, BIG_ENDIAN }, /* m68k */ - - { "mipsco", 0, 1, 0, 8, 2, 0, BIG_ENDIAN }, /* mips */ - { "mvmeppc", 0, 1, 0, 8, 3, 0, BIG_ENDIAN }, /* powerpc */ - - { "bebox", 0, 1, 0, 8, 3, 0, BIG_ENDIAN }, /* powerpc */ - - { "emips", 0, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* mips */ - { "hppa", 0, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* hppa */ - { "ibmnws", 0, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ - { "ofppc", 0, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ - { "rs6000", 0, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ - { "sandpoint", 0, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ - { "sgimips", 0, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* mips */ - - { "sbmips", 0, 1, 0, 16, 3, 0, 0 }, /* mips */ - - { "cesfic", 0, 2, 0, 8, 2, 0, BIG_ENDIAN }, /* m68k */ - { "hp300", 0, 2, 0, 8, 2, 0, BIG_ENDIAN }, /* m68k */ - - { "ews4800mips",0, 9, 0, 16, 15, 0, BIG_ENDIAN }, /* mips */ - - { "macppc", 1, 0, 64, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ - { "pmon", 1, 0, 64, 16, 2, 0, 0 }, /* evbmips */ - - { "prep", 1, 1, 0, 8, 2, 0, BIG_ENDIAN }, /* powerpc */ - - { "dreamcast", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* sh3 */ - { "evbarm64", 1, 1, 0, 16, 2, 0, 0 }, /* aarch64 */ - { "evbcf", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* coldfire */ - { "evbppc-mbr", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ - { "evbsh3", 1, 1, 0, 16, 2, 0, 0 }, /* sh3 */ - { "hpcsh", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* sh3 */ - { "mmeye", 1, 1, 0, 16, 2, 0, 0 }, /* sh3 */ - { "or1k", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* or1k */ - { "riscv", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* riscv */ - - { "acorn26", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ - { "acorn32", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ - { "cats", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ - { "evbarm", 1, 1, 0, 16, 2, 8, 0 }, /* arm */ - { "iyonix", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ - { "netwinder", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ - {
CVS commit: src/sbin/disklabel
Module Name:src Committed By: matt Date: Fri Sep 19 17:45:04 UTC 2014 Modified Files: src/sbin/disklabel: main.c Log Message: Add OpenRISC 1000 & UCB RISC-V platform support. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.41 src/sbin/disklabel/main.c:1.42 --- src/sbin/disklabel/main.c:1.41 Sun Aug 10 06:48:51 2014 +++ src/sbin/disklabel/main.c Fri Sep 19 17:45:03 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.41 2014/08/10 06:48:51 apb Exp $ */ +/* $NetBSD: main.c,v 1.42 2014/09/19 17:45:03 matt Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.41 2014/08/10 06:48:51 apb Exp $"); +__RCSID("$NetBSD: main.c,v 1.42 2014/09/19 17:45:03 matt Exp $"); #endif #endif /* not lint */ @@ -246,7 +246,7 @@ static const struct disklabel_params { { "sandpoint", 0, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ { "sgimips", 0, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* mips */ - { "sbmips", 0, 1, 0, 16, 3, 0, 0 }, /* mips */ + { "sbmips", 0, 1, 0, 16, 3, 0, 0 }, /* mips */ { "cesfic", 0, 2, 0, 8, 2, 0, BIG_ENDIAN }, /* m68k */ { "hp300", 0, 2, 0, 8, 2, 0, BIG_ENDIAN }, /* m68k */ @@ -260,11 +260,13 @@ static const struct disklabel_params { { "dreamcast", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* sh3 */ { "evbarm64", 1, 1, 0, 16, 2, 0, 0 }, /* aarch64 */ - { "evbsh3", 1, 1, 0, 16, 2, 0, 0 }, /* sh3 */ { "evbcf", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* coldfire */ { "evbppc-mbr", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ + { "evbsh3", 1, 1, 0, 16, 2, 0, 0 }, /* sh3 */ { "hpcsh", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* sh3 */ { "mmeye", 1, 1, 0, 16, 2, 0, 0 }, /* sh3 */ + { "or1k", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* or1k */ + { "riscv", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* riscv */ { "acorn26", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ { "acorn32", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ @@ -312,6 +314,8 @@ static const struct arch_endian { { LITTLE_ENDIAN, "ia64" }, { LITTLE_ENDIAN, "mipsel" }, { LITTLE_ENDIAN, "mips64el" }, + { LITTLE_ENDIAN, "riscv32" }, + { LITTLE_ENDIAN, "riscv64" }, { LITTLE_ENDIAN, "sh3el" }, { LITTLE_ENDIAN, "vax" }, { LITTLE_ENDIAN, "x86_64" }, @@ -332,6 +336,7 @@ static const struct arch_endian { { BIG_ENDIAN, "m68k" }, { BIG_ENDIAN, "mipseb" }, { BIG_ENDIAN, "mips64eb" }, + { BIG_ENDIAN, "or1k" }, { BIG_ENDIAN, "powerpc" }, { BIG_ENDIAN, "sh3eb" }, { BIG_ENDIAN, "sparc" },
CVS commit: src/sbin/disklabel
Module Name:src Committed By: apb Date: Sun Aug 10 06:48:51 UTC 2014 Modified Files: src/sbin/disklabel: main.c Log Message: Fix typo in "dreamcast" port name. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.40 src/sbin/disklabel/main.c:1.41 --- src/sbin/disklabel/main.c:1.40 Sun Aug 10 05:57:31 2014 +++ src/sbin/disklabel/main.c Sun Aug 10 06:48:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.40 2014/08/10 05:57:31 matt Exp $ */ +/* $NetBSD: main.c,v 1.41 2014/08/10 06:48:51 apb Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.40 2014/08/10 05:57:31 matt Exp $"); +__RCSID("$NetBSD: main.c,v 1.41 2014/08/10 06:48:51 apb Exp $"); #endif #endif /* not lint */ @@ -258,7 +258,7 @@ static const struct disklabel_params { { "prep", 1, 1, 0, 8, 2, 0, BIG_ENDIAN }, /* powerpc */ - { "dreadmcast", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* sh3 */ + { "dreamcast", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* sh3 */ { "evbarm64", 1, 1, 0, 16, 2, 0, 0 }, /* aarch64 */ { "evbsh3", 1, 1, 0, 16, 2, 0, 0 }, /* sh3 */ { "evbcf", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* coldfire */
CVS commit: src/sbin/disklabel
Module Name:src Committed By: joerg Date: Tue Jul 15 20:18:30 UTC 2014 Modified Files: src/sbin/disklabel: main.c Log Message: Print uint32_t field as such. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.38 src/sbin/disklabel/main.c:1.39 --- src/sbin/disklabel/main.c:1.38 Mon Feb 24 07:23:40 2014 +++ src/sbin/disklabel/main.c Tue Jul 15 20:18:30 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.38 2014/02/24 07:23:40 skrll Exp $ */ +/* $NetBSD: main.c,v 1.39 2014/07/15 20:18:30 joerg Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.38 2014/02/24 07:23:40 skrll Exp $"); +__RCSID("$NetBSD: main.c,v 1.39 2014/07/15 20:18:30 joerg Exp $"); #endif #endif /* not lint */ @@ -1384,7 +1384,7 @@ makedisktab(FILE *f, struct disklabel *l did = ""; } if (lp->d_headswitch != 0) { - (void) fprintf(f, "%shs#%" PRIu16 ":", did, lp->d_headswitch); + (void) fprintf(f, "%shs#%" PRIu32 ":", did, lp->d_headswitch); did = ""; } if (lp->d_trkseek != 0) {
CVS commit: src/sbin/disklabel
Module Name:src Committed By: matt Date: Thu Aug 22 00:26:23 UTC 2013 Modified Files: src/sbin/disklabel: main.c Log Message: Add m68000/coldfire. Add evbcf. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.36 src/sbin/disklabel/main.c:1.37 --- src/sbin/disklabel/main.c:1.36 Sun Aug 11 17:15:15 2013 +++ src/sbin/disklabel/main.c Thu Aug 22 00:26:23 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.36 2013/08/11 17:15:15 riz Exp $ */ +/* $NetBSD: main.c,v 1.37 2013/08/22 00:26:23 matt Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.36 2013/08/11 17:15:15 riz Exp $"); +__RCSID("$NetBSD: main.c,v 1.37 2013/08/22 00:26:23 matt Exp $"); #endif #endif /* not lint */ @@ -260,8 +260,9 @@ static const struct disklabel_params { { "dreadmcast", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* sh3 */ { "evbsh3", 1, 1, 0, 16, 2, 0, 0 }, /* sh3 */ - { "hpcsh", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* sh3 */ + { "evbcf", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* coldfire */ { "evbppc-mbr", 1, 1, 0, 16, 2, 0, BIG_ENDIAN }, /* powerpc */ + { "hpcsh", 1, 1, 0, 16, 2, 0, LITTLE_ENDIAN }, /* sh3 */ { "mmeye", 1, 1, 0, 16, 2, 0, 0 }, /* sh3 */ { "acorn26", 1, 1, 0, 16, 2, 8, LITTLE_ENDIAN }, /* arm */ @@ -314,6 +315,7 @@ static const struct arch_endian { { LITTLE_ENDIAN, "x86_64" }, { BIG_ENDIAN, "armeb" }, + { BIG_ENDIAN, "coldfire" }, { BIG_ENDIAN, "earmeb" }, { BIG_ENDIAN, "earmhfeb" }, { BIG_ENDIAN, "earmv4eb" }, @@ -323,6 +325,7 @@ static const struct arch_endian { { BIG_ENDIAN, "earmv7eb" }, { BIG_ENDIAN, "earmv7hfeb" }, { BIG_ENDIAN, "hppa" }, + { BIG_ENDIAN, "m68000" }, { BIG_ENDIAN, "m68k" }, { BIG_ENDIAN, "mipseb" }, { BIG_ENDIAN, "mips64eb" },
CVS commit: src/sbin/disklabel
Module Name:src Committed By: riz Date: Sun Aug 11 17:15:15 UTC 2013 Modified Files: src/sbin/disklabel: main.c Log Message: A number of new earm MACHINE_ARCH have shown up recently; make sure we can deduce their endianness. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.35 src/sbin/disklabel/main.c:1.36 --- src/sbin/disklabel/main.c:1.35 Wed May 15 00:47:43 2013 +++ src/sbin/disklabel/main.c Sun Aug 11 17:15:15 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.35 2013/05/15 00:47:43 christos Exp $ */ +/* $NetBSD: main.c,v 1.36 2013/08/11 17:15:15 riz Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.35 2013/05/15 00:47:43 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.36 2013/08/11 17:15:15 riz Exp $"); #endif #endif /* not lint */ @@ -299,6 +299,12 @@ static const struct arch_endian { { LITTLE_ENDIAN, "arm" }, { LITTLE_ENDIAN, "earm" }, { LITTLE_ENDIAN, "earmhf" }, + { LITTLE_ENDIAN, "earmv4" }, + { LITTLE_ENDIAN, "earmv5" }, + { LITTLE_ENDIAN, "earmv6" }, + { LITTLE_ENDIAN, "earmv6hf" }, + { LITTLE_ENDIAN, "earmv7" }, + { LITTLE_ENDIAN, "earmv7hf" }, { LITTLE_ENDIAN, "i386" }, { LITTLE_ENDIAN, "ia64" }, { LITTLE_ENDIAN, "mipsel" }, @@ -310,6 +316,12 @@ static const struct arch_endian { { BIG_ENDIAN, "armeb" }, { BIG_ENDIAN, "earmeb" }, { BIG_ENDIAN, "earmhfeb" }, + { BIG_ENDIAN, "earmv4eb" }, + { BIG_ENDIAN, "earmv5eb" }, + { BIG_ENDIAN, "earmv6eb" }, + { BIG_ENDIAN, "earmv6hfeb" }, + { BIG_ENDIAN, "earmv7eb" }, + { BIG_ENDIAN, "earmv7hfeb" }, { BIG_ENDIAN, "hppa" }, { BIG_ENDIAN, "m68k" }, { BIG_ENDIAN, "mipseb" },
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Wed May 15 00:47:43 UTC 2013 Modified Files: src/sbin/disklabel: main.c Log Message: %td is for ptrdiff_t not for off_t To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.34 src/sbin/disklabel/main.c:1.35 --- src/sbin/disklabel/main.c:1.34 Mon May 13 14:01:08 2013 +++ src/sbin/disklabel/main.c Tue May 14 20:47:43 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.34 2013/05/13 18:01:08 christos Exp $ */ +/* $NetBSD: main.c,v 1.35 2013/05/15 00:47:43 christos Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.34 2013/05/13 18:01:08 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.35 2013/05/15 00:47:43 christos Exp $"); #endif #endif /* not lint */ @@ -1172,28 +1172,28 @@ find_label(int f, u_int sector) if (target32toh(disk_lp->d_magic) == DISKMAGIC_REV && target32toh(disk_lp->d_magic2) == DISKMAGIC_REV) warnx("ignoring %sbyteswapped label" -" at offset %td from sector %u", -is_deleted, offset, sector); +" at offset %jd from sector %u", +is_deleted, (intmax_t)offset, sector); continue; } if (target16toh(disk_lp->d_npartitions) > maxpartitions || dkcksum_target(disk_lp) != 0) { if (verbose > 0) -warnx("corrupt label found at offset %td in " -"sector %u", offset, sector); +warnx("corrupt label found at offset %jd in " +"sector %u", (intmax_t)offset, sector); continue; } if (verbose > 1) - warnx("%slabel found at offset %td from sector %u", - is_deleted, offset, sector); + warnx("%slabel found at offset %jd from sector %u", + is_deleted, (intmax_t)offset, sector); if (!read_all) return disk_lp; /* To print all the labels we have to do it here */ /* XXX: maybe we should compare them? */ targettohlabel(&hlp, disk_lp); - printf("# %ssector %u offset %td bytes\n", - is_deleted, sector, offset); + printf("# %ssector %u offset %jd bytes\n", + is_deleted, sector, (intmax_t)offset); if (tflag) makedisktab(stdout, &hlp); else {
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Mon May 13 18:01:08 UTC 2013 Modified Files: src/sbin/disklabel: main.c Log Message: CVE 1020933: Prevent integer overflow by using wider type To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.33 src/sbin/disklabel/main.c:1.34 --- src/sbin/disklabel/main.c:1.33 Mon May 13 13:58:50 2013 +++ src/sbin/disklabel/main.c Mon May 13 14:01:08 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.33 2013/05/13 17:58:50 christos Exp $ */ +/* $NetBSD: main.c,v 1.34 2013/05/13 18:01:08 christos Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.33 2013/05/13 17:58:50 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.34 2013/05/13 18:01:08 christos Exp $"); #endif #endif /* not lint */ @@ -1136,7 +1136,7 @@ find_label(int f, u_int sector) { struct disklabel *disk_lp, hlp; int i; - u_int offset; + off_t offset; const char *is_deleted; bootarea_len = pread(f, bootarea, sizeof bootarea, @@ -1172,19 +1172,19 @@ find_label(int f, u_int sector) if (target32toh(disk_lp->d_magic) == DISKMAGIC_REV && target32toh(disk_lp->d_magic2) == DISKMAGIC_REV) warnx("ignoring %sbyteswapped label" -" at offset %u from sector %u", +" at offset %td from sector %u", is_deleted, offset, sector); continue; } if (target16toh(disk_lp->d_npartitions) > maxpartitions || dkcksum_target(disk_lp) != 0) { if (verbose > 0) -warnx("corrupt label found at offset %u in " +warnx("corrupt label found at offset %td in " "sector %u", offset, sector); continue; } if (verbose > 1) - warnx("%slabel found at offset %u from sector %u", + warnx("%slabel found at offset %td from sector %u", is_deleted, offset, sector); if (!read_all) return disk_lp; @@ -1192,7 +1192,7 @@ find_label(int f, u_int sector) /* To print all the labels we have to do it here */ /* XXX: maybe we should compare them? */ targettohlabel(&hlp, disk_lp); - printf("# %ssector %u offset %u bytes\n", + printf("# %ssector %u offset %td bytes\n", is_deleted, sector, offset); if (tflag) makedisktab(stdout, &hlp);
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Mon May 13 17:58:50 UTC 2013 Modified Files: src/sbin/disklabel: main.c Log Message: CVE 1020935: Prevent overflow To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.32 src/sbin/disklabel/main.c:1.33 --- src/sbin/disklabel/main.c:1.32 Sun May 5 11:59:42 2013 +++ src/sbin/disklabel/main.c Mon May 13 13:58:50 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.32 2013/05/05 15:59:42 skrll Exp $ */ +/* $NetBSD: main.c,v 1.33 2013/05/13 17:58:50 christos Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.32 2013/05/05 15:59:42 skrll Exp $"); +__RCSID("$NetBSD: main.c,v 1.33 2013/05/13 17:58:50 christos Exp $"); #endif #endif /* not lint */ @@ -1835,6 +1835,12 @@ getasciilabel(FILE *f, struct disklabel errors++; continue; } + if (part >= __arraycount(lp->d_partitions)) { + warnx("line %d: partition id %s, >= %zu", lineno, + cp, __arraycount(lp->d_partitions)); + errors++; + continue; + } pp = &lp->d_partitions[part]; NXTXNUM(pp->p_size);
CVS commit: src/sbin/disklabel
Module Name:src Committed By: skrll Date: Sun May 5 15:59:43 UTC 2013 Modified Files: src/sbin/disklabel: main.c Log Message: Add an arch_endian entry for x86_64. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.31 src/sbin/disklabel/main.c:1.32 --- src/sbin/disklabel/main.c:1.31 Fri May 3 21:23:36 2013 +++ src/sbin/disklabel/main.c Sun May 5 15:59:42 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.31 2013/05/03 21:23:36 matt Exp $ */ +/* $NetBSD: main.c,v 1.32 2013/05/05 15:59:42 skrll Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.31 2013/05/03 21:23:36 matt Exp $"); +__RCSID("$NetBSD: main.c,v 1.32 2013/05/05 15:59:42 skrll Exp $"); #endif #endif /* not lint */ @@ -305,6 +305,7 @@ static const struct arch_endian { { LITTLE_ENDIAN, "mips64el" }, { LITTLE_ENDIAN, "sh3el" }, { LITTLE_ENDIAN, "vax" }, + { LITTLE_ENDIAN, "x86_64" }, { BIG_ENDIAN, "armeb" }, { BIG_ENDIAN, "earmeb" },
CVS commit: src/sbin/disklabel
Module Name:src Committed By: matt Date: Fri May 3 21:23:36 UTC 2013 Modified Files: src/sbin/disklabel: main.c Log Message: Make sure to initialize byteorder if native. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.30 src/sbin/disklabel/main.c:1.31 --- src/sbin/disklabel/main.c:1.30 Fri May 3 16:39:00 2013 +++ src/sbin/disklabel/main.c Fri May 3 21:23:36 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.30 2013/05/03 16:39:00 matt Exp $ */ +/* $NetBSD: main.c,v 1.31 2013/05/03 21:23:36 matt Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.30 2013/05/03 16:39:00 matt Exp $"); +__RCSID("$NetBSD: main.c,v 1.31 2013/05/03 21:23:36 matt Exp $"); #endif #endif /* not lint */ @@ -447,7 +447,7 @@ main(int argc, char *argv[]) labelsector = native_params.labelsector = getlabelsector(); labelusesmbr = native_params.labelusesmbr = getlabelusesmbr(); maxpartitions = native_params.maxpartitions = getmaxpartitions(); - native_params.byteorder = BYTE_ORDER; + byteorder = native_params.byteorder = BYTE_ORDER; #endif if ((cp = getenv("MACHINE")) != NULL) {
CVS commit: src/sbin/disklabel
Module Name:src Committed By: matt Date: Fri May 3 16:39:00 UTC 2013 Modified Files: src/sbin/disklabel: main.c Log Message: Fix tpyos. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.29 src/sbin/disklabel/main.c:1.30 --- src/sbin/disklabel/main.c:1.29 Fri May 3 16:05:12 2013 +++ src/sbin/disklabel/main.c Fri May 3 16:39:00 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.29 2013/05/03 16:05:12 matt Exp $ */ +/* $NetBSD: main.c,v 1.30 2013/05/03 16:39:00 matt Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.29 2013/05/03 16:05:12 matt Exp $"); +__RCSID("$NetBSD: main.c,v 1.30 2013/05/03 16:39:00 matt Exp $"); #endif #endif /* not lint */ @@ -560,7 +560,7 @@ main(int argc, char *argv[]) } bswap_p = (byteorder != BYTE_ORDER); #ifdef DEBUG - printf("labelusesmbr=%d labelsector=%u labeloffset=%u maxparitions=%u\n", + printf("labelusesmbr=%d labelsector=%u labeloffset=%u maxpartitions=%u\n", labelusesmbr, labelsector, labeloffset, maxpartitions); printf("byteorder=%d bswap_p=%d\n", byteorder, bswap_p); #endif @@ -573,7 +573,7 @@ main(int argc, char *argv[]) native_p = native_params.labelusesmbr == labelusesmbr && native_params.labelsector == labelsector && native_params.labeloffset == labeloffset - && maxparitions <= native_params.maxpartitions + && maxpartitions <= native_params.maxpartitions && !bswap_p; if (!native_p) Fflag = rflag = 1;
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Thu Jan 17 18:33:58 UTC 2013 Modified Files: src/sbin/disklabel: extern.h interact.c main.c Log Message: move dk_ioctl to a header file for the benefit of x-building. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sbin/disklabel/extern.h cvs rdiff -u -r1.36 -r1.37 src/sbin/disklabel/interact.c cvs rdiff -u -r1.27 -r1.28 src/sbin/disklabel/main.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/disklabel/extern.h diff -u src/sbin/disklabel/extern.h:1.11 src/sbin/disklabel/extern.h:1.12 --- src/sbin/disklabel/extern.h:1.11 Tue Oct 20 21:07:46 2009 +++ src/sbin/disklabel/extern.h Thu Jan 17 13:33:58 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.11 2009/10/21 01:07:46 snj Exp $ */ +/* $NetBSD: extern.h,v 1.12 2013/01/17 18:33:58 christos Exp $ */ /* * Copyright (c) 1997 Christos Zoulas. All rights reserved. @@ -34,3 +34,15 @@ int list_fs_types(void); extern char specname[]; extern int Cflag; + +#ifdef HAVE_NBTOOL_CONFIG_H +static int +dk_ioctl(int f, void *arg) +{ + errno = ENOTTY; + return -1; +} +# define dk_ioctl(f, cmd, arg) dk_ioctl(f, arg) +#else +# define dk_ioctl(f, cmd, arg) ioctl(f, cmd, arg) +#endif /* HAVE_NBTOOL_CONFIG_H */ Index: src/sbin/disklabel/interact.c diff -u src/sbin/disklabel/interact.c:1.36 src/sbin/disklabel/interact.c:1.37 --- src/sbin/disklabel/interact.c:1.36 Tue Jan 15 18:52:48 2013 +++ src/sbin/disklabel/interact.c Thu Jan 17 13:33:58 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: interact.c,v 1.36 2013/01/15 23:52:48 christos Exp $ */ +/* $NetBSD: interact.c,v 1.37 2013/01/17 18:33:58 christos Exp $ */ /* * Copyright (c) 1997 Christos Zoulas. All rights reserved. @@ -30,7 +30,7 @@ #include #ifndef lint -__RCSID("$NetBSD: interact.c,v 1.36 2013/01/15 23:52:48 christos Exp $"); +__RCSID("$NetBSD: interact.c,v 1.37 2013/01/17 18:33:58 christos Exp $"); #endif /* lint */ #include @@ -112,7 +112,7 @@ cmd_adjust(struct disklabel *lp, char *s { struct disklabel dl; - if (ioctl(fd, DIOCGDEFLABEL, &dl) == -1) { + if (dk_ioctl(fd, DIOCGDEFLABEL, &dl) == -1) { warn("Cannot get default label"); return; } Index: src/sbin/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.27 src/sbin/disklabel/main.c:1.28 --- src/sbin/disklabel/main.c:1.27 Sun Apr 8 03:59:53 2012 +++ src/sbin/disklabel/main.c Thu Jan 17 13:33:58 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.27 2012/04/08 07:59:53 cyber Exp $ */ +/* $NetBSD: main.c,v 1.28 2013/01/17 18:33:58 christos Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.27 2012/04/08 07:59:53 cyber Exp $"); +__RCSID("$NetBSD: main.c,v 1.28 2013/01/17 18:33:58 christos Exp $"); #endif #endif /* not lint */ @@ -214,16 +214,6 @@ opendisk(const char *path, int flags, ch strlcpy(buf, path, buflen); return f; } - -static int -dk_ioctl(int f, void *arg) -{ - errno = ENOTTY; - return -1; -} -#define dk_ioctl(f, cmd, arg) dk_ioctl(f, arg) -#else -#define dk_ioctl(f, cmd, arg) ioctl(f, cmd, arg) #endif /* HAVE_NBTOOL_CONFIG_H */ static daddr_t
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Tue Jan 15 23:52:48 UTC 2013 Modified Files: src/sbin/disklabel: interact.c Log Message: - simplify getinput. - add adjust command. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sbin/disklabel/interact.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/disklabel/interact.c diff -u src/sbin/disklabel/interact.c:1.35 src/sbin/disklabel/interact.c:1.36 --- src/sbin/disklabel/interact.c:1.35 Thu Jan 6 16:39:01 2011 +++ src/sbin/disklabel/interact.c Tue Jan 15 18:52:48 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: interact.c,v 1.35 2011/01/06 21:39:01 apb Exp $ */ +/* $NetBSD: interact.c,v 1.36 2013/01/15 23:52:48 christos Exp $ */ /* * Copyright (c) 1997 Christos Zoulas. All rights reserved. @@ -30,7 +30,7 @@ #include #ifndef lint -__RCSID("$NetBSD: interact.c,v 1.35 2011/01/06 21:39:01 apb Exp $"); +__RCSID("$NetBSD: interact.c,v 1.36 2013/01/15 23:52:48 christos Exp $"); #endif /* lint */ #include @@ -40,7 +40,9 @@ __RCSID("$NetBSD: interact.c,v 1.35 2011 #include #include #include +#include #include +#include #if HAVE_NBTOOL_CONFIG_H #define getmaxpartitions() MAXPARTITIONS @@ -53,6 +55,7 @@ __RCSID("$NetBSD: interact.c,v 1.35 2011 #include "extern.h" static void cmd_help(struct disklabel *, char *, int); +static void cmd_adjust(struct disklabel *, char *, int); static void cmd_chain(struct disklabel *, char *, int); static void cmd_print(struct disklabel *, char *, int); static void cmd_printall(struct disklabel *, char *, int); @@ -63,7 +66,7 @@ static void cmd_round(struct disklabel * static void cmd_name(struct disklabel *, char *, int); static void cmd_listfstypes(struct disklabel *, char *, int); static int runcmd(struct disklabel *, char *, int); -static int getinput(const char *, const char *, const char *, char *); +static int getinput(char *, const char *, ...) __printflike(2, 3); static int alphacmp(const void *, const void *); static void defnum(struct disklabel *, char *, uint32_t); static void dumpnames(const char *, const char * const *, size_t); @@ -78,6 +81,7 @@ static struct cmds { const char *help; } cmds[] = { { "?", cmd_help, "print this menu" }, + { "A", cmd_adjust, "adjust the label size to the max disk size" }, { "C", cmd_chain, "make partitions contiguous" }, { "E", cmd_printall, "print disk label and current partition table"}, { "I", cmd_info, "change label information" }, @@ -91,7 +95,6 @@ static struct cmds { }; - static void cmd_help(struct disklabel *lp, char *s, int fd) { @@ -105,13 +108,39 @@ cmd_help(struct disklabel *lp, char *s, static void +cmd_adjust(struct disklabel *lp, char *s, int fd) +{ + struct disklabel dl; + + if (ioctl(fd, DIOCGDEFLABEL, &dl) == -1) { + warn("Cannot get default label"); + return; + } + + if (dl.d_secperunit != lp->d_secperunit) { + char line[BUFSIZ]; + int i = getinput(line, "Adjust disklabel sector from %" PRIu32 + " to %" PRIu32 " [n]? ", lp->d_secperunit, dl.d_secperunit); + if (i <= 0) + return; + if (line[0] != 'Y' && line[0] != 'y') + return; + lp->d_secperunit = dl.d_secperunit; + return; + } + + printf("Already at %" PRIu32 " sectors\n", dl.d_secperunit); + return; +} + +static void cmd_chain(struct disklabel *lp, char *s, int fd) { int i; char line[BUFSIZ]; - i = getinput(":", "Automatically adjust partitions", - chaining ? "yes" : "no", line); + i = getinput(line, "Automatically adjust partitions [%s]? ", + chaining ? "yes" : "no"); if (i <= 0) return; @@ -150,7 +179,6 @@ static void cmd_info(struct disklabel *lp, char *s, int fd) { char line[BUFSIZ]; - char def[BUFSIZ]; int v, i; u_int32_t u; @@ -162,8 +190,7 @@ cmd_info(struct disklabel *lp, char *s, i = lp->d_type; if (i < 0 || i >= DKMAXTYPES) i = 0; - snprintf(def, sizeof(def), "%s", dktypenames[i]); - i = getinput(":", "Disk type [?]", def, line); + i = getinput(line, "Disk type [%s]: ", dktypenames[i]); if (i == -1) return; else if (i == 0) @@ -190,9 +217,8 @@ cmd_info(struct disklabel *lp, char *s, } /* d_typename */ - snprintf(def, sizeof(def), "%.*s", + i = getinput(line, "Disk name [%.*s]: ", (int) sizeof(lp->d_typename), lp->d_typename); - i = getinput(":", "Disk name", def, line); if (i == -1) return; else if (i == 1) @@ -203,8 +229,8 @@ cmd_info(struct disklabel *lp, char *s, /* d_npartitions */ for (;;) { - snprintf(def, sizeof(def), "%" PRIu16, lp->d_npartitions); - i = getinput(":", "Number of partitions", def, line); + i = getinput(line, "Number of partitions [%" PRIu16 "]: ", + lp->d_npartitions); if (i == -1) return; else if (i == 0) @@ -219,8 +245,8 @@ cmd_info(struct disklabel *lp, char *s, /* d_secsize */ for (;;) { - snprintf(def, sizeof(def), "%" PRIu32, lp->d_secsize); - i = getinput(":",
CVS commit: src/sbin/disklabel
Module Name:src Committed By: cyber Date: Sun Apr 8 07:59:53 UTC 2012 Modified Files: src/sbin/disklabel: main.c Log Message: PR bin/45744 from Julian Fagir Removing options that have had implementations removed. -b: removed in -r1.4 -s: removed in -r1.2 To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.26 src/sbin/disklabel/main.c:1.27 --- src/sbin/disklabel/main.c:1.26 Tue Aug 30 12:39:52 2011 +++ src/sbin/disklabel/main.c Sun Apr 8 07:59:53 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.26 2011/08/30 12:39:52 bouyer Exp $ */ +/* $NetBSD: main.c,v 1.27 2012/04/08 07:59:53 cyber Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.26 2011/08/30 12:39:52 bouyer Exp $"); +__RCSID("$NetBSD: main.c,v 1.27 2012/04/08 07:59:53 cyber Exp $"); #endif #endif /* not lint */ @@ -285,7 +285,7 @@ main(int argc, char *argv[]) #endif error = 0; - while ((ch = getopt(argc, argv, "ACDFINRWb:ef:ilmrs:tvw")) != -1) { + while ((ch = getopt(argc, argv, "ACDFINRWef:ilmrtvw")) != -1) { old_op = op; switch (ch) { case 'A': /* Action all labels */
CVS commit: src/sbin/disklabel
Module Name:src Committed By: phx Date: Thu Aug 18 08:42:07 UTC 2011 Modified Files: src/sbin/disklabel: Makefile Log Message: Define USE_MBR for ofppc. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sbin/disklabel/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/disklabel/Makefile diff -u src/sbin/disklabel/Makefile:1.67 src/sbin/disklabel/Makefile:1.68 --- src/sbin/disklabel/Makefile:1.67 Sat Feb 12 22:23:01 2011 +++ src/sbin/disklabel/Makefile Thu Aug 18 08:42:07 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.67 2011/02/12 22:23:01 dholland Exp $ +# $NetBSD: Makefile,v 1.68 2011/08/18 08:42:07 phx Exp $ # @(#)Makefile 8.2 (Berkeley) 3/17/94 PROG= disklabel @@ -34,6 +34,7 @@ || ${MACHINE} == "macppc" \ || ${MACHINE} == "mmeye" \ || ${MACHINE} == "netwinder" \ + || ${MACHINE} == "ofppc" \ || ${MACHINE} == "prep" \ || ${MACHINE} == "shark" \ || ${MACHINE} == "zaurus" \
CVS commit: src/sbin/disklabel
Module Name:src Committed By: wiz Date: Tue Aug 2 10:21:12 UTC 2011 Modified Files: src/sbin/disklabel: disklabel.8 Log Message: Sort sections. Remove comma in enumeration of two items. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sbin/disklabel/disklabel.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/disklabel/disklabel.8 diff -u src/sbin/disklabel/disklabel.8:1.63 src/sbin/disklabel/disklabel.8:1.64 --- src/sbin/disklabel/disklabel.8:1.63 Mon Jul 25 16:31:05 2011 +++ src/sbin/disklabel/disklabel.8 Tue Aug 2 10:21:12 2011 @@ -1,4 +1,4 @@ -.\" $NetBSD: disklabel.8,v 1.63 2011/07/25 16:31:05 christos Exp $ +.\" $NetBSD: disklabel.8,v 1.64 2011/08/02 10:21:12 wiz Exp $ .\" .\" Copyright (c) 1987, 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -209,6 +209,10 @@ could update the bootstrap code on some architectures. This functionality has been subsumed by .Xr installboot 8 . +.Sh FILES +.Bl -tag -width /etc/disktab -compact +.It Pa /etc/disktab +.El .Sh EXIT STATUS The exit status of .Nm @@ -228,10 +232,6 @@ One or more warnings occured while reading the disklabel. Subtract 100 to get the number of warnings detected. .El -.Sh FILES -.Bl -tag -width /etc/disktab -compact -.It Pa /etc/disktab -.El .Sh EXAMPLES .Dl Ic disklabel sd0 .Pp @@ -303,7 +303,7 @@ .Nm structure stored on disk cannot support partitions/disks greater than 2TB. Please use -.Xr gpt 8 , +.Xr gpt 8 and .Xr dkctl 8 to manage partitions and disks larger than 2TB.
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Mon Jul 25 16:31:05 UTC 2011 Modified Files: src/sbin/disklabel: disklabel.8 Log Message: mention that we don't handle more than 2TB disks/partitions. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sbin/disklabel/disklabel.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/disklabel/disklabel.8 diff -u src/sbin/disklabel/disklabel.8:1.62 src/sbin/disklabel/disklabel.8:1.63 --- src/sbin/disklabel/disklabel.8:1.62 Sat Nov 28 05:28:22 2009 +++ src/sbin/disklabel/disklabel.8 Mon Jul 25 12:31:05 2011 @@ -1,4 +1,4 @@ -.\" $NetBSD: disklabel.8,v 1.62 2009/11/28 10:28:22 abs Exp $ +.\" $NetBSD: disklabel.8,v 1.63 2011/07/25 16:31:05 christos Exp $ .\" .\" Copyright (c) 1987, 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 .\" -.Dd November 28, 2009 +.Dd July 25, 2011 .Dt DISKLABEL 8 .Os .Sh NAME @@ -293,10 +293,21 @@ .Xr disktab 5 , .Xr dkctl 8 , .Xr fdisk 8 , +.Xr gpt 8 , .Xr installboot 8 , .Xr mbrlabel 8 , .Xr mscdlabel 8 .Sh BUGS +.Pp +The +.Nm +structure stored on disk cannot support partitions/disks greater than 2TB. +Please use +.Xr gpt 8 , +and +.Xr dkctl 8 +to manage partitions and disks larger than 2TB. +.Pp If the disk partition is not specified in the disk name (i.e., .Ar xy0
CVS commit: src/sbin/disklabel
Module Name:src Committed By: dholland Date: Sat Feb 12 22:23:02 UTC 2011 Modified Files: src/sbin/disklabel: Makefile Log Message: Disable COMPAT_386BSD_MBRPART. The code is still here if anyone needs it for some reason. (But I have no idea why that would be -- if you have one of these really ancient partitions and you're about to run disklabel, you can easily run fdisk first and change the partition type to NetBSD.) As it stands, the code will munch FreeBSD installs under some circumstances, which is really not acceptable behavior. The code, along with the kernel support that's been disabled by default for several years, and some related but less dangerous code in sysinst, should prboably be removed entirely after -6 is branched. Discussed on tech-kern and tech-userlevel; closes PR 44496. This is also almost certainly the cause of PR 42521 and PR 38841. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sbin/disklabel/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/disklabel/Makefile diff -u src/sbin/disklabel/Makefile:1.66 src/sbin/disklabel/Makefile:1.67 --- src/sbin/disklabel/Makefile:1.66 Sun Dec 13 05:01:32 2009 +++ src/sbin/disklabel/Makefile Sat Feb 12 22:23:01 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.66 2009/12/13 05:01:32 nakayama Exp $ +# $NetBSD: Makefile,v 1.67 2011/02/12 22:23:01 dholland Exp $ # @(#)Makefile 8.2 (Berkeley) 3/17/94 PROG= disklabel @@ -40,8 +40,8 @@ ) # use MBR partition info CPPFLAGS+= -DUSE_MBR -# recognize old MBR partition ID for a while -CPPFLAGS+= -DCOMPAT_386BSD_MBRPART +# do not recognize old MBR partition ID any more +#CPPFLAGS+= -DCOMPAT_386BSD_MBRPART .endif .if (${MACHINE} == "acorn32" || ${MACHINE} == "acorn26")
CVS commit: src/sbin/disklabel
Module Name:src Committed By: apb Date: Thu Jan 6 21:39:01 UTC 2011 Modified Files: src/sbin/disklabel: interact.c main.c printlabel.c Log Message: Change printf formats to match the data type of the values being printed. There's now a lot of PRIu16 and PRIu32, some PRIu8, some SCNu32, and a few cases where %u and %d were reversed. Multiplication of 32-bit and 8-bit values is cast to uint64_t and printed with PRIu64. Inspired by a report from Patrick Welche on current-users. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sbin/disklabel/interact.c cvs rdiff -u -r1.23 -r1.24 src/sbin/disklabel/main.c cvs rdiff -u -r1.15 -r1.16 src/sbin/disklabel/printlabel.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/disklabel/interact.c diff -u src/sbin/disklabel/interact.c:1.34 src/sbin/disklabel/interact.c:1.35 --- src/sbin/disklabel/interact.c:1.34 Fri May 28 07:40:53 2010 +++ src/sbin/disklabel/interact.c Thu Jan 6 21:39:01 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: interact.c,v 1.34 2010/05/28 07:40:53 dholland Exp $ */ +/* $NetBSD: interact.c,v 1.35 2011/01/06 21:39:01 apb Exp $ */ /* * Copyright (c) 1997 Christos Zoulas. All rights reserved. @@ -30,7 +30,7 @@ #include #ifndef lint -__RCSID("$NetBSD: interact.c,v 1.34 2010/05/28 07:40:53 dholland Exp $"); +__RCSID("$NetBSD: interact.c,v 1.35 2011/01/06 21:39:01 apb Exp $"); #endif /* lint */ #include @@ -203,13 +203,13 @@ /* d_npartitions */ for (;;) { - snprintf(def, sizeof(def), "%u", lp->d_npartitions); + snprintf(def, sizeof(def), "%" PRIu16, lp->d_npartitions); i = getinput(":", "Number of partitions", def, line); if (i == -1) return; else if (i == 0) break; - if (sscanf(line, "%u", &u) != 1) { + if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid number of partitions `%s'\n", line); continue; } @@ -219,13 +219,13 @@ /* d_secsize */ for (;;) { - snprintf(def, sizeof(def), "%u", lp->d_secsize); + snprintf(def, sizeof(def), "%" PRIu32, lp->d_secsize); i = getinput(":", "Sector size (bytes)", def, line); if (i == -1) return; else if (i == 0) break; - if (sscanf(line, "%u", &u) != 1) { + if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid sector size `%s'\n", line); continue; } @@ -235,13 +235,13 @@ /* d_nsectors */ for (;;) { - snprintf(def, sizeof(def), "%u", lp->d_nsectors); + snprintf(def, sizeof(def), "%" PRIu32, lp->d_nsectors); i = getinput(":", "Number of sectors per track", def, line); if (i == -1) return; else if (i == 0) break; - if (sscanf(line, "%u", &u) != 1) { + if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid number of sectors `%s'\n", line); continue; } @@ -251,13 +251,13 @@ /* d_ntracks */ for (;;) { - snprintf(def, sizeof(def), "%u", lp->d_ntracks); + snprintf(def, sizeof(def), "%" PRIu32, lp->d_ntracks); i = getinput(":", "Number of tracks per cylinder", def, line); if (i == -1) return; else if (i == 0) break; - if (sscanf(line, "%u", &u) != 1) { + if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid number of tracks `%s'\n", line); continue; } @@ -267,13 +267,13 @@ /* d_secpercyl */ for (;;) { - snprintf(def, sizeof(def), "%u", lp->d_secpercyl); + snprintf(def, sizeof(def), "%" PRIu32, lp->d_secpercyl); i = getinput(":", "Number of sectors/cylinder", def, line); if (i == -1) return; else if (i == 0) break; - if (sscanf(line, "%u", &u) != 1) { + if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid number of sector/cylinder `%s'\n", line); continue; @@ -284,13 +284,13 @@ /* d_ncylinders */ for (;;) { - snprintf(def, sizeof(def), "%u", lp->d_ncylinders); + snprintf(def, sizeof(def), "%" PRIu32, lp->d_ncylinders); i = getinput(":", "Total number of cylinders", def, line); if (i == -1) return; else if (i == 0) break; - if (sscanf(line, "%u", &u) != 1) { + if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid sector size `%s'\n", line); continue; } @@ -300,13 +300,13 @@ /* d_secperunit */ for (;;) { - snprintf(def, sizeof(def), "%u", lp->d_secperunit); + snprintf(def, sizeof(def), "%" PRIu32, lp->d_secperunit); i = getinput(":", "Total number of sectors", def, line); if (i == -1) return; else if (i == 0) break; - if (sscanf(line, "%u", &u) != 1) { + if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid number of sectors `%s'\n", line); continue; } @@ -318,13 +318,13 @@ /* d_interleave */ for (;;) { - snprintf(def, sizeof(def), "%u", lp->d_interleave); + snprintf(def, sizeof(def), "%" PRIu16, lp->d_interleave); i = getinput(":", "Hardware sectors interleave", def, line); if (i == -1) return; else if (i == 0) break; - if (sscanf(line, "%u", &u) != 1) { + if (sscanf(line,
CVS commit: src/sbin/disklabel
Module Name:src Committed By: christos Date: Thu Jan 6 19:34:28 UTC 2011 Modified Files: src/sbin/disklabel: main.c Log Message: match printf formats and types from Patrick Welche To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.22 src/sbin/disklabel/main.c:1.23 --- src/sbin/disklabel/main.c:1.22 Tue Jan 5 10:45:26 2010 +++ src/sbin/disklabel/main.c Thu Jan 6 14:34:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.22 2010/01/05 15:45:26 tsutsui Exp $ */ +/* $NetBSD: main.c,v 1.23 2011/01/06 19:34:28 christos Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.22 2010/01/05 15:45:26 tsutsui Exp $"); +__RCSID("$NetBSD: main.c,v 1.23 2011/01/06 19:34:28 christos Exp $"); #endif #endif /* not lint */ @@ -1106,40 +1106,40 @@ if ((unsigned) lp->d_type < DKMAXTYPES) (void) fprintf(f, "%s:", dktypenames[lp->d_type]); else - (void) fprintf(f, "unknown%d:", lp->d_type); + (void) fprintf(f, "unknown%" PRIu16 ":", lp->d_type); - (void) fprintf(f, "se#%d:", lp->d_secsize); - (void) fprintf(f, "ns#%d:", lp->d_nsectors); - (void) fprintf(f, "nt#%d:", lp->d_ntracks); - (void) fprintf(f, "sc#%d:", lp->d_secpercyl); - (void) fprintf(f, "nc#%d:", lp->d_ncylinders); + (void) fprintf(f, "se#%" PRIu32 ":", lp->d_secsize); + (void) fprintf(f, "ns#%" PRIu32 ":", lp->d_nsectors); + (void) fprintf(f, "nt#%" PRIu32 ":", lp->d_ntracks); + (void) fprintf(f, "sc#%" PRIu32 ":", lp->d_secpercyl); + (void) fprintf(f, "nc#%" PRIu32 ":", lp->d_ncylinders); if ((lp->d_secpercyl * lp->d_ncylinders) != lp->d_secperunit) { - (void) fprintf(f, "%ssu#%d:", did, lp->d_secperunit); + (void) fprintf(f, "%ssu#%" PRIu32 ":", did, lp->d_secperunit); did = ""; } if (lp->d_rpm != 3600) { - (void) fprintf(f, "%srm#%d:", did, lp->d_rpm); + (void) fprintf(f, "%srm#%" PRIu16 ":", did, lp->d_rpm); did = ""; } if (lp->d_interleave != 1) { - (void) fprintf(f, "%sil#%d:", did, lp->d_interleave); + (void) fprintf(f, "%sil#%" PRIu16 ":", did, lp->d_interleave); did = ""; } if (lp->d_trackskew != 0) { - (void) fprintf(f, "%ssk#%d:", did, lp->d_trackskew); + (void) fprintf(f, "%ssk#%" PRIu16 ":", did, lp->d_trackskew); did = ""; } if (lp->d_cylskew != 0) { - (void) fprintf(f, "%scs#%d:", did, lp->d_cylskew); + (void) fprintf(f, "%scs#%" PRIu16 ":", did, lp->d_cylskew); did = ""; } if (lp->d_headswitch != 0) { - (void) fprintf(f, "%shs#%d:", did, lp->d_headswitch); + (void) fprintf(f, "%shs#%" PRIu16 ":", did, lp->d_headswitch); did = ""; } if (lp->d_trkseek != 0) { - (void) fprintf(f, "%sts#%d:", did, lp->d_trkseek); + (void) fprintf(f, "%sts#%" PRIu32 ":", did, lp->d_trkseek); did = ""; } #ifdef notyet @@ -1150,22 +1150,22 @@ if (i < 0) i = 0; for (j = 0; j <= i; j++) - (void) fprintf(f, "%d ", lp->d_drivedata[j]); + (void) fprintf(f, "%" PRIu32 " ", lp->d_drivedata[j]); #endif /* notyet */ pp = lp->d_partitions; for (i = 0; i < lp->d_npartitions; i++, pp++) { if (pp->p_size) { char c = 'a' + i; (void) fprintf(f, "\\\n\t:"); - (void) fprintf(f, "p%c#%d:", c, pp->p_size); - (void) fprintf(f, "o%c#%d:", c, pp->p_offset); + (void) fprintf(f, "p%c#%" PRIu32 ":", c, pp->p_size); + (void) fprintf(f, "o%c#%" PRIu32 ":", c, pp->p_offset); if (pp->p_fstype != FS_UNUSED) { if ((unsigned) pp->p_fstype < FSMAXTYPES) (void) fprintf(f, "t%c=%s:", c, fstypenames[pp->p_fstype]); else - (void) fprintf(f, "t%c=unknown%d:", - c, pp->p_fstype); + (void) fprintf(f, "t%c=unknown%" PRIu8 + ":", c, pp->p_fstype); } switch (pp->p_fstype) { @@ -1177,9 +1177,10 @@ case FS_EX2FS: case FS_ADOS: case FS_APPLEUFS: -(void) fprintf(f, "b%c#%d:", c, -pp->p_fsize * pp->p_frag); -(void) fprintf(f, "f%c#%d:", c, pp->p_fsize); +(void) fprintf(f, "b%c#%" PRIu64 ":", c, +(uint64_t)pp->p_fsize * pp->p_frag); +(void) fprintf(f, "f%c#%" PRIu32 ":", c, +pp->p_fsize); break; default: break; @@ -1709,34 +1710,34 @@ errors = 0; if (lp->d_secsize == 0) { - warnx("sector size %d", lp->d_secsize); + warnx("sector size %" PRIu32, lp->d_secsize); return (1); } if (lp->d_nsectors == 0) { - warnx("sectors/track %d", lp->d_nsectors); + warnx("sectors/track %" PRIu32, lp->d_nsectors); return (1); } if (lp->d_ntracks == 0) { - warnx("tracks/cylinder %d", lp->d_ntracks); + warnx("tracks/cylinder %" PRIu32, lp->d_ntracks); return (1); } if (lp->d_ncylinders == 0) { - warnx("cyli
CVS commit: src/sbin/disklabel
Module Name:src Committed By: dholland Date: Fri May 28 07:40:53 UTC 2010 Modified Files: src/sbin/disklabel: interact.c Log Message: Change getnum() to use intmax_t instead of int, so it doesn't overflow between 2^31 and 2^32. Adjust call sites accordingly. PR 43354. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sbin/disklabel/interact.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/disklabel/interact.c diff -u src/sbin/disklabel/interact.c:1.33 src/sbin/disklabel/interact.c:1.34 --- src/sbin/disklabel/interact.c:1.33 Sat Nov 28 10:52:10 2009 +++ src/sbin/disklabel/interact.c Fri May 28 07:40:53 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: interact.c,v 1.33 2009/11/28 10:52:10 abs Exp $ */ +/* $NetBSD: interact.c,v 1.34 2010/05/28 07:40:53 dholland Exp $ */ /* * Copyright (c) 1997 Christos Zoulas. All rights reserved. @@ -30,7 +30,7 @@ #include #ifndef lint -__RCSID("$NetBSD: interact.c,v 1.33 2009/11/28 10:52:10 abs Exp $"); +__RCSID("$NetBSD: interact.c,v 1.34 2010/05/28 07:40:53 dholland Exp $"); #endif /* lint */ #include @@ -67,7 +67,7 @@ static int alphacmp(const void *, const void *); static void defnum(struct disklabel *, char *, uint32_t); static void dumpnames(const char *, const char * const *, size_t); -static int getnum(struct disklabel *, char *, int); +static intmax_t getnum(struct disklabel *, char *, intmax_t); static int rounding = 0; /* sector rounding */ static int chaining = 0; /* make partitions contiguous */ @@ -444,6 +444,7 @@ cmd_part(struct disklabel *lp, char *s, int fd) { int i; + intmax_t im; char line[BUFSIZ]; char def[BUFSIZ]; int part; @@ -503,14 +504,15 @@ cp[line[0] - 'a'].p_size; } } else { - if ((i = getnum(lp, line, 0)) == -1 || i < 0) { + if ((im = getnum(lp, line, 0)) == -1 || im < 0) { printf("Bad offset `%s'\n", line); continue; - } else if ((uint32_t)i > lp->d_secperunit) { + } else if (im > 0xLL || + (uint32_t)im > lp->d_secperunit) { printf("Offset `%s' out of range\n", line); continue; } - p->p_offset = i; + p->p_offset = (uint32_t)im; } break; } @@ -522,16 +524,16 @@ return; else if (i == 0) break; - if ((i = getnum(lp, line, lp->d_secperunit - p->p_offset)) + if ((im = getnum(lp, line, lp->d_secperunit - p->p_offset)) == -1) { printf("Bad size `%s'\n", line); continue; - } else if - ((i + p->p_offset) > lp->d_secperunit) { + } else if (im > 0xLL || + (im + p->p_offset) > lp->d_secperunit) { printf("Size `%s' out of range\n", line); continue; } - p->p_size = i; + p->p_size = im; break; } @@ -708,15 +710,15 @@ } -static int -getnum(struct disklabel *lp, char *buf, int max) +static intmax_t +getnum(struct disklabel *lp, char *buf, intmax_t defaultval) { char *ep; double d; - int rv; + intmax_t rv; - if (max && buf[0] == '$' && buf[1] == 0) - return max; + if (defaultval && buf[0] == '$' && buf[1] == 0) + return defaultval; d = strtod(buf, &ep); if (buf == ep) @@ -729,32 +731,32 @@ case '\0': case 's': case 'S': - rv = (int) d; + rv = (intmax_t) d; break; case 'c': case 'C': - rv = (int) (d * lp->d_secpercyl); + rv = (intmax_t) (d * lp->d_secpercyl); break; case 'k': case 'K': - rv = (int) (d * 1024 / lp->d_secsize); + rv = (intmax_t) (d * 1024 / lp->d_secsize); break; case 'm': case 'M': - rv = (int) (d * 1024 * 1024 / lp->d_secsize); + rv = (intmax_t) (d * 1024 * 1024 / lp->d_secsize); break; case 'g': case 'G': - rv = (int) (d * 1024 * 1024 * 1024 / lp->d_secsize); + rv = (intmax_t) (d * 1024 * 1024 * 1024 / lp->d_secsize); break; case 't': case 'T': - rv = (int) (d * 1024 * 1024 * 1024 * 1024 / lp->d_secsize); + rv = (intmax_t) (d * 1024 * 1024 * 1024 * 1024 / lp->d_secsize); break; default:
CVS commit: src/sbin/disklabel
Module Name:src Committed By: tsutsui Date: Sat Nov 28 12:14:53 UTC 2009 Modified Files: src/sbin/disklabel: Makefile main.c Log Message: Don't use #ifdef __${MACHINE_ARCH}__ to enable machine dependent features. Instead, use proper macro defined in Makefile per ${MACHINE_ARCH}. __${MACHINE_ARCH}__ doesn't represent an architecture of tool's target but an architecture of binaries being compiled, so required features are not prolery enabled or unintentionally enabled on certain host and target combinations during src/tools build. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sbin/disklabel/Makefile cvs rdiff -u -r1.20 -r1.21 src/sbin/disklabel/main.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/disklabel/Makefile diff -u src/sbin/disklabel/Makefile:1.63 src/sbin/disklabel/Makefile:1.64 --- src/sbin/disklabel/Makefile:1.63 Sat Nov 28 11:26:36 2009 +++ src/sbin/disklabel/Makefile Sat Nov 28 12:14:53 2009 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.63 2009/11/28 11:26:36 tsutsui Exp $ +# $NetBSD: Makefile,v 1.64 2009/11/28 12:14:53 tsutsui Exp $ # @(#)Makefile 8.2 (Berkeley) 3/17/94 PROG= disklabel @@ -50,4 +50,14 @@ CPPFLAGS+= -DUSE_ACORN .endif +.if (${MACHINE_ARCH} == "alpha") +# alpha requires boot block checksum +CPPFLAGS+= -DALPHA_BOOTBLOCK_CKSUM +.endif + +.if (${MACHINE_ARCH} == "vax") +# vax requires labels in alternative sectors on SMD disk +CPPFLAGS+= -DVAX_ALTLABELS +.endif + .include Index: src/sbin/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.20 src/sbin/disklabel/main.c:1.21 --- src/sbin/disklabel/main.c:1.20 Mon May 4 18:09:04 2009 +++ src/sbin/disklabel/main.c Sat Nov 28 12:14:53 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.20 2009/05/04 18:09:04 mhitch Exp $ */ +/* $NetBSD: main.c,v 1.21 2009/11/28 12:14:53 tsutsui Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.20 2009/05/04 18:09:04 mhitch Exp $"); +__RCSID("$NetBSD: main.c,v 1.21 2009/11/28 12:14:53 tsutsui Exp $"); #endif #endif /* not lint */ @@ -535,7 +535,7 @@ } } -#ifdef __vax__ +#ifdef VAX_ALTLABELS if (lab.d_type == DTYPE_SMD && lab.d_flags & D_BADSECT && lab.d_secsize == 512) { /* Write the label to the odd sectors of the last track! */ @@ -554,7 +554,7 @@ warn("alternate label %d write", i/2); } } -#endif /* __vax__ */ +#endif /* VAX_ALTLABELS */ return 0; } @@ -978,10 +978,10 @@ if (bootarea_len <= 0) errx(1, "attempting to write after failed read"); -#ifdef __alpha__ +#ifdef ALPHA_BOOTBLOCK_CKSUM /* * The Alpha requires that the boot block be checksummed. - * The NetBSD/alpha disklabel.h provides a macro to do it. + * provides a macro to do it. */ if (sector == 0) { struct alpha_boot_block *bb; @@ -990,7 +990,7 @@ bb->bb_cksum = 0; ALPHA_BOOT_BLOCK_CKSUM(bb, &bb->bb_cksum); } -#endif /* __alpha__ */ +#endif /* ALPHA_BOOTBLOCK_CKSUM */ wlen = pwrite(f, bootarea, bootarea_len, sector * (off_t)DEV_BSIZE); if (wlen == bootarea_len)
CVS commit: src/sbin/disklabel
Module Name:src Committed By: tsutsui Date: Sat Nov 28 11:26:36 UTC 2009 Modified Files: src/sbin/disklabel: Makefile Log Message: Make dreamcast, evbsh3, and mmeye use -DUSE_MBR. All of these ports use src/sys/arch/sh3/sh3/disksubr.c which is MBR aware. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sbin/disklabel/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/disklabel/Makefile diff -u src/sbin/disklabel/Makefile:1.62 src/sbin/disklabel/Makefile:1.63 --- src/sbin/disklabel/Makefile:1.62 Sat Feb 14 13:52:51 2009 +++ src/sbin/disklabel/Makefile Sat Nov 28 11:26:36 2009 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.62 2009/02/14 13:52:51 abs Exp $ +# $NetBSD: Makefile,v 1.63 2009/11/28 11:26:36 tsutsui Exp $ # @(#)Makefile 8.2 (Berkeley) 3/17/94 PROG= disklabel @@ -22,7 +22,9 @@ || ${MACHINE} == "arc" \ || ${MACHINE} == "cats" \ || ${MACHINE} == "cobalt" \ + || ${MACHINE} == "dreamcast" \ || ${MACHINE} == "evbarm" \ + || ${MACHINE} == "evbsh3" \ || ${MACHINE} == "hpcarm" \ || ${MACHINE} == "hpcmips" \ || ${MACHINE} == "hpcsh" \ @@ -30,6 +32,7 @@ || ${MACHINE} == "iyonix" \ || ${MACHINE} == "landisk" \ || ${MACHINE} == "macppc" \ + || ${MACHINE} == "mmeye" \ || ${MACHINE} == "netwinder" \ || ${MACHINE} == "playstation2" \ || ${MACHINE} == "prep" \
CVS commit: src/sbin/disklabel
Module Name:src Committed By: abs Date: Sat Nov 28 10:52:10 UTC 2009 Modified Files: src/sbin/disklabel: interact.c Log Message: - Display "Enter '?' for help" when starting interactive mode - Use %.40g rather than %g when printing sectors and MB for existing partition size/offset. Changes [1.93802e+06c, 1953525105s, 953870M]: to: [1938021c, 1953525105s, 953869.6875M]: To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sbin/disklabel/interact.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/disklabel/interact.c diff -u src/sbin/disklabel/interact.c:1.32 src/sbin/disklabel/interact.c:1.33 --- src/sbin/disklabel/interact.c:1.32 Wed Oct 21 01:07:46 2009 +++ src/sbin/disklabel/interact.c Sat Nov 28 10:52:10 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: interact.c,v 1.32 2009/10/21 01:07:46 snj Exp $ */ +/* $NetBSD: interact.c,v 1.33 2009/11/28 10:52:10 abs Exp $ */ /* * Copyright (c) 1997 Christos Zoulas. All rights reserved. @@ -30,7 +30,7 @@ #include #ifndef lint -__RCSID("$NetBSD: interact.c,v 1.32 2009/10/21 01:07:46 snj Exp $"); +__RCSID("$NetBSD: interact.c,v 1.33 2009/11/28 10:52:10 abs Exp $"); #endif /* lint */ #include @@ -702,7 +702,7 @@ defnum(struct disklabel *lp, char *buf, uint32_t size) { - (void) snprintf(buf, BUFSIZ, "%gc, %us, %gM", + (void) snprintf(buf, BUFSIZ, "%.40gc, %us, %.40gM", size / (float) lp->d_secpercyl, size, size * (lp->d_secsize / (float) (1024 * 1024))); } @@ -776,6 +776,7 @@ { char line[BUFSIZ]; + puts("Enter '?' for help"); for (;;) { if (getinput(">", "partition", NULL, line) == -1) return;
CVS commit: src/sbin/disklabel
Module Name:src Committed By: abs Date: Sat Nov 28 10:28:22 UTC 2009 Modified Files: src/sbin/disklabel: disklabel.8 Log Message: Shuffle the order of examples to put the interactive option (-i) ahead of $EDITOR and "disklabel -w -r /dev/rsd0c sd2212 foo" To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sbin/disklabel/disklabel.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/disklabel/disklabel.8 diff -u src/sbin/disklabel/disklabel.8:1.61 src/sbin/disklabel/disklabel.8:1.62 --- src/sbin/disklabel/disklabel.8:1.61 Sat Jan 27 19:20:28 2007 +++ src/sbin/disklabel/disklabel.8 Sat Nov 28 10:28:22 2009 @@ -1,4 +1,4 @@ -.\" $NetBSD: disklabel.8,v 1.61 2007/01/27 19:20:28 perry Exp $ +.\" $NetBSD: disklabel.8,v 1.62 2009/11/28 10:28:22 abs Exp $ .\" .\" Copyright (c) 1987, 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 .\" -.Dd November 26, 2006 +.Dd November 28, 2009 .Dt DISKLABEL 8 .Os .Sh NAME @@ -238,6 +238,20 @@ Display the in-core label for sd0 as obtained via .Pa /dev/rsd0c . .Pp +.Dl Ic disklabel -i -r sd0 +.Pp +Read the on-disk label for sd0, edit it using the built-in interactive editor and reinstall in-core as well +as on-disk. +.Pp +.Dl Ic disklabel -i -I sd0 +.Pp +As previous, but don't fail if there was no label on the disk yet; +provide some default values instead. +.Pp +.Dl Ic disklabel -e -I sd0 +.Pp +As previous, only edit using $EDITOR +.Pp .Dl Ic disklabel -w -r /dev/rsd0c sd2212 foo .Pp Create a label for sd0 based on information for @@ -256,20 +270,6 @@ editing the file, and replacing the label with .Ic disklabel -R sd0 protofile . .Pp -.Dl Ic disklabel -e -r sd0 -.Pp -Read the on-disk label for sd0, edit it and reinstall in-core as well -as on-disk. -.Pp -.Dl Ic disklabel -e -I sd0 -.Pp -As previous, but don't fail if there was no label on the disk yet; -provide some default values instead. -.Pp -.Dl Ic disklabel -i -I sd0 -.Pp -As previous, only use the built-in interactive editor. -.Pp .Dl Ic disklabel -R sd0 mylabel .Pp Restore the on-disk and in-core label for sd0 from information in
CVS commit: src/sbin/disklabel
Module Name:src Committed By: tsutsui Date: Sat Oct 24 18:15:46 UTC 2009 Modified Files: src/sbin/disklabel: dkcksum.c dkcksum.h Log Message: - u_short -> uint16_t - KNF a bit To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sbin/disklabel/dkcksum.c cvs rdiff -u -r1.3 -r1.4 src/sbin/disklabel/dkcksum.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/disklabel/dkcksum.c diff -u src/sbin/disklabel/dkcksum.c:1.11 src/sbin/disklabel/dkcksum.c:1.12 --- src/sbin/disklabel/dkcksum.c:1.11 Sun Jun 12 19:18:34 2005 +++ src/sbin/disklabel/dkcksum.c Sat Oct 24 18:15:45 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: dkcksum.c,v 1.11 2005/06/12 19:18:34 dyoung Exp $ */ +/* $NetBSD: dkcksum.c,v 1.12 2009/10/24 18:15:45 tsutsui Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)dkcksum.c 8.1 (Berkeley) 6/5/93"; #else -__RCSID("$NetBSD: dkcksum.c,v 1.11 2005/06/12 19:18:34 dyoung Exp $"); +__RCSID("$NetBSD: dkcksum.c,v 1.12 2009/10/24 18:15:45 tsutsui Exp $"); #endif #endif /* not lint */ @@ -50,16 +50,16 @@ #endif /* HAVE_NBTOOL_CONFIG_H */ #include "dkcksum.h" -u_short +uint16_t dkcksum(struct disklabel *lp) { - u_short *start, *end; - u_short sum; + uint16_t *start, *end; + uint16_t sum; sum = 0; - start = (u_short *)lp; - end = (u_short *)&lp->d_partitions[lp->d_npartitions]; + start = (uint16_t *)lp; + end = (uint16_t *)&lp->d_partitions[lp->d_npartitions]; while (start < end) sum ^= *start++; - return (sum); + return sum; } Index: src/sbin/disklabel/dkcksum.h diff -u src/sbin/disklabel/dkcksum.h:1.3 src/sbin/disklabel/dkcksum.h:1.4 --- src/sbin/disklabel/dkcksum.h:1.3 Sun Dec 24 05:59:11 2000 +++ src/sbin/disklabel/dkcksum.h Sat Oct 24 18:15:45 2009 @@ -1,3 +1,3 @@ -/* $NetBSD: dkcksum.h,v 1.3 2000/12/24 05:59:11 lukem Exp $ */ +/* $NetBSD: dkcksum.h,v 1.4 2009/10/24 18:15:45 tsutsui Exp $ */ -u_short dkcksum(struct disklabel *); +uint16_t dkcksum(struct disklabel *);
CVS commit: src/sbin/disklabel
Module Name:src Committed By: mhitch Date: Mon May 4 18:09:04 UTC 2009 Modified Files: src/sbin/disklabel: main.c Log Message: fix sign-compare issues in vax-specific code. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sbin/disklabel/main.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/disklabel/main.c diff -u src/sbin/disklabel/main.c:1.19 src/sbin/disklabel/main.c:1.20 --- src/sbin/disklabel/main.c:1.19 Sun Jul 20 01:20:22 2008 +++ src/sbin/disklabel/main.c Mon May 4 18:09:04 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.19 2008/07/20 01:20:22 lukem Exp $ */ +/* $NetBSD: main.c,v 1.20 2009/05/04 18:09:04 mhitch Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ #else -__RCSID("$NetBSD: main.c,v 1.19 2008/07/20 01:20:22 lukem Exp $"); +__RCSID("$NetBSD: main.c,v 1.20 2009/05/04 18:09:04 mhitch Exp $"); #endif #endif /* not lint */ @@ -549,7 +549,7 @@ } alt = lab.d_ncylinders * lab.d_secpercyl - lab.d_nsectors; - for (i = 1; i < 11 && i < lab.d_nsectors; i += 2) { + for (i = 1; i < 11 && (uint32_t)i < lab.d_nsectors; i += 2) { if (pwrite(f, sec0, 512, (off_t)(alt + i) * 512) < 512) warn("alternate label %d write", i/2); }