From nobody@FreeBSD.org  Fri Jan  9 16:30:29 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7CE6216A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  9 Jan 2004 16:30:29 -0800 (PST)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9624C43D2F
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  9 Jan 2004 16:30:28 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i0A0USdL082976
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 9 Jan 2004 16:30:28 -0800 (PST)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.10/8.12.10/Submit) id i0A0USKL082975;
	Fri, 9 Jan 2004 16:30:28 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200401100030.i0A0USKL082975@www.freebsd.org>
Date: Fri, 9 Jan 2004 16:30:28 -0800 (PST)
From: Heikki Soerum <heikkis@matnat.uio.no>
To: freebsd-gnats-submit@FreeBSD.org
Subject: installer refuses to mount USB-floppy or USB-cdrom units.
X-Send-Pr-Version: www-2.0

>Number:         61152
>Category:       bin
>Synopsis:       sysinstall(8): installer refuses to mount USB-floppy or USB-cdrom units
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    cperciva
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 09 16:40:16 PST 2004
>Closed-Date:    Wed Oct 19 01:46:01 UTC 2011
>Last-Modified:  Wed Oct 19 01:46:01 UTC 2011
>Originator:     Heikki Soerum
>Release:        5.2-RC2
>Organization:
>Environment:
N/A
>Description:
The installer for 5.2-RC2 candidate assumes that all Floppy or CDROM
units are connected to /dev/fd* or /dev/ad0*.
When attempting to install the OS or executing fixit emergency shell the 
installer refuses to recognise USB-storage units as valid CD/DVD media
or floppy drives with fixit floppies.
When tested on an computer with an standard /dev/fd0 unit the fixit
disc was mountable&readable, and then it was possible to mount and
read USB-CD/DVD and USB-floppy discs manually in the fixit-shell.
>How-To-Repeat:
Attempt to install FreeBSD 5.2-RC2 from an USB-CDROM/floppy.

>Fix:
In the installer:
When using the Emergency shell selector in the installer, add two
aditional options to;
1. emergency fixit shell can be mounted&loaded from an 
   userspecified devicename.
2.LiveCD's can be mounted from an userspecified devicename.

