Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/distrib/utils/sysinst Do not bother to ask the user for CD d...
details: https://anonhg.NetBSD.org/src/rev/f7ec38dd94f3
branches: trunk
changeset: 753498:f7ec38dd94f3
user: martin <martin%NetBSD.org@localhost>
date: Tue Mar 30 20:09:25 2010 +0000
description:
Do not bother to ask the user for CD details (like device name or path
on the CD) if we can find CDs (i.e. media, not drives) automagically
and check the standard paths on it.
If we find multiple CDs, offer a menu to select showing the volume
name. If something goes wrong, fall back to the manual input method.
In typical installs this makes us just proceed with extracting the sets
after selecting "install from CD/DVD", w/o any further interaction.
As a side effect fixes PR 43012.
XXX new messages need translations.
diffstat:
distrib/utils/sysinst/menus.mi | 4 +-
distrib/utils/sysinst/msg.mi.de | 12 ++-
distrib/utils/sysinst/msg.mi.en | 12 ++-
distrib/utils/sysinst/msg.mi.es | 12 ++-
distrib/utils/sysinst/msg.mi.fr | 12 ++-
distrib/utils/sysinst/msg.mi.pl | 12 ++-
distrib/utils/sysinst/util.c | 197 +++++++++++++++++++++++++++++++++++++--
7 files changed, 243 insertions(+), 18 deletions(-)
diffs (truncated from 407 to 300 lines):
diff -r 426577d1a7d9 -r f7ec38dd94f3 distrib/utils/sysinst/menus.mi
--- a/distrib/utils/sysinst/menus.mi Tue Mar 30 19:54:28 2010 +0000
+++ b/distrib/utils/sysinst/menus.mi Tue Mar 30 20:09:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: menus.mi,v 1.37 2009/12/16 16:03:26 ahoka Exp $ */
+/* $NetBSD: menus.mi,v 1.38 2010/03/30 20:09:25 martin Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -320,7 +320,7 @@
clean_xfer_dir = yesno; };
menu cdromsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
- display action { msg_display(MSG_cdromsource); };
+ display action { msg_display_add(MSG_cdromsource); };
option {src_legend(menu, MSG_Device, cdrom_dev);},
action { src_prompt(MSG_dev, cdrom_dev, sizeof cdrom_dev); };
option {src_legend(menu, MSG_Set_dir, set_dir);},
diff -r 426577d1a7d9 -r f7ec38dd94f3 distrib/utils/sysinst/msg.mi.de
--- a/distrib/utils/sysinst/msg.mi.de Tue Mar 30 19:54:28 2010 +0000
+++ b/distrib/utils/sysinst/msg.mi.de Tue Mar 30 20:09:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg.mi.de,v 1.51 2009/09/07 02:31:53 jnemeth Exp $ */
+/* $NetBSD: msg.mi.de,v 1.52 2010/03/30 20:09:25 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -486,6 +486,16 @@
}
+message Available_cds
+{Verfügbare CDs}
+
+message ask_cd
+{Es wurden mehrere CDs gefunden. Bitte wählen Sie die Installations CD aus.}
+
+message cd_path_not_found
+{Die Installationsdateien wurden auf der ausgewählten CD nicht gefunden. Bitte
+prüfen Sie den Gerätenamen und Pfad der Installationsdateien.}
+
message localfssource
{Geben Sie das noch nicht gemountete lokale Gerät und dessen entsprechendes
Verzeichnis an, in dem die Distribution zu finden ist.
diff -r 426577d1a7d9 -r f7ec38dd94f3 distrib/utils/sysinst/msg.mi.en
--- a/distrib/utils/sysinst/msg.mi.en Tue Mar 30 19:54:28 2010 +0000
+++ b/distrib/utils/sysinst/msg.mi.en Tue Mar 30 20:09:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg.mi.en,v 1.159 2009/09/07 02:31:53 jnemeth Exp $ */
+/* $NetBSD: msg.mi.en,v 1.160 2010/03/30 20:09:25 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -471,6 +471,16 @@
}
+message Available_cds
+{Available CDs }
+
+message ask_cd
+{Multiple CDs found, please select the one containing the install CD.}
+
+message cd_path_not_found
+{The installation sets have not been found at the default location on this
+CD. Please check device and path name.}
+
message localfssource
{Enter the unmounted local device and directory on that device where
the distribution is located.
diff -r 426577d1a7d9 -r f7ec38dd94f3 distrib/utils/sysinst/msg.mi.es
--- a/distrib/utils/sysinst/msg.mi.es Tue Mar 30 19:54:28 2010 +0000
+++ b/distrib/utils/sysinst/msg.mi.es Tue Mar 30 20:09:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg.mi.es,v 1.28 2009/09/07 02:31:53 jnemeth Exp $ */
+/* $NetBSD: msg.mi.es,v 1.29 2010/03/30 20:09:25 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -484,6 +484,16 @@
}
+message Available_cds
+{Available CDs}
+
+message ask_cd
+{Multiple CDs found, please select the one containing the install CD.}
+
+message cd_path_not_found
+{The installation sets have not been found at the default location on this
+CD. Please check device and path name.}
+
message localfssource
{Introduzca el dispositivo local desmontado y el directorio de ese
dispositivo donde se encuentre la distribución.
diff -r 426577d1a7d9 -r f7ec38dd94f3 distrib/utils/sysinst/msg.mi.fr
--- a/distrib/utils/sysinst/msg.mi.fr Tue Mar 30 19:54:28 2010 +0000
+++ b/distrib/utils/sysinst/msg.mi.fr Tue Mar 30 20:09:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg.mi.fr,v 1.109 2009/10/18 19:31:53 stacktic Exp $ */
+/* $NetBSD: msg.mi.fr,v 1.110 2010/03/30 20:09:25 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -484,6 +484,16 @@
}
+message Available_cds
+{Available CDs}
+
+message ask_cd
+{Multiple CDs found, please select the one containing the install CD.}
+
+message cd_path_not_found
+{The installation sets have not been found at the default location on this
+CD. Please check device and path name.}
+
message localfssource
{Veuillez spécifier le nom du périphérique local (qui ne doit pas
être monté) à utiliser. Ce dernier doit contenir les fichiers
diff -r 426577d1a7d9 -r f7ec38dd94f3 distrib/utils/sysinst/msg.mi.pl
--- a/distrib/utils/sysinst/msg.mi.pl Tue Mar 30 19:54:28 2010 +0000
+++ b/distrib/utils/sysinst/msg.mi.pl Tue Mar 30 20:09:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg.mi.pl,v 1.67 2009/09/07 02:31:53 jnemeth Exp $ */
+/* $NetBSD: msg.mi.pl,v 1.68 2010/03/30 20:09:25 martin Exp $ */
/* Based on english version: */
/* NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp */
@@ -465,6 +465,16 @@
}
+message Available_cds
+{Available CDs}
+
+message ask_cd
+{Multiple CDs found, please select the one containing the install CD.}
+
+message cd_path_not_found
+{The installation sets have not been found at the default location on this
+CD. Please check device and path name.}
+
message localfssource
{Podaj niezamountowane lokalne urzadzenie oraz katalog na nim, gdzie
znajduje sie dystrybucja.
diff -r 426577d1a7d9 -r f7ec38dd94f3 distrib/utils/sysinst/util.c
--- a/distrib/utils/sysinst/util.c Tue Mar 30 19:54:28 2010 +0000
+++ b/distrib/utils/sysinst/util.c Tue Mar 30 20:09:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: util.c,v 1.163 2010/01/27 11:02:03 jmmv Exp $ */
+/* $NetBSD: util.c,v 1.164 2010/03/30 20:09:25 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -40,12 +40,17 @@
#include <stdio.h>
#include <stdarg.h>
+#include <string.h>
#include <unistd.h>
+#include <sys/disklabel.h>
+#include <sys/dkio.h>
+#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
+#include <isofs/cd9660/iso.h>
#include <curses.h>
#include <err.h>
#include <errno.h>
@@ -66,6 +71,9 @@
#define MD_SETS_VALID SET_KERNEL, SET_SYSTEM, SET_X11, SET_MD
#endif
+#define MAX_CD_DEVS 256 /* how many cd drives do we expect to attach */
+#define ISO_BLKSIZE ISO_DEFAULT_BLOCK_SIZE
+
static const char *msg_yes, *msg_no, *msg_all, *msg_some, *msg_none;
static const char *msg_cur_distsets_row;
static int select_menu_width;
@@ -145,11 +153,20 @@
{NULL, SET_LAST, NULL, NULL},
};
+#define MAX_CD_INFOS 16 /* how many media can be found? */
+struct cd_info {
+ char device_name[16];
+ char menu[100];
+};
+static struct cd_info cds[MAX_CD_INFOS];
+
/*
* local prototypes
*/
static int check_for(unsigned int mode, const char *pathname);
+static int get_iso9660_volname(int dev, int sess, char *volname);
+static int get_available_cds(void);
void
init_set_status(int minimal)
@@ -342,12 +359,138 @@
}
/*
+ * Get the volume name of a ISO9660 file system
+ */
+static int
+get_iso9660_volname(int dev, int sess, char *volname)
+{
+ int blkno, error, last;
+ char buf[ISO_BLKSIZE];
+ struct iso_volume_descriptor *vd = NULL;
+ struct iso_primary_descriptor *pd = NULL;
+
+ for (blkno = sess+16; blkno < sess+16+100; blkno++) {
+ error = pread(dev, buf, ISO_BLKSIZE, blkno*ISO_BLKSIZE);
+ if (error == -1)
+ return -1;
+ vd = (struct iso_volume_descriptor *)&buf;
+ if (memcmp(vd->id, ISO_STANDARD_ID, sizeof(vd->id)) != 0)
+ return -1;
+ if (isonum_711((const unsigned char *)&vd->type)
+ == ISO_VD_PRIMARY) {
+ pd = (struct iso_primary_descriptor*)buf;
+ strncpy(volname, pd->volume_id, sizeof pd->volume_id);
+ last = sizeof pd->volume_id-1;
+ while (last >= 0
+ && (volname[last] == ' ' || volname[last] == 0))
+ last--;
+ volname[last+1] = 0;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+/*
+ * Get a list of all available CD media (not drives!), return
+ * the number of entries collected.
+ */
+static int
+get_available_cds()
+{
+ char dname[16], volname[80];
+ struct cd_info *info = cds;
+ struct disklabel label;
+ int i, part, dev, error, sess, ready, count = 0;
+
+ for (i = 0; i < MAX_CD_DEVS; i++) {
+ sprintf(dname, "/dev/rcd%d%c", i, 'a'+RAW_PART);
+ dev = open(dname, O_RDONLY, 0);
+ if (dev == -1)
+ break;
+ ready = 0;
+ error = ioctl(dev, DIOCTUR, &ready);
+ if (error != 0 || ready == 0) {
+ close(dev);
+ continue;
+ }
+ error = ioctl(dev, DIOCGDINFO, &label);
+ close(dev);
+ if (error == 0) {
+ for (part = 0; part < label.d_npartitions; part++) {
+ if (label.d_partitions[part].p_fstype
+ != FS_ISO9660)
+ continue;
+ if (label.d_partitions[part].p_fstype
+ == FS_ISO9660) {
+ sess = label.d_partitions[part]
+ .p_cdsession;
+ sprintf(dname, "/dev/rcd%d%c", i,
+ 'a'+part);
+ dev = open(dname, O_RDONLY, 0);
+ if (dev == -1)
+ continue;
+ error = get_iso9660_volname(dev, sess,
+ volname);
+ close(dev);
+ if (error) continue;
+ sprintf(info->device_name, "cd%d%c",
+ i, 'a'+part);
+ sprintf(info->menu, "%s (%s)",
+ info->device_name,
+ volname);
+ } else {
+ /*
+ * All install CDs use partition
+ * a for the sets.
+ */
+ if (part > 0)
+ continue;
+ sprintf(info->device_name, "cd%d%c",
+ i, 'a'+part);
+ strcpy(info->menu, info->device_name);
Home |
Main Index |
Thread Index |
Old Index