Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Move the LABELSECTOR check and make it FS t...



details:   https://anonhg.NetBSD.org/src/rev/1cfe497eab80
branches:  trunk
changeset: 467029:1cfe497eab80
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Jan 10 10:47:35 2020 +0000

description:
Move the LABELSECTOR check and make it FS type specific - some partition
types (FFS, RAID) are allowed to overlap with the LABELSECTOR.

diffstat:

 usr.sbin/sysinst/disklabel.c |  32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

diffs (60 lines):

diff -r 198ef1dd7580 -r 1cfe497eab80 usr.sbin/sysinst/disklabel.c
--- a/usr.sbin/sysinst/disklabel.c      Fri Jan 10 09:47:19 2020 +0000
+++ b/usr.sbin/sysinst/disklabel.c      Fri Jan 10 10:47:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disklabel.c,v 1.28 2020/01/09 13:22:30 martin Exp $    */
+/*     $NetBSD: disklabel.c,v 1.29 2020/01/10 10:47:35 martin Exp $    */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -797,8 +797,8 @@
        size_t cnt = 0, i;
        daddr_t s, e, from, size, end_of_disk;
 
-       if (start <= parts->dp.disk_start+LABELSECTOR)
-               start = parts->dp.disk_start+LABELSECTOR+1;
+       if (start < parts->dp.disk_start)
+               start = parts->dp.disk_start;
        if (min_space_size < 1)
                min_space_size = 1;
        if (align > 1 && (start % align) != 0)
@@ -965,6 +965,24 @@
        return false;
 }
 
+/*
+ * If the requested partition file system type internally skips
+ * the disk label sector, we can allow it to start at the beginning
+ * of the disk. In most cases though we have to move the partition
+ * to start past the label sector.
+ */
+static bool
+need_to_skip_past_label(const struct disk_part_info *info)
+{
+       switch (info->fs_type) {
+       case FS_BSDFFS:
+       case FS_RAID:
+               return false;
+       }
+
+       return true;
+}
+
 static part_id
 disklabel_add_partition(struct disk_partitions *arg,
     const struct disk_part_info *info, const char **err_msg)
@@ -982,6 +1000,14 @@
                        *err_msg = msg_string(MSG_No_free_space);
                return NO_PART;
        }
+       if (space.start <= (parts->dp.disk_start + LABELSECTOR) &&
+           need_to_skip_past_label(info)) {
+               daddr_t new_start = roundup(parts->dp.disk_start + LABELSECTOR,
+                   parts->ptn_alignment);
+               daddr_t off = new_start - space.start;
+               space.start += off;
+               space.size -= off;
+       }
        if (data.size > space.size)
                data.size = space.size;
        daddr_t dend = data.start+data.size;



Home | Main Index | Thread Index | Old Index