Module Name:    src
Committed By:   martin
Date:           Sun Jun 19 12:08:31 UTC 2022

Modified Files:
        src/usr.sbin/sysinst: defs.h disks.c label.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/usr.sbin/sysinst/defs.h \
    src/usr.sbin/sysinst/disks.c
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/sysinst/label.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sysinst/defs.h
diff -u src/usr.sbin/sysinst/defs.h:1.83 src/usr.sbin/sysinst/defs.h:1.84
--- src/usr.sbin/sysinst/defs.h:1.83	Sun May 22 11:27:37 2022
+++ src/usr.sbin/sysinst/defs.h	Sun Jun 19 12:08:31 2022
@@ -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 @@ bool	clone_partition_data(struct disk_pa
 
 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 *);
Index: src/usr.sbin/sysinst/disks.c
diff -u src/usr.sbin/sysinst/disks.c:1.83 src/usr.sbin/sysinst/disks.c:1.84
--- src/usr.sbin/sysinst/disks.c:1.83	Sat Jun 11 18:30:02 2022
+++ src/usr.sbin/sysinst/disks.c	Sun Jun 19 12:08:31 2022
@@ -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 @@ sort_part_usage_by_mount(const void *a, 
 	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 @@ make_filesystems(struct install_partitio
 			fsname = "lfs";
 			break;
 		case FS_MSDOS:
+		case FS_EFI_SP:
 			asprintf(&newfs, "/sbin/newfs_msdos");
 			mnt_opts = "-tmsdos";
 			fsname = "msdos";

Index: src/usr.sbin/sysinst/label.c
diff -u src/usr.sbin/sysinst/label.c:1.37 src/usr.sbin/sysinst/label.c:1.38
--- src/usr.sbin/sysinst/label.c:1.37	Sat Jun 18 13:52:42 2022
+++ src/usr.sbin/sysinst/label.c	Sun Jun 19 12:08:31 2022
@@ -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_ptn(menudesc *menu, void *arg)
 		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 @@ update_edit_ptn_menu(menudesc *m, void *
 			/* 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;

Reply via email to