2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that the following conditions
5 * 1. Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer,
7 * verbatim and that no modifications are made prior to this
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * used floppy.c and cdrom.c as templates, edited as necessary.
30 #include <sys/fcntl.h>
31 #include <sys/param.h>
32 #include <sys/mount.h>
34 #include <ufs/ufs/ufsmount.h>
36 #include "sysinstall.h"
38 static Boolean USBMounted;
39 static char mountpoint[] = "/dist";
42 mediaInitUSB(Device *dev)
44 struct ufs_args ufsargs;
51 memset(&ufsargs, 0, sizeof(ufsargs));
52 ufsargs.fspec = dev->devname;
54 if (mount("ufs", mountpoint, MNT_RDONLY, (caddr_t)&ufsargs) != -1) {
59 msgConfirm("Error mounting USB drive %s (%s) on %s : %s",
60 dev->name, dev->devname, mountpoint, strerror(errno));
66 mediaGetUSB(Device *dev, char *file, Boolean probe)
68 return mediaGenericGet(mountpoint, file);
73 * When sysinstall terminates, all USB drives handled by deviceRegister will
74 * be checked and unmounted if necessary.
77 mediaShutdownUSB(Device *dev)
82 if (unmount(mountpoint, MNT_FORCE) != 0)
83 msgConfirm("Could not unmount the USB drive from %s: %s",
84 mountpoint, strerror(errno));