Module Name: src Committed By: christos Date: Sun Mar 30 22:18:13 UTC 2014
Modified Files: src/sbin/fdisk: fdisk.c Log Message: Allow -1 values in the -s <sysid>/<start>/<size> indicate use the previous values. For example: fdisk -f -i /dev/rsd0d # initialize mbr and create an msdos partition. fdisk -f -u -0 -a -s 169/-1/-1 /dev/rsd0d # converts the msdos partition to a netbsd one, and makes it active. To generate a diff of this commit: cvs rdiff -u -r1.146 -r1.147 src/sbin/fdisk/fdisk.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/fdisk/fdisk.c diff -u src/sbin/fdisk/fdisk.c:1.146 src/sbin/fdisk/fdisk.c:1.147 --- src/sbin/fdisk/fdisk.c:1.146 Mon Mar 10 11:42:51 2014 +++ src/sbin/fdisk/fdisk.c Sun Mar 30 18:18:13 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: fdisk.c,v 1.146 2014/03/10 15:42:51 jakllsch Exp $ */ +/* $NetBSD: fdisk.c,v 1.147 2014/03/30 22:18:13 christos Exp $ */ /* * Mach Operating System @@ -39,7 +39,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fdisk.c,v 1.146 2014/03/10 15:42:51 jakllsch Exp $"); +__RCSID("$NetBSD: fdisk.c,v 1.147 2014/03/30 22:18:13 christos Exp $"); #endif /* not lint */ #define MBRPTYPENAMES @@ -2027,11 +2027,20 @@ change_part(int extended, int part, int tmp_bootmenu[0] = 0; #endif - if (!s_flag && partp != NULL) { - /* values not specified, default to current ones */ - sysid = partp->mbrp_type; - start = offset + le32toh(partp->mbrp_start); - size = le32toh(partp->mbrp_size); + if (partp != NULL) { + if (!s_flag) { + /* values not specified, default to current ones */ + sysid = partp->mbrp_type; + start = offset + le32toh(partp->mbrp_start); + size = le32toh(partp->mbrp_size); + } else { + if (sysid == -1) + sysid = partp->mbrp_type; + if (start == (daddr_t)0xffffffff) + start = offset + le32toh(partp->mbrp_start); + if (size == (daddr_t)0xffffffff) + size = le32toh(partp->mbrp_size); + } } /* creating a new partition, default to free space */