From jsa@wickedmachine.net  Thu May 28 03:05:52 2009
Return-Path: <jsa@wickedmachine.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E66A5106566B
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 28 May 2009 03:05:52 +0000 (UTC)
	(envelope-from jsa@wickedmachine.net)
Received: from mephisto.wickedmachine.net (tn-67-232-82-190.dhcp.embarqhsd.net [67.232.82.190])
	by mx1.freebsd.org (Postfix) with ESMTP id A93338FC14
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 28 May 2009 03:05:52 +0000 (UTC)
	(envelope-from jsa@wickedmachine.net)
Received: from mephisto.wickedmachine.net (localhost [127.0.0.1])
	by mephisto.wickedmachine.net (8.14.3/8.14.3) with ESMTP id n4S35uHp060555
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 27 May 2009 23:05:56 -0400 (EDT)
	(envelope-from jsa@wickedmachine.net)
Message-Id: <1243479956.59881@mephisto.wickedmachine.net>
Date: Wed, 27 May 2009 23:05:56 -0400
From: "Joseph S. Atkinson" <jsa@wickedmachine.net>
To: "FreeBSD gnats submit" <FreeBSD-gnats-submit@freebsd.org>
Subject: sysinstall needs support for USB devices
X-Send-Pr-Version: gtk-send-pr 0.4.9 
X-GNATS-Notify:

>Number:         135016
>Category:       bin
>Synopsis:       [request] sysinstall(8) needs support for USB devices
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    randi
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 28 03:10:01 UTC 2009
>Closed-Date:    Sun Oct 23 22:51:16 UTC 2011
>Last-Modified:  Sun Oct 23 22:51:16 UTC 2011
>Originator:     Joseph S. Atkinson
>Release:        FreeBSD 7.2-RELEASE i386
>Organization:
>Environment:


System: FreeBSD 7.2-RELEASE #0: Sat May  2 00:21:11 EDT 2009
    jsa@mephisto.wickedmachine.net:/usr/obj/usr/src/sys/MEPHISTO



>Description:


I've been trying to install FreeBSD on my Acer Aspire One AOD150-1920. I have three issues that are preventing me from doing so successfully so far. This PR addresses one of them.

The primary problem is that sysinstall does not recognize /dev/da0 as a device from which FreeBSD may be installed. Getting the bootable magic onto the USB was failry simple, but it cannot access the medium after boot, and thus cannot be used.

The other two problems elimiated the ability to do a netinstall from the USB stick, and are not the subject of this PR.


>How-To-Repeat:


# fdisk -BI /dev/da0 && bsdlabel -B -w da0s1 && newfs -b 4096 /dev/da0s1a
# mdconfig -a -t vnode -u 0 -f /path/to/installer.iso && mount -t cd9660 /dev/md0 /mnt
# mkdir -p /media/disk && mount /dev/da0s1a /media/disk
# cp -a /mnt/* /media/disk/

When completed, unmount, and insert into netbook. Boot from it and go through install process. When you get to the option to select media, there will be no option for USB. If no other options are usable, this will be a dead end for your install process.


>Fix:





>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->randi 
Responsible-Changed-By: randi 
Responsible-Changed-When: Sat Jun 6 18:28:21 UTC 2009 
Responsible-Changed-Why:  
I'll look into this. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/135016: commit references a PR
Date: Wed, 24 Jun 2009 23:17:16 +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: Tue Mar 1 10:16:01 EST 2011 
State-Changed-Why:  
committed in head (r194931) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=135016 
State-Changed-From-To: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Sun Oct 23 22:51:11 UTC 2011 
State-Changed-Why:  



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