Module Name: src
Committed By: martin
Date: Wed Aug 7 10:08:04 UTC 2019
Modified Files:
src/usr.sbin/sysinst: defs.h disklabel.c disks.c gpt.c partitions.h
target.c txtwalk.c txtwalk.h
src/usr.sbin/sysinst/arch/ews4800mips: md.h
Log Message:
Support upgrade of systems using NAME= syntax in /etc/fstab.
Make supported file system types dynamic - instead of hardcoding the
available types at compile time, check for available newfs_* helper
binaries in the actual install environment at runtime.
To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/sysinst/defs.h
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/sysinst/disklabel.c
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/sysinst/disks.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/sysinst/gpt.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sysinst/partitions.h
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/sysinst/target.c
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/sysinst/txtwalk.c \
src/usr.sbin/sysinst/txtwalk.h
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/sysinst/arch/ews4800mips/md.h
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.42 src/usr.sbin/sysinst/defs.h:1.43
--- src/usr.sbin/sysinst/defs.h:1.42 Fri Jul 26 08:18:47 2019
+++ src/usr.sbin/sysinst/defs.h Wed Aug 7 10:08:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.42 2019/07/26 08:18:47 martin Exp $ */
+/* $NetBSD: defs.h,v 1.43 2019/08/07 10:08:04 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -806,6 +806,7 @@ int target_file_exists_p(const char *);
int target_symlink_exists_p(const char *);
void unwind_mounts(void);
int target_mounted(void);
+void umount_root(void);
/* from partman.c */
#ifndef NO_PARTMAN
Index: src/usr.sbin/sysinst/disklabel.c
diff -u src/usr.sbin/sysinst/disklabel.c:1.10 src/usr.sbin/sysinst/disklabel.c:1.11
--- src/usr.sbin/sysinst/disklabel.c:1.10 Fri Jul 26 08:18:47 2019
+++ src/usr.sbin/sysinst/disklabel.c Wed Aug 7 10:08:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: disklabel.c,v 1.10 2019/07/26 08:18:47 martin Exp $ */
+/* $NetBSD: disklabel.c,v 1.11 2019/08/07 10:08:04 martin Exp $ */
/*
* Copyright 2018 The NetBSD Foundation, Inc.
@@ -1016,6 +1016,32 @@ disklabel_get_alignment(const struct dis
return parts->ptn_alignment;
}
+static part_id
+disklabel_find_by_name(struct disk_partitions *arg, const char *name)
+{
+ const struct disklabel_disk_partitions *parts =
+ (const struct disklabel_disk_partitions*)arg;
+ char *sl, part;
+ ptrdiff_t n;
+ part_id pno;
+
+ sl = strrchr(name, '/');
+ if (sl == NULL)
+ return NO_PART;
+ n = sl - name;
+ if (strncmp(name, parts->l.d_packname, n) != 0)
+ return NO_PART;
+ part = name[n+1];
+ if (part < 'a')
+ return NO_PART;
+ pno = part - 'a';
+ if (pno >= parts->l.d_npartitions)
+ return NO_PART;
+ if (parts->l.d_partitions[pno].p_fstype == FS_UNUSED)
+ return NO_PART;
+ return pno;
+}
+
static void
disklabel_free(struct disk_partitions *arg)
{
@@ -1034,6 +1060,7 @@ disklabel_parts = {
.read_from_disk = disklabel_parts_read,
.create_new_for_disk = disklabel_parts_new,
.change_disk_geom = disklabel_change_geom,
+ .find_by_name = disklabel_find_by_name,
.get_disk_pack_name = disklabel_get_disk_pack_name,
.set_disk_pack_name = disklabel_set_disk_pack_name,
.delete_all_partitions = disklabel_delete_all,
Index: src/usr.sbin/sysinst/disks.c
diff -u src/usr.sbin/sysinst/disks.c:1.46 src/usr.sbin/sysinst/disks.c:1.47
--- src/usr.sbin/sysinst/disks.c:1.46 Sat Aug 3 12:09:22 2019
+++ src/usr.sbin/sysinst/disks.c Wed Aug 7 10:08:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: disks.c,v 1.46 2019/08/03 12:09:22 martin Exp $ */
+/* $NetBSD: disks.c,v 1.47 2019/08/07 10:08:04 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -46,6 +46,7 @@
#include <util.h>
#include <uuid.h>
#include <paths.h>
+#include <fstab.h>
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -80,13 +81,22 @@ struct disk_desc {
daddr_t dd_totsec;
};
-static const char name_prefix[] = "NAME=";
+#define NAME_PREFIX "NAME="
+static const char name_prefix[] = NAME_PREFIX;
+
+/* things we could have as /sbin/newfs_* and /sbin/fsck_* */
+static const char *extern_fs_with_chk[] = {
+ "ext2fs", "lfs", "msdos", "v7fs"
+};
+
+/* things we could have as /sbin/newfs_* but not /sbin/fsck_* */
+static const char *extern_fs_newfs_only[] = {
+ "sysvbfs", "udf"
+};
/* Local prototypes */
-static int foundffs(struct data *, size_t);
-#ifdef USE_SYSVBFS
-static int foundsysvbfs(struct data *, size_t);
-#endif
+static int found_fs(struct data *, size_t, const struct lookfor*);
+static int found_fs_nocheck(struct data *, size_t, const struct lookfor*);
static int fsck_preen(const char *, const char *, bool silent);
static void fixsb(const char *, const char *);
@@ -1153,20 +1163,16 @@ make_filesystems(struct install_partitio
mnt_opts = "-tmsdos";
fsname = "msdos";
break;
-#ifdef USE_SYSVBFS
case FS_SYSVBFS:
asprintf(&newfs, "/sbin/newfs_sysvbfs");
mnt_opts = "-tsysvbfs";
fsname = "sysvbfs";
break;
-#endif
-#ifdef USE_EXT2FS
case FS_EX2FS:
asprintf(&newfs, "/sbin/newfs_ext2fs");
mnt_opts = "-text2fs";
fsname = "ext2fs";
break;
-#endif
}
if ((ptn->instflags & PUIINST_NEWFS) && newfs != NULL) {
if (ptn->fs_type == FS_MSDOS) {
@@ -1258,7 +1264,7 @@ make_fstab(struct install_partition_desc
if (!get_name_and_parent(pm->diskdev, buf, parent))
goto done_with_disks;
- scripting_fprintf(f, "NAME=%s\t/\tffs\trw\t\t1 1\n",
+ scripting_fprintf(f, NAME_PREFIX "%s\t/\tffs\trw\t\t1 1\n",
buf);
if (!find_swap_part_on(parent, swap))
goto done_with_disks;
@@ -1268,7 +1274,7 @@ make_fstab(struct install_partition_desc
res = ask_yesno(prompt);
free(prompt);
if (res)
- scripting_fprintf(f, "NAME=%s\tnone"
+ scripting_fprintf(f, NAME_PREFIX "%s\tnone"
"\tswap\tsw,dp\t\t0 0\n", swap);
goto done_with_disks;
}
@@ -1328,12 +1334,10 @@ make_fstab(struct install_partition_desc
scripting_fprintf(f, "%s\t\tnone\tswap\tsw%s\t\t 0 0\n",
dev, dump_dev);
continue;
-#ifdef USE_SYSVBFS
case FS_SYSVBFS:
fstype = "sysvbfs";
make_target_dir("/stand");
break;
-#endif
default:
fstype = "???";
s = "# ";
@@ -1398,37 +1402,138 @@ done_with_disks:
return 0;
}
+static bool
+find_part_by_name(const char *name, struct disk_partitions **parts,
+ part_id *pno)
+{
+ struct pm_devs *i;
+ struct disk_partitions *ps;
+ part_id id;
+ struct disk_desc disks[MAX_DISKS];
+ int n, cnt;
+
+ if (SLIST_EMPTY(&pm_head)) {
+ /*
+ * List has not been filled, only "pm" is valid - check
+ * that first.
+ */
+ if (pm->parts->pscheme->find_by_name != NULL) {
+ id = pm->parts->pscheme->find_by_name(pm->parts, name);
+ if (id != NO_PART) {
+ *pno = id;
+ *parts = pm->parts;
+ return true;
+ }
+ }
+ /*
+ * Not that easy - check all other disks
+ */
+ cnt = get_disks(disks, false);
+ for (n = 0; n < cnt; n++) {
+ if (strcmp(disks[n].dd_name, pm->diskdev) == 0)
+ continue;
+ ps = partitions_read_disk(disks[n].dd_name,
+ disks[n].dd_totsec);
+ if (ps == NULL)
+ continue;
+ if (ps->pscheme->find_by_name == NULL)
+ continue;
+ id = ps->pscheme->find_by_name(ps, name);
+ if (id != NO_PART) {
+ *pno = id;
+ *parts = ps;
+ return true; /* XXX this leaks memory */
+ }
+ ps->pscheme->free(ps);
+ }
+ } else {
+ SLIST_FOREACH(i, &pm_head, l) {
+ if (i->parts == NULL)
+ continue;
+ if (i->parts->pscheme->find_by_name == NULL)
+ continue;
+ id = i->parts->pscheme->find_by_name(i->parts, name);
+ if (id == NO_PART)
+ continue;
+ *pno = id;
+ *parts = i->parts;
+ return true;
+ }
+ }
+
+ *pno = NO_PART;
+ *parts = NULL;
+ return false;
+}
+
static int
/*ARGSUSED*/
-foundffs(struct data *list, size_t num)
+process_found_fs(struct data *list, size_t num, const struct lookfor *item,
+ bool with_fsck)
{
int error;
- char rbuf[PATH_MAX], buf[PATH_MAX];
- const char *rdev, *dev;
+ char rdev[PATH_MAX], dev[PATH_MAX],
+ options[STRSIZE], tmp[STRSIZE], *op, *last;
+ const char *fsname = (const char*)item->var;
+ part_id pno;
+ struct disk_partitions *parts;
+ bool first;
+
+ if (num < 2 || strstr(list[2].u.s_val, "noauto") != NULL)
+ return 0;
- if (num < 2 || strcmp(list[1].u.s_val, "/") == 0 ||
- strstr(list[2].u.s_val, "noauto") != NULL)
+ if ((strcmp(list[1].u.s_val, "/") == 0) && target_mounted())
return 0;
- /* need the raw device for fsck_preen */
- if (strncmp(list[0].u.s_val, name_prefix, sizeof(name_prefix)-1)
- != 0) {
- strcpy(rbuf, "/dev/r");
- strlcat(rbuf, list[0].u.s_val, sizeof(rbuf));
- rdev = rbuf;
- strcpy(buf, "/dev/");
- strlcat(buf, list[0].u.s_val, sizeof(buf));
- dev = buf;
+ if (strcmp(item->head, name_prefix) == 0) {
+ /* this fstab entry uses NAME= syntax */
+ if (!find_part_by_name(list[0].u.s_val,
+ &parts, &pno) || parts == NULL || pno == NO_PART)
+ return 0;
+ parts->pscheme->get_part_device(parts, pno,
+ dev, sizeof(dev), NULL, plain_name, true);
+ parts->pscheme->get_part_device(parts, pno,
+ rdev, sizeof(rdev), NULL, raw_dev_name, true);
} else {
- rdev = list[0].u.s_val;
- dev = list[0].u.s_val;
+ /* plain device name */
+ strcpy(rdev, "/dev/r");
+ strlcat(rdev, list[0].u.s_val, sizeof(rdev));
+ strcpy(dev, "/dev/");
+ strlcat(dev, list[0].u.s_val, sizeof(dev));
}
- error = fsck_preen(rdev, "ffs", false);
- if (error != 0)
- return error;
+ if (with_fsck) {
+ /* need the raw device for fsck_preen */
+ error = fsck_preen(rdev, fsname, false);
+ if (error != 0)
+ return error;
+ }
- error = target_mount("", dev, list[1].u.s_val);
+ /* add mount option for fs type */
+ strcpy(options, "-t ");
+ strlcat(options, fsname, sizeof(options));
+
+ /* extract mount options from fstab */
+ strlcpy(tmp, list[2].u.s_val, sizeof(tmp));
+ for (first = true, op = strtok_r(tmp, ",", &last); op != NULL;
+ op = strtok_r(NULL, ",", &last)) {
+ if (strcmp(op, FSTAB_RW) == 0 ||
+ strcmp(op, FSTAB_RQ) == 0 ||
+ strcmp(op, FSTAB_RO) == 0 ||
+ strcmp(op, FSTAB_SW) == 0 ||
+ strcmp(op, FSTAB_DP) == 0 ||
+ strcmp(op, FSTAB_XX) == 0)
+ continue;
+ if (first) {
+ first = false;
+ strlcat(options, " -o ", sizeof(options));
+ } else {
+ strlcat(options, ",", sizeof(options));
+ }
+ strlcat(options, op, sizeof(options));
+ }
+
+ error = target_mount(options, dev, list[1].u.s_val);
if (error != 0) {
msg_fmt_display(MSG_mount_failed, "%s", list[0].u.s_val);
if (!ask_noyes(NULL))
@@ -1437,23 +1542,19 @@ foundffs(struct data *list, size_t num)
return 0;
}
-#ifdef USE_SYSVBFS
static int
/*ARGSUSED*/
-foundsysvbfs(struct data *list, size_t num)
+found_fs(struct data *list, size_t num, const struct lookfor *item)
{
- int error;
-
- if (num < 2 || strcmp(list[1].u.s_val, "/") == 0 ||
- strstr(list[2].u.s_val, "noauto") != NULL)
- return 0;
+ return process_found_fs(list, num, item, true);
+}
- error = target_mount("", list[0].u.s_val, list[1].u.s_val);
- if (error != 0)
- return error;
- return 0;
+static int
+/*ARGSUSED*/
+found_fs_nocheck(struct data *list, size_t num, const struct lookfor *item)
+{
+ return process_found_fs(list, num, item, false);
}
-#endif
/*
* Do an fsck. On failure, inform the user by showing a warning
@@ -1550,7 +1651,8 @@ fixsb(const char *prog, const char *disk
* devdev is the fully qualified block device name.
*/
static int
-mount_root(const char *devdev, struct install_partition_desc *install)
+mount_root(const char *devdev, bool first, bool writeable,
+ struct install_partition_desc *install)
{
int error;
@@ -1558,7 +1660,8 @@ mount_root(const char *devdev, struct in
if (error != 0)
return error;
- md_pre_mount(install, 0);
+ if (first)
+ md_pre_mount(install, 0);
/* Mount devdev on target's "".
* If we pass "" as mount-on, Prefixing will DTRT.
@@ -1566,7 +1669,7 @@ mount_root(const char *devdev, struct in
* XXX consider -o remount in case target root is
* current root, still readonly from single-user?
*/
- return target_mount("", devdev, "");
+ return target_mount(writeable? "" : "-r", devdev, "");
}
/* Get information on the file systems mounted from the root filesystem.
@@ -1581,20 +1684,92 @@ mount_disks(struct install_partition_des
int fstabsize;
int error;
char devdev[PATH_MAX];
- size_t i;
+ size_t i, num_fs_types, num_entries;
+ struct lookfor *fstabbuf, *l;
if (install->cur_system)
return 0;
- static struct lookfor fstabbuf[] = {
- {"/dev/", "/dev/%s %s ffs %s", "c", NULL, 0, 0, foundffs},
- {"/dev/", "/dev/%s %s ufs %s", "c", NULL, 0, 0, foundffs},
-#ifdef USE_SYSVBFS
- {"/dev/", "/dev/%s %s sysvbfs %s", "c", NULL, 0, 0,
- foundsysvbfs},
-#endif
- };
- static size_t numfstabbuf = sizeof(fstabbuf) / sizeof(struct lookfor);
+ /*
+ * Check what file system tools are available and create parsers
+ * for the corresponding fstab(5) entries - all others will be
+ * ignored.
+ */
+ num_fs_types = 1; /* ffs is implicit */
+ for (i = 0; i < __arraycount(extern_fs_with_chk); i++) {
+ sprintf(devdev, "/sbin/newfs_%s", extern_fs_with_chk[i]);
+ if (file_exists_p(devdev))
+ num_fs_types++;
+ }
+ for (i = 0; i < __arraycount(extern_fs_newfs_only); i++) {
+ sprintf(devdev, "/sbin/newfs_%s", extern_fs_newfs_only[i]);
+ if (file_exists_p(devdev))
+ num_fs_types++;
+ }
+ num_entries = 2 * num_fs_types + 1; /* +1 for "ufs" special case */
+ fstabbuf = calloc(num_entries, sizeof(*fstabbuf));
+ if (fstabbuf == NULL)
+ return -1;
+ l = fstabbuf;
+ l->head = "/dev/";
+ l->fmt = strdup("/dev/%s %s ffs %s");
+ l->todo = "c";
+ l->var = __UNCONST("ffs");
+ l->func = found_fs;
+ l++;
+ l->head = "/dev/";
+ l->fmt = strdup("/dev/%s %s ufs %s");
+ l->todo = "c";
+ l->var = __UNCONST("ffs");
+ l->func = found_fs;
+ l++;
+ l->head = NAME_PREFIX;
+ l->fmt = strdup(NAME_PREFIX "%s %s ffs %s");
+ l->todo = "c";
+ l->var = __UNCONST("ffs");
+ l->func = found_fs;
+ l++;
+ for (i = 0; i < __arraycount(extern_fs_with_chk); i++) {
+ sprintf(devdev, "/sbin/newfs_%s", extern_fs_with_chk[i]);
+ if (!file_exists_p(devdev))
+ continue;
+ sprintf(devdev, "/dev/%%s %%s %s %%s", extern_fs_with_chk[i]);
+ l->head = "/dev/";
+ l->fmt = strdup(devdev);
+ l->todo = "c";
+ l->var = __UNCONST(extern_fs_with_chk[i]);
+ l->func = found_fs;
+ l++;
+ sprintf(devdev, NAME_PREFIX "%%s %%s %s %%s",
+ extern_fs_with_chk[i]);
+ l->head = NAME_PREFIX;
+ l->fmt = strdup(devdev);
+ l->todo = "c";
+ l->var = __UNCONST(extern_fs_with_chk[i]);
+ l->func = found_fs;
+ l++;
+ }
+ for (i = 0; i < __arraycount(extern_fs_newfs_only); i++) {
+ sprintf(devdev, "/sbin/newfs_%s", extern_fs_newfs_only[i]);
+ if (!file_exists_p(devdev))
+ continue;
+ sprintf(devdev, "/dev/%%s %%s %s %%s", extern_fs_newfs_only[i]);
+ l->head = "/dev/";
+ l->fmt = strdup(devdev);
+ l->todo = "c";
+ l->var = __UNCONST(extern_fs_newfs_only[i]);
+ l->func = found_fs_nocheck;
+ l++;
+ sprintf(devdev, NAME_PREFIX "%%s %%s %s %%s",
+ extern_fs_newfs_only[i]);
+ l->head = NAME_PREFIX;
+ l->fmt = strdup(devdev);
+ l->todo = "c";
+ l->var = __UNCONST(extern_fs_newfs_only[i]);
+ l->func = found_fs_nocheck;
+ l++;
+ }
+ assert((size_t)(l - fstabbuf) == num_entries);
/* First the root device. */
if (target_already_root())
@@ -1615,7 +1790,7 @@ mount_disks(struct install_partition_des
install->infos[i].parts, install->infos[i].cur_part_id,
devdev, sizeof devdev, NULL, plain_name, true))
return -1;
- error = mount_root(devdev, install);
+ error = mount_root(devdev, true, false, install);
if (error != 0 && error != EBUSY)
return -1;
}
@@ -1635,10 +1810,23 @@ mount_disks(struct install_partition_des
/* error ! */
msg_fmt_display(MSG_badetcfstab, "%s", pm->diskdev);
hit_enter_to_continue(NULL, NULL);
+ umount_root();
return -2;
}
- error = walk(fstab, (size_t)fstabsize, fstabbuf, numfstabbuf);
+ /*
+ * We unmount the read-only root again, so we can mount it
+ * with proper options from /etc/fstab
+ */
+ umount_root();
+
+ /*
+ * Now do all entries in /etc/fstab and mount them if required
+ */
+ error = walk(fstab, (size_t)fstabsize, fstabbuf, num_entries);
free(fstab);
+ for (i = 0; i < num_entries; i++)
+ free(__UNCONST(fstabbuf[i].fmt));
+ free(fstabbuf);
return error;
}
Index: src/usr.sbin/sysinst/gpt.c
diff -u src/usr.sbin/sysinst/gpt.c:1.8 src/usr.sbin/sysinst/gpt.c:1.9
--- src/usr.sbin/sysinst/gpt.c:1.8 Sat Aug 3 14:00:42 2019
+++ src/usr.sbin/sysinst/gpt.c Wed Aug 7 10:08:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gpt.c,v 1.8 2019/08/03 14:00:42 martin Exp $ */
+/* $NetBSD: gpt.c,v 1.9 2019/08/07 10:08:04 martin Exp $ */
/*
* Copyright 2018 The NetBSD Foundation, Inc.
@@ -1400,6 +1400,24 @@ gpt_write_to_disk(struct disk_partitions
return true;
}
+static part_id
+gpt_find_by_name(struct disk_partitions *arg, const char *name)
+{
+ struct gpt_disk_partitions *parts = (struct gpt_disk_partitions*)arg;
+ struct gpt_part_entry *p;
+ part_id pno;
+
+ for (pno = 0, p = parts->partitions; p != NULL;
+ p = p->gp_next, pno++) {
+ if (strcmp(p->gp_label, name) == 0)
+ return pno;
+ if (strcmp(p->gp_id, name) == 0)
+ return pno;
+ }
+
+ return NO_PART;
+}
+
bool
gpt_parts_check(void)
{
@@ -1627,6 +1645,7 @@ gpt_parts = {
.read_from_disk = gpt_read_from_disk,
.create_new_for_disk = gpt_create_new,
.have_boot_support = gpt_have_boot_support,
+ .find_by_name = gpt_find_by_name,
.can_add_partition = gpt_can_add_partition,
.custom_attribute_writable = gpt_custom_attribute_writable,
.format_custom_attribute = gpt_format_custom_attribute,
Index: src/usr.sbin/sysinst/partitions.h
diff -u src/usr.sbin/sysinst/partitions.h:1.4 src/usr.sbin/sysinst/partitions.h:1.5
--- src/usr.sbin/sysinst/partitions.h:1.4 Sun Jul 28 16:30:36 2019
+++ src/usr.sbin/sysinst/partitions.h Wed Aug 7 10:08:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: partitions.h,v 1.4 2019/07/28 16:30:36 martin Exp $ */
+/* $NetBSD: partitions.h,v 1.5 2019/08/07 10:08:04 martin Exp $ */
/*
* Copyright 2018 The NetBSD Foundation, Inc.
@@ -426,16 +426,19 @@ struct disk_partitioning_scheme {
* Optional: this scheme may be used to boot from the given disk
*/
bool (*have_boot_support)(const char *disk);
+
/*
* Optional: try to guess disk geometry from the partition information
*/
int (*guess_disk_geom)(struct disk_partitions *,
int *cyl, int *head, int *sec);
+
/*
* Optional: change used geometry info and update internal state
*/
bool (*change_disk_geom)(struct disk_partitions *,
int cyl, int head, int sec);
+
/*
* Optional:
* Get or set a name for the whole disk (most partitioning
@@ -446,6 +449,13 @@ struct disk_partitioning_scheme {
bool (*get_disk_pack_name)(const struct disk_partitions *,
char *, size_t);
bool (*set_disk_pack_name)(struct disk_partitions *, const char *);
+
+ /*
+ * Optional:
+ * Find a partition by name (as used in /etc/fstab NAME= entries)
+ */
+ part_id (*find_by_name)(struct disk_partitions *, const char *name);
+
/*
* Optional:
* Try to guess install target partition from internal data,
@@ -454,6 +464,7 @@ struct disk_partitioning_scheme {
*/
bool (*guess_install_target)(const struct disk_partitions *,
daddr_t *start, daddr_t *size);
+
/*
* Optional: verify that the whole set of partitions would be bootable,
* fix up any issues (with user interaction) where needed.
@@ -465,6 +476,7 @@ struct disk_partitioning_scheme {
* 2: use anyway (continue)
*/
int (*post_edit_verify)(struct disk_partitions *, bool quiet);
+
/*
* Optional: called during updates, before mounting the target disk(s),
* before md_pre_update() is called. Can be used to fixup
Index: src/usr.sbin/sysinst/target.c
diff -u src/usr.sbin/sysinst/target.c:1.9 src/usr.sbin/sysinst/target.c:1.10
--- src/usr.sbin/sysinst/target.c:1.9 Thu Aug 1 16:32:06 2019
+++ src/usr.sbin/sysinst/target.c Wed Aug 7 10:08:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: target.c,v 1.9 2019/08/01 16:32:06 martin Exp $ */
+/* $NetBSD: target.c,v 1.10 2019/08/07 10:08:04 martin Exp $ */
/*
* Copyright 1997 Jonathan Stone
@@ -71,7 +71,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: target.c,v 1.9 2019/08/01 16:32:06 martin Exp $");
+__RCSID("$NetBSD: target.c,v 1.10 2019/08/07 10:08:04 martin Exp $");
#endif
/*
@@ -485,6 +485,28 @@ target_mount_do(const char *opts, const
return 0;
}
+/*
+ * Special case - we have mounted the target / readonly
+ * to peek at etc/fstab, and now want it undone.
+ */
+void
+umount_root(void)
+{
+
+ /* verify this is the only mount */
+ if (unwind_mountlist == NULL)
+ return;
+ if (unwind_mountlist->um_prev != NULL)
+ return;
+
+ if (run_program(0, "/sbin/umount %s", target_prefix()) != 0)
+ return;
+
+ free(unwind_mountlist);
+ unwind_mountlist = NULL;
+}
+
+
int
target_mount(const char *opts, const char *from, const char *on)
{
Index: src/usr.sbin/sysinst/txtwalk.c
diff -u src/usr.sbin/sysinst/txtwalk.c:1.1 src/usr.sbin/sysinst/txtwalk.c:1.2
--- src/usr.sbin/sysinst/txtwalk.c:1.1 Sat Jul 26 19:30:44 2014
+++ src/usr.sbin/sysinst/txtwalk.c Wed Aug 7 10:08:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: txtwalk.c,v 1.1 2014/07/26 19:30:44 dholland Exp $ */
+/* $NetBSD: txtwalk.c,v 1.2 2019/08/07 10:08:04 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -181,7 +181,7 @@ process(const struct lookfor *item, char
}
break;
case 'c': /* Call a function with data. */
- error = (*item->func)(found, numfound);
+ error = (*item->func)(found, numfound, item);
if (error != 0)
return error;
break;
Index: src/usr.sbin/sysinst/txtwalk.h
diff -u src/usr.sbin/sysinst/txtwalk.h:1.1 src/usr.sbin/sysinst/txtwalk.h:1.2
--- src/usr.sbin/sysinst/txtwalk.h:1.1 Sat Jul 26 19:30:44 2014
+++ src/usr.sbin/sysinst/txtwalk.h Wed Aug 7 10:08:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: txtwalk.h,v 1.1 2014/07/26 19:30:44 dholland Exp $ */
+/* $NetBSD: txtwalk.h,v 1.2 2019/08/07 10:08:04 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -50,10 +50,11 @@ struct lookfor {
const char *head; /* Line starts this way. */
const char *fmt; /* Expected format. */
const char *todo; /* What to do ... */
- void *var; /* Possible var */
- size_t nument; /* Number of entries in the "array" */
- size_t size; /* size of string variables */
- int (*func) (struct data *list, size_t num); /* function to call */
+ void *var; /* Possible var or additional args */
+ size_t nument; /* Number of entries in the "array" */
+ size_t size; /* size of string variables */
+ int (*func) (struct data *list, size_t num, const struct lookfor*);
+ /* function to call */
};
/* Format string for the expected string:
Index: src/usr.sbin/sysinst/arch/ews4800mips/md.h
diff -u src/usr.sbin/sysinst/arch/ews4800mips/md.h:1.3 src/usr.sbin/sysinst/arch/ews4800mips/md.h:1.4
--- src/usr.sbin/sysinst/arch/ews4800mips/md.h:1.3 Wed Jun 12 06:20:20 2019
+++ src/usr.sbin/sysinst/arch/ews4800mips/md.h Wed Aug 7 10:08:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: md.h,v 1.3 2019/06/12 06:20:20 martin Exp $ */
+/* $NetBSD: md.h,v 1.4 2019/08/07 10:08:04 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -38,7 +38,6 @@
*/
#include <machine/disklabel.h>
-#define USE_SYSVBFS
#define PART_BOOT (8*MEG)
#define PART_BOOT_TYPE FS_SYSVBFS