Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/distrib/utils/sysinst Pull up revisions:
details: https://anonhg.NetBSD.org/src/rev/cfded061dee6
branches: netbsd-6
changeset: 774297:cfded061dee6
user: jdc <jdc%NetBSD.org@localhost>
date: Wed Jul 04 20:48:55 2012 +0000
description:
Pull up revisions:
src/distrib/utils/sysinst/defs.h revision 1.163
src/distrib/utils/sysinst/disks.c revisions 1.125,1.126
src/distrib/utils/sysinst/main.c revisions 1.65,1.66
src/distrib/utils/sysinst/arch/emips/md.h revision 1.4
src/distrib/utils/sysinst/arch/i386/md.h revision 1.69
src/distrib/utils/sysinst/arch/vax/md.h revision 1.21
(requested by abs in ticket #386).
- Replace the CD_NAME definition with a CD_NAMES comma separate list,
the default remains "cd0a", but i386 sets "cd0a", "mcd0a" while vax
takes "cd0a", "racd0a"
- Add get_default_cdrom() to disks.c, which is called in init(). This
checks the contents of hw.disknames against CD_NAMES. The first one
found (minus partition letter) is picked, otherwise the first entry
in CD_NAMES is used
The primary beneficiary is vax systems with an MSCP but no SCSI CD
drive, which now default to (a valid) racd0a rather than an invalid
cd0a. The obvious example being simh-vax
Trying to print a function pointer as a string is likely to cause tears.
While here, don't match on the unit either
Do not assign to a const pointer, but set the value of the target variable
instead. Makes sysinst at least start up again.
diffstat:
distrib/utils/sysinst/arch/emips/md.h | 9 ++---
distrib/utils/sysinst/arch/i386/md.h | 8 ++++-
distrib/utils/sysinst/arch/vax/md.h | 8 +++++-
distrib/utils/sysinst/defs.h | 9 ++---
distrib/utils/sysinst/disks.c | 48 +++++++++++++++++++++++++++++++++-
distrib/utils/sysinst/main.c | 12 +++++--
6 files changed, 75 insertions(+), 19 deletions(-)
diffs (202 lines):
diff -r b49a593af7e7 -r cfded061dee6 distrib/utils/sysinst/arch/emips/md.h
--- a/distrib/utils/sysinst/arch/emips/md.h Wed Jul 04 20:41:45 2012 +0000
+++ b/distrib/utils/sysinst/arch/emips/md.h Wed Jul 04 20:48:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: md.h,v 1.3 2011/04/04 08:30:22 mbalmer Exp $ */
+/* $NetBSD: md.h,v 1.3.6.1 2012/07/04 20:48:55 jdc Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -83,8 +83,7 @@
#define MD_SETS_VALID SET_KERNEL, SET_SYSTEM, SET_X11_NOSERVERS
/* default install CD device is ace1a */
-/* XXX: not pretty */
-#ifdef CD_NAME
-#undef CD_NAME
+#ifdef CD_NAMES
+#undef CD_NAMES
#endif
-#define CD_NAME "ace1a"
+#define CD_NAMES "ace1a"
diff -r b49a593af7e7 -r cfded061dee6 distrib/utils/sysinst/arch/i386/md.h
--- a/distrib/utils/sysinst/arch/i386/md.h Wed Jul 04 20:41:45 2012 +0000
+++ b/distrib/utils/sysinst/arch/i386/md.h Wed Jul 04 20:48:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: md.h,v 1.68 2011/04/04 08:30:32 mbalmer Exp $ */
+/* $NetBSD: md.h,v 1.68.6.1 2012/07/04 20:48:55 jdc Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -105,8 +105,12 @@
extern struct mbr_bootsel *mbs;
+/* i386 can still have old mcd ISA devices */
+#ifdef CD_NAMES
+#undef CD_NAMES
+#endif
+#define CD_NAMES "cd0a","mcd0a"
/*
* prototypes for MD code.
*/
-
diff -r b49a593af7e7 -r cfded061dee6 distrib/utils/sysinst/arch/vax/md.h
--- a/distrib/utils/sysinst/arch/vax/md.h Wed Jul 04 20:41:45 2012 +0000
+++ b/distrib/utils/sysinst/arch/vax/md.h Wed Jul 04 20:48:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: md.h,v 1.20 2011/04/04 08:30:44 mbalmer Exp $ */
+/* $NetBSD: md.h,v 1.20.6.1 2012/07/04 20:48:55 jdc Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -69,3 +69,9 @@
* the hand-edited disklabel will NOT be written by MI code.
*/
#define DISKLABEL_CMD "disklabel -w -r"
+
+/* VAX can have cd* or racd* devices */
+#ifdef CD_NAMES
+#undef CD_NAMES
+#endif
+#define CD_NAMES "cd0a","racd0a"
diff -r b49a593af7e7 -r cfded061dee6 distrib/utils/sysinst/defs.h
--- a/distrib/utils/sysinst/defs.h Wed Jul 04 20:41:45 2012 +0000
+++ b/distrib/utils/sysinst/defs.h Wed Jul 04 20:48:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.161.2.1 2012/05/17 18:57:08 sborrill Exp $ */
+/* $NetBSD: defs.h,v 1.161.2.2 2012/07/04 20:48:55 jdc Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -171,10 +171,8 @@
#define PI_ISBSDFS(p) ((p)->pi_fstype == FS_BSDLFS || \
(p)->pi_fstype == FS_BSDFFS)
-/* non-standard cd0 driver */
-#ifndef CD_NAME
-#define CD_NAME "cd0a"
-#endif
+/* standard cd0 device */
+#define CD_NAMES "cd0a"
/* Types */
typedef struct distinfo {
@@ -379,6 +377,7 @@
void toplevel(void);
/* from disks.c */
+const char *get_default_cdrom(void);
int find_disks(const char *);
struct menudesc;
void fmt_fspart(struct menudesc *, int, void *);
diff -r b49a593af7e7 -r cfded061dee6 distrib/utils/sysinst/disks.c
--- a/distrib/utils/sysinst/disks.c Wed Jul 04 20:41:45 2012 +0000
+++ b/distrib/utils/sysinst/disks.c Wed Jul 04 20:48:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disks.c,v 1.123 2012/01/09 01:51:47 riz Exp $ */
+/* $NetBSD: disks.c,v 1.123.2.1 2012/07/04 20:48:55 jdc Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -43,6 +43,7 @@
#include <util.h>
#include <sys/param.h>
+#include <sys/sysctl.h>
#include <sys/swap.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@@ -305,6 +306,48 @@
strcpy(dd->dd_descr, dd->dd_name);
}
+/* disknames - contains device names without partition letters
+ * cdrom_devices - contains devices including partition letters
+ * returns the first entry in hw.disknames matching a cdrom_device, or
+ * first entry on error or no match
+ */
+const char *
+get_default_cdrom(void)
+{
+ static const char *cdrom_devices[] = { CD_NAMES, 0};
+ static const char mib_name[] = "hw.disknames";
+ size_t len;
+ char *disknames;
+ char *last;
+ char *name;
+ const char **arg;
+ const char *cd_dev;
+
+ /* On error just use first entry in cdrom_devices */
+ if (sysctlbyname(mib_name, NULL, &len, NULL, 0) == -1)
+ return cdrom_devices[0];
+ if ((disknames = malloc(len + 2)) == 0) /* skip on malloc fail */
+ return cdrom_devices[0];
+
+ (void)sysctlbyname(mib_name, disknames, &len, NULL, 0);
+ for ((name = strtok_r(disknames, " ", &last)); name;
+ (name = strtok_r(NULL, " ", &last))) {
+ for (arg = cdrom_devices; *arg; ++arg) {
+ cd_dev = *arg;
+ /* skip unit and partition */
+ if (strncmp(cd_dev, name, strlen(cd_dev) - 2) != 0)
+ continue;
+ if (name != disknames)
+ strcpy(disknames, name);
+ strcat(disknames, "a");
+ /* XXX: leaks, but so what? */
+ return disknames;
+ }
+ }
+ free(disknames);
+ return cdrom_devices[0];
+}
+
static int
get_disks(struct disk_desc *dd)
{
@@ -773,7 +816,8 @@
scripting_fprintf(f, "kernfs\t\t/kern\tkernfs\trw\n");
scripting_fprintf(f, "ptyfs\t\t/dev/pts\tptyfs\trw\n");
scripting_fprintf(f, "procfs\t\t/proc\tprocfs\trw\n");
- scripting_fprintf(f, "/dev/" CD_NAME "\t\t/cdrom\tcd9660\tro,noauto\n");
+ scripting_fprintf(f, "/dev/%s\t\t/cdrom\tcd9660\tro,noauto\n",
+ get_default_cdrom());
make_target_dir("/kern");
make_target_dir("/proc");
make_target_dir("/dev/pts");
diff -r b49a593af7e7 -r cfded061dee6 distrib/utils/sysinst/main.c
--- a/distrib/utils/sysinst/main.c Wed Jul 04 20:41:45 2012 +0000
+++ b/distrib/utils/sysinst/main.c Wed Jul 04 20:48:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.63.2.1 2012/05/17 18:57:08 sborrill Exp $ */
+/* $NetBSD: main.c,v 1.63.2.2 2012/07/04 20:48:55 jdc Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -91,7 +91,7 @@
{"ftp proxy", "", ftp.proxy, sizeof ftp.proxy},
{"nfs host", "", nfs_host, sizeof nfs_host},
{"nfs dir", "/bsd/release", nfs_dir, sizeof nfs_dir},
- {"cd dev", CD_NAME, cdrom_dev, sizeof cdrom_dev},
+ {"cd dev", 0, cdrom_dev, sizeof cdrom_dev}, /* default filled in init */
{"fd dev", "/dev/fd0a", fd_dev, sizeof fd_dev},
{"local dev", "", localfs_dev, sizeof localfs_dev},
{"local fs", "ffs", localfs_fs, sizeof localfs_fs},
@@ -128,8 +128,12 @@
mnt2_mounted = 0;
fd_type = "msdos";
- for (arg = fflagopts; arg->name != NULL; arg++)
- strlcpy(arg->var, arg->dflt, arg->size);
+ for (arg = fflagopts; arg->name != NULL; arg++) {
+ if (arg->var == cdrom_dev)
+ strlcpy(arg->var, get_default_cdrom(), arg->size);
+ else
+ strlcpy(arg->var, arg->dflt, arg->size);
+ }
pkg.xfer_type = pkgsrc.xfer_type = "http";
}
Home |
Main Index |
Thread Index |
Old Index