diff options
author | cperciva <cperciva@FreeBSD.org> | 2009-06-24 23:17:00 +0000 |
---|---|---|
committer | cperciva <cperciva@FreeBSD.org> | 2009-06-24 23:17:00 +0000 |
commit | 8f1962d8fc528050e30fea347d88c0f96b905608 (patch) | |
tree | cb558ef8f9bf60cb354f08b5cefbf7d7686ceabd /usr.sbin/sysinstall/media.c | |
parent | 11197296caae985dd245decd98433d199f255d12 (diff) | |
download | FreeBSD-src-8f1962d8fc528050e30fea347d88c0f96b905608.zip FreeBSD-src-8f1962d8fc528050e30fea347d88c0f96b905608.tar.gz |
Make sysinstall search for /dev/daXa and register such devices as USB disks.
This covers the common case of unsliced USB drives, and makes it possible to
select them as installation source media.
PR: 61152, 115197, 135016
Submitted by: randi
MFC after: 1 month
Diffstat (limited to 'usr.sbin/sysinstall/media.c')
-rw-r--r-- | usr.sbin/sysinstall/media.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c index 643f28b..e50b47c 100644 --- a/usr.sbin/sysinstall/media.c +++ b/usr.sbin/sysinstall/media.c @@ -221,6 +221,52 @@ mediaSetFloppy(dialogMenuItem *self) } static int +USBHook(dialogMenuItem *self) +{ + return genericHook(self, DEVICE_TYPE_USB); +} + + +/* + * Attempt to use USB as the installation media type. + */ +int +mediaSetUSB(dialogMenuItem *self) +{ + Device **devs; + int cnt; + + mediaClose(); + devs = deviceFind(NULL, DEVICE_TYPE_USB); + cnt = deviceCount(devs); + + if (!cnt) { + msgConfirm("No USB devices found!"); + return DITEM_FAILURE | DITEM_CONTINUE; + } + else if (cnt > 1) { + DMenu *menu; + int status; + + menu = deviceCreateMenu(&MenuMediaUSB, DEVICE_TYPE_USB, USBHook, + NULL); + if (!menu) + msgFatal("Unable to create USB menu! Something is " \ + "seriously wrong."); + status = dmenuOpenSimple(menu, FALSE); + free(menu); + if (!status) + return DITEM_FAILURE; + } + else + mediaDevice = devs[0]; + if (mediaDevice) + mediaDevice->private = NULL; + msgConfirm("Using USB device: %s", mediaDevice->name); + return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE); +} + +static int DOSHook(dialogMenuItem *self) { return genericHook(self, DEVICE_TYPE_DOS); |