Source-Changes-HG archive

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

[src/trunk]: src/sbin/fdisk default to something reasonable (like the interac...



details:   https://anonhg.NetBSD.org/src/rev/c144d0890c5d
branches:  trunk
changeset: 328380:c144d0890c5d
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Apr 01 19:08:48 2014 +0000

description:
default to something reasonable (like the interactive mode does) instead
of 0 when -1 is specified for the start or size.

diffstat:

 sbin/fdisk/fdisk.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (46 lines):

diff -r 85e0f50afc32 -r c144d0890c5d sbin/fdisk/fdisk.c
--- a/sbin/fdisk/fdisk.c        Tue Apr 01 18:01:45 2014 +0000
+++ b/sbin/fdisk/fdisk.c        Tue Apr 01 19:08:48 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fdisk.c,v 1.147 2014/03/30 22:18:13 christos Exp $ */
+/*     $NetBSD: fdisk.c,v 1.148 2014/04/01 19:08:48 christos Exp $ */
 
 /*
  * Mach Operating System
@@ -39,7 +39,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: fdisk.c,v 1.147 2014/03/30 22:18:13 christos Exp $");
+__RCSID("$NetBSD: fdisk.c,v 1.148 2014/04/01 19:08:48 christos Exp $");
 #endif /* not lint */
 
 #define MBRPTYPENAMES
@@ -1817,7 +1817,7 @@
                        /* This is just a convention, not a requirement */
                        return "Track zero is reserved for the BIOS";
 #endif
-               if (start + size > disksectors) 
+               if (start + size > disksectors)
                        return "Partition exceeds size of disk";
                for (p = 0; p < MBR_PART_COUNT; p++) {
                        if (p == part || mboot.mbr_parts[p].mbrp_type == 0)
@@ -2036,10 +2036,16 @@
                } else {
                        if (sysid == -1)
                                sysid = partp->mbrp_type;
-                       if (start == (daddr_t)0xffffffff)
+                       if (start == (daddr_t)0xffffffff) {
                                start = offset + le32toh(partp->mbrp_start);
-                       if (size == (daddr_t)0xffffffff)
+                               if (start == 0)
+                                       start = offset = ptn_0_offset;
+                       }
+                       if (size == (daddr_t)0xffffffff) {
                                size = le32toh(partp->mbrp_size);
+                               if (size == 0) 
+                                       size = disksectors - start;
+                       }
                }
        }
 



Home | Main Index | Thread Index | Old Index