Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Centralize the "we can newfs this type of f...



details:   https://anonhg.NetBSD.org/src/rev/86598fc238c2
branches:  trunk
changeset: 367253:86598fc238c2
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Jun 19 12:08:31 2022 +0000

description:
Centralize the "we can newfs this type of filesystem" predicate
and fix the list.

diffstat:

 usr.sbin/sysinst/defs.h  |   3 ++-
 usr.sbin/sysinst/disks.c |  24 +++++++++++++++++++++++-
 usr.sbin/sysinst/label.c |   9 +++++----
 3 files changed, 30 insertions(+), 6 deletions(-)

diffs (99 lines):

diff -r 65baf5827119 -r 86598fc238c2 usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h   Sun Jun 19 11:50:42 2022 +0000
+++ b/usr.sbin/sysinst/defs.h   Sun Jun 19 12:08:31 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.83 2022/05/22 11:27:37 andvar Exp $ */
+/*     $NetBSD: defs.h,v 1.84 2022/06/19 12:08:31 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -718,6 +718,7 @@
 
 struct menudesc;
 void   disp_cur_fspart(int, int);
+bool   can_newfs_fstype(unsigned int);
 int    make_filesystems(struct install_partition_desc *);
 int    make_fstab(struct install_partition_desc *);
 int    mount_disks(struct install_partition_desc *);
diff -r 65baf5827119 -r 86598fc238c2 usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c  Sun Jun 19 11:50:42 2022 +0000
+++ b/usr.sbin/sysinst/disks.c  Sun Jun 19 12:08:31 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disks.c,v 1.83 2022/06/11 18:30:02 martin Exp $ */
+/*     $NetBSD: disks.c,v 1.84 2022/06/19 12:08:31 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1220,6 +1220,27 @@
        return (uintptr_t)a < (uintptr_t)b ? -1 : 1;
 }
 
+/*
+ * Are we able to newfs this type of file system?
+ * Keep in sync with switch labels below!
+ */
+bool
+can_newfs_fstype(unsigned int t)
+{
+       switch (t) {
+       case FS_APPLEUFS:
+       case FS_BSDFFS:
+       case FS_BSDLFS:
+       case FS_MSDOS:
+       case FS_EFI_SP:
+       case FS_SYSVBFS:
+       case FS_V7:
+       case FS_EX2FS:
+               return true;
+       }
+       return false;
+}
+
 int
 make_filesystems(struct install_partition_desc *install)
 {
@@ -1331,6 +1352,7 @@
                        fsname = "lfs";
                        break;
                case FS_MSDOS:
+               case FS_EFI_SP:
                        asprintf(&newfs, "/sbin/newfs_msdos");
                        mnt_opts = "-tmsdos";
                        fsname = "msdos";
diff -r 65baf5827119 -r 86598fc238c2 usr.sbin/sysinst/label.c
--- a/usr.sbin/sysinst/label.c  Sun Jun 19 11:50:42 2022 +0000
+++ b/usr.sbin/sysinst/label.c  Sun Jun 19 12:08:31 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: label.c,v 1.37 2022/06/18 13:52:42 martin Exp $        */
+/*     $NetBSD: label.c,v 1.38 2022/06/19 12:08:31 martin Exp $        */
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: label.c,v 1.37 2022/06/18 13:52:42 martin Exp $");
+__RCSID("$NetBSD: label.c,v 1.38 2022/06/19 12:08:31 martin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -978,6 +978,8 @@
                edit.info.last_mounted = edit.wanted->mount;
                if (is_new_part) {
                        edit.wanted->parts = pset->parts;
+                       if (!can_newfs_fstype(edit.wanted->fs_type))
+                               edit.wanted->instflags &= ~PUIINST_NEWFS;
                        edit.wanted->cur_part_id = pset->parts->pscheme->
                            add_partition(pset->parts, &edit.info, &err);
                        if (edit.wanted->cur_part_id == NO_PART)
@@ -1081,8 +1083,7 @@
                        /* can only install onto PT_root partitions */
                        continue;
                if (m->opts[i].opt_action == edit_fs_preserve &&
-                   t != FS_BSDFFS && t != FS_BSDLFS && t != FS_APPLEUFS &&
-                   t != FS_MSDOS && t != FS_EFI_SP && t != FS_EX2FS) {
+                   !can_newfs_fstype(t)) {
                        /* Can not newfs this filesystem */
                        edit->wanted->instflags &= ~PUIINST_NEWFS;
                        continue;



Home | Main Index | Thread Index | Old Index