In addition, the installers choice of install medium need to include
an possibility to choose manually the devicename for CD/DVD medium.
(Simple hack?)
Or the device search routine used to detect what devicename the CD/DVD
rom is connected to should include /dev/da0 devices.(More elegant, but
probably more complicated.)
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-qa 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Nov 4 06:52:23 GMT 2004 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=61152 
Responsible-Changed-From-To: freebsd-bugs->randi 
Responsible-Changed-By: randi 
Responsible-Changed-When: Sat Jun 6 20:46:56 UTC 2009 
Responsible-Changed-Why:  
Grabbing this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=61152 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/61152: commit references a PR
Date: Wed, 24 Jun 2009 23:17:15 +0000 (UTC)

 Author: cperciva
 Date: Wed Jun 24 23:17:00 2009
 New Revision: 194931
 URL: http://svn.freebsd.org/changeset/base/194931
 
 Log:
   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
 
 Added:
   head/usr.sbin/sysinstall/usb.c   (contents, props changed)
 Modified:
   head/usr.sbin/sysinstall/Makefile
   head/usr.sbin/sysinstall/devices.c
   head/usr.sbin/sysinstall/dispatch.c
   head/usr.sbin/sysinstall/media.c
   head/usr.sbin/sysinstall/menus.c
   head/usr.sbin/sysinstall/options.c
   head/usr.sbin/sysinstall/sysinstall.h
 
 Modified: head/usr.sbin/sysinstall/Makefile
 ==============================================================================
 --- head/usr.sbin/sysinstall/Makefile	Wed Jun 24 22:57:07 2009	(r194930)
 +++ head/usr.sbin/sysinstall/Makefile	Wed Jun 24 23:17:00 2009	(r194931)
 @@ -11,7 +11,7 @@ SRCS=	anonFTP.c cdrom.c command.c config
  	ftp.c globals.c http.c index.c install.c installUpgrade.c keymap.c \
  	label.c main.c makedevs.c media.c menus.c misc.c modules.c \
  	mouse.c msg.c network.c nfs.c options.c package.c \
 -	system.c tcpip.c termcap.c ttys.c ufs.c user.c \
 +	system.c tcpip.c termcap.c ttys.c ufs.c usb.c user.c \
  	variable.c ${_wizard} keymap.h countries.h
  
  CFLAGS+= -DUSE_GZIP=1
 
 Modified: head/usr.sbin/sysinstall/devices.c
 ==============================================================================
 --- head/usr.sbin/sysinstall/devices.c	Wed Jun 24 22:57:07 2009	(r194930)
 +++ head/usr.sbin/sysinstall/devices.c	Wed Jun 24 23:17:00 2009	(r194931)
 @@ -65,6 +65,8 @@ static int numDevs;
  	DEVICE_ENTRY(DEVICE_TYPE_NETWORK, name, descr, 0)
  #define	SERIAL(name, descr, max)					\
  	DEVICE_ENTRY(DEVICE_TYPE_NETWORK, name, descr, max)
 +#define	USB(name, descr, max)						\
 +	DEVICE_ENTRY(DEVICE_TYPE_USB, name, descr, max)
  
  static struct _devname {
      DeviceType type;
 @@ -89,6 +91,7 @@ static struct _devname {
      DISK("mfid%d",	"LSI MegaRAID SAS array",		4),
      FLOPPY("fd%d",	"floppy drive unit A",			4),
      SERIAL("cuad%d",	"%s on device %s (COM%d)",		16),
 +    USB("da%da",	"USB Mass Storage Device",		16),
      NETWORK("ae",	"Attansic/Atheros L2 Fast Ethernet"),
      NETWORK("age",	"Attansic/Atheros L1 Gigabit Ethernet"),
      NETWORK("alc",	"Atheros AR8131/AR8132 PCIe Ethernet"),
 @@ -392,6 +395,22 @@ skipif:
  		}
  		break;
  
 +	    case DEVICE_TYPE_USB:
 +		fd = deviceTry(device_names[i], try, j);
 +		if (fd >= 0) {
 +			char n[BUFSIZ];
 +
 +			close(fd);
 +			snprintf(n, sizeof(n), device_names[i].name, j);
 +			deviceRegister(strdup(n), device_names[i].description,
 +			    strdup(try), DEVICE_TYPE_USB, TRUE, mediaInitUSB,
 +			    mediaGetUSB, mediaShutdownUSB, NULL);
 +
 +			if (isDebug())
 +				msgDebug("Found a USB disk for %s\n", try);
 +		}
 +		break;
 +
  	    case DEVICE_TYPE_NETWORK:
  		fd = deviceTry(device_names[i], try, j);
  		/* The only network devices that you can open this way are serial ones */
 
 Modified: head/usr.sbin/sysinstall/dispatch.c
 ==============================================================================
 --- head/usr.sbin/sysinstall/dispatch.c	Wed Jun 24 22:57:07 2009	(r194930)
 +++ head/usr.sbin/sysinstall/dispatch.c	Wed Jun 24 23:17:00 2009	(r194931)
 @@ -96,6 +96,7 @@ static struct _word {
      { "mediaClose",		dispatch_mediaClose	},
      { "mediaSetCDROM",		mediaSetCDROM		},
      { "mediaSetFloppy",		mediaSetFloppy		},
 +    { "mediaSetUSB",		mediaSetUSB		},
      { "mediaSetDOS",		mediaSetDOS		},
      { "mediaSetFTP",		mediaSetFTP		},
      { "mediaSetFTPActive",	mediaSetFTPActive	},
 @@ -511,7 +512,8 @@ dispatch_load_menu(dialogMenuItem *self)
      Device	**devlist;
      char	*err;
      int		what, i, j, msize, count;
 -    DeviceType	dtypes[] = {DEVICE_TYPE_FLOPPY, DEVICE_TYPE_CDROM, DEVICE_TYPE_DOS, DEVICE_TYPE_UFS};
 +    DeviceType	dtypes[] = {DEVICE_TYPE_FLOPPY, DEVICE_TYPE_CDROM,
 +	DEVICE_TYPE_DOS, DEVICE_TYPE_UFS, DEVICE_TYPE_USB};
  
      fprintf(stderr, "dispatch_load_menu called\n");
  
 
 Modified: head/usr.sbin/sysinstall/media.c
 ==============================================================================
 --- head/usr.sbin/sysinstall/media.c	Wed Jun 24 22:57:07 2009	(r194930)
 +++ head/usr.sbin/sysinstall/media.c	Wed Jun 24 23:17:00 2009	(r194931)
 @@ -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);
 
 Modified: head/usr.sbin/sysinstall/menus.c
 ==============================================================================
 --- head/usr.sbin/sysinstall/menus.c	Wed Jun 24 22:57:07 2009	(r194930)
 +++ head/usr.sbin/sysinstall/menus.c	Wed Jun 24 23:17:00 2009	(r194931)
 @@ -191,6 +191,7 @@ DMenu MenuIndex = {
        { " Media, NFS",		"Select NFS installation media.",	NULL, mediaSetNFS },
        { " Media, Floppy",	"Select floppy installation media.",	NULL, mediaSetFloppy },
        { " Media, CDROM/DVD",	"Select CDROM/DVD installation media.",	NULL, mediaSetCDROM },
 +      { " Media, USB",		"Select USB installation media.",	NULL, mediaSetUSB },
        { " Media, DOS",		"Select DOS installation media.",	NULL, mediaSetDOS },
        { " Media, UFS",		"Select UFS installation media.",	NULL, mediaSetUFS },
        { " Media, FTP",		"Select FTP installation media.",	NULL, mediaSetFTP },
 @@ -428,6 +429,16 @@ DMenu MenuMediaFloppy = {
      { { NULL } },
  };
  
 +DMenu MenuMediaUSB = {
 +	DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
 +	"Choose a USB drive",
 +	"You have more than one USB drive. Please choose which drive\n"
 +	"you would like to use.",
 +	NULL,
 +	NULL,
 +	{ { NULL } },
 +};
 +
  DMenu MenuMediaDOS = {
      DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
      "Choose a DOS partition",
 @@ -850,6 +861,7 @@ DMenu MenuMedia = {
        { "6 NFS",		"Install over NFS",			NULL, mediaSetNFS },
        { "7 File System",	"Install from an existing filesystem",	NULL, mediaSetUFS },
        { "8 Floppy",		"Install from a floppy disk set",	NULL, mediaSetFloppy },
 +      { "9 USB",		"Install from a USB drive",		NULL, mediaSetUSB },
        { "X Options",		"Go to the Options screen",		NULL, optionsEditor },
        { NULL } },
  };
 
 Modified: head/usr.sbin/sysinstall/options.c
 ==============================================================================
 --- head/usr.sbin/sysinstall/options.c	Wed Jun 24 22:57:07 2009	(r194930)
 +++ head/usr.sbin/sysinstall/options.c	Wed Jun 24 23:17:00 2009	(r194931)
 @@ -78,6 +78,9 @@ mediaCheck(Option *opt)
  	case DEVICE_TYPE_CDROM:
  	    return "CDROM";
  
 +	case DEVICE_TYPE_USB:
 +	    return "USB";
 +
  	case DEVICE_TYPE_DOS:
  	    return "DOS";
  
 
 Modified: head/usr.sbin/sysinstall/sysinstall.h
 ==============================================================================
 --- head/usr.sbin/sysinstall/sysinstall.h	Wed Jun 24 22:57:07 2009	(r194930)
 +++ head/usr.sbin/sysinstall/sysinstall.h	Wed Jun 24 23:17:00 2009	(r194931)
 @@ -271,6 +271,7 @@ typedef enum {
      DEVICE_TYPE_FTP,
      DEVICE_TYPE_NETWORK,
      DEVICE_TYPE_CDROM,
 +    DEVICE_TYPE_USB,
      DEVICE_TYPE_DOS,
      DEVICE_TYPE_UFS,
      DEVICE_TYPE_NFS,
 @@ -440,6 +441,7 @@ extern DMenu		MenuMedia;		/* Media type 
  extern DMenu		MenuMouse;		/* Mouse type menu				*/
  #endif
  extern DMenu		MenuMediaCDROM;		/* CDROM media menu				*/
 +extern DMenu		MenuMediaUSB;		/* USB media menu				*/
  extern DMenu		MenuMediaDOS;		/* DOS media menu				*/
  extern DMenu		MenuMediaFloppy;	/* Floppy media menu				*/
  extern DMenu		MenuMediaFTP;		/* FTP media menu				*/
 @@ -717,6 +719,7 @@ extern void	mediaClose(void);
  extern int	mediaTimeout(void);
  extern int	mediaSetCDROM(dialogMenuItem *self);
  extern int	mediaSetFloppy(dialogMenuItem *self);
 +extern int	mediaSetUSB(dialogMenuItem *self);
  extern int	mediaSetDOS(dialogMenuItem *self);
  extern int	mediaSetFTP(dialogMenuItem *self);
  extern int	mediaSetFTPActive(dialogMenuItem *self);
 @@ -848,6 +851,11 @@ extern void	mediaShutdownUFS(Device *dev
  extern Boolean	mediaInitUFS(Device *dev);
  extern FILE	*mediaGetUFS(Device *dev, char *file, Boolean probe);
  
 +/* usb.c */
 +extern Boolean	mediaInitUSB(Device *dev);
 +extern FILE	*mediaGetUSB(Device *dev, char *file, Boolean probe);
 +extern void	mediaShutdownUSB(Device *dev);
 +
  /* user.c */
  extern int	userAddGroup(dialogMenuItem *self);
  extern int	userAddUser(dialogMenuItem *self);
 
 Added: head/usr.sbin/sysinstall/usb.c
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/usr.sbin/sysinstall/usb.c	Wed Jun 24 23:17:00 2009	(r194931)
 @@ -0,0 +1,88 @@
 +/*
 + * Redistribution and use in source and binary forms, with or without
 + * modification, are permitted provided that the following conditions
 + * are met:
 + * 1. Redistributions of source code must retain the above copyright
 + *    notice, this list of conditions and the following disclaimer,
 + *    verbatim and that no modifications are made prior to this
 + *    point in the file.
 + * 2. Redistributions in binary form must reproduce the above copyright
 + *    notice, this list of conditions and the following disclaimer in the
 + *    documentation and/or other materials provided with the distribution.
 + *
 + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 + * ARE DISCLAIMED.  IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 + * SUCH DAMAGE.
 + *
 + * used floppy.c and cdrom.c as templates, edited as necessary.
 + *
 + * $FreeBSD$
 + */
 +
 +#include <sys/fcntl.h>
 +#include <sys/param.h>
 +#include <sys/mount.h>
 +
 +#include <ufs/ufs/ufsmount.h>
 +
 +#include "sysinstall.h"
 +
 +static Boolean USBMounted;
 +static char mountpoint[] = "/dist";
 +
 +Boolean
 +mediaInitUSB(Device *dev)
 +{
 +	struct ufs_args ufsargs;
 +
 +	if (USBMounted)
 +		return TRUE;
 +
 +	Mkdir(mountpoint);
 +
 +	memset(&ufsargs, 0, sizeof(ufsargs));
 +	ufsargs.fspec = dev->devname;
 +
 +	if (mount("ufs", mountpoint, MNT_RDONLY, (caddr_t)&ufsargs) != -1) {
 +		USBMounted = TRUE;
 +		return TRUE;
 +	}
 +
 +	msgConfirm("Error mounting USB drive %s (%s) on %s : %s",
 +	    dev->name, dev->devname, mountpoint, strerror(errno));
 +	return FALSE;
 +}
 +
 +
 +FILE *
 +mediaGetUSB(Device *dev, char *file, Boolean probe)
 +{
 +	return mediaGenericGet(mountpoint, file);
 +}
 +
 +
 +/* 
 + * When sysinstall terminates, all USB drives handled by deviceRegister will 
 + * be checked and unmounted if necessary.
 + */
 +void
 +mediaShutdownUSB(Device *dev)
 +{
 +	if (!USBMounted) 
 +		return;
 +
 +	if (unmount(mountpoint, MNT_FORCE) != 0)
 +		msgConfirm("Could not unmount the USB drive from %s: %s", 
 +				mountpoint, strerror(errno));
 +	else
 +		USBMounted = FALSE;
 +
 +}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: eadler 
State-Changed-When: Sat Feb 26 21:10:58 EST 2011 
State-Changed-Why:  
You comitted the patch 


Responsible-Changed-From-To: randi->cperciva 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sat Feb 26 21:10:58 EST 2011 
Responsible-Changed-Why:  
You comitted the patch 

http://www.freebsd.org/cgi/query-pr.cgi?pr=61152 

From: Niclas Zeising <niclas.zeising@gmail.com>
To: bug-followup@FreeBSD.org, heikkis@matnat.uio.no
Cc: cperciva@freebsd.org
Subject: Re: bin/61152: sysinstall(8): installer refuses to mount USB-floppy
 or USB-cdrom units
Date: Tue, 17 May 2011 16:19:15 +0200

 Hi!
 This patch is in both 9-current and 8-stable, and as such can probably
 be merged to 7 as well, and/or the PR closed. Thanks!
 Regards!
 -- 
State-Changed-From-To: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Wed Oct 19 01:45:59 UTC 2011 
State-Changed-Why:  
this has been MFCed 

http://www.freebsd.org/cgi/query-pr.cgi?pr=61152 
>Unformatted:
