1/* 2 * The new sysinstall program. 3 * 4 * This is probably the last attempt in the `sysinstall' line, the next 5 * generation being slated to essentially a complete rewrite. 6 *
|
7 * $Id: dos.c,v 1.2 1995/05/27 23:39:28 phk Exp $
|
7 * $Id: dos.c,v 1.3 1995/05/28 03:04:54 jkh Exp $ |
8 * 9 * Copyright (c) 1995 10 * Jordan Hubbard. All rights reserved. 11 * Copyright (c) 1995 12 * Gary J Palmer. All rights reserved. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions 16 * are met: 17 * 1. Redistributions of source code must retain the above copyright 18 * notice, this list of conditions and the following disclaimer, 19 * verbatim and that no modifications are made prior to this 20 * point in the file. 21 * 2. Redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in the 23 * documentation and/or other materials provided with the distribution. 24 * 3. All advertising materials mentioning features or use of this software 25 * must display the following acknowledgement: 26 * This product includes software developed by Jordan Hubbard 27 * for the FreeBSD Project. 28 * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to 29 * endorse or promote products derived from this software without specific 30 * prior written permission. 31 * 32 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND 33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE 36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 42 * SUCH DAMAGE. 43 * 44 */ 45 46#include "sysinstall.h" 47#include <sys/stat.h> 48#include <sys/errno.h> 49#include <sys/param.h> 50#include <sys/wait.h> 51#include <unistd.h> 52#include <fcntl.h> 53#include <grp.h> 54 55#define MSDOSFS 56#include <sys/mount.h> 57#undef MSDOSFS 58 59static Boolean DOSMounted; 60 61Boolean 62mediaInitDOS(Device *dev) 63{ 64 struct msdosfs_args args; 65 66 if (DOSMounted) 67 return TRUE; 68 69 if (Mkdir("/dos", NULL)) 70 return FALSE; 71
|
72 bzero(&args, sizeof(args)); |
73 args.fspec = dev->devname; 74 args.uid = args.gid = 0; 75 76 if (mount(MOUNT_MSDOS, "/dos", MNT_RDONLY, (caddr_t)&args) == -1) { 77 msgConfirm("Error mounting %s on /dos: %s (%u)\n", dev, strerror(errno), errno); 78 return FALSE; 79 } 80 DOSMounted = TRUE; 81 return TRUE; 82} 83 84int 85mediaGetDOS(char *file) 86{ 87 char buf[PATH_MAX]; 88
|
88 snprintf(buf, PATH_MAX, "/dos/%s", file);
|
89 snprintf(buf, PATH_MAX, "/dos/freebsd/%s", file); 90 if (!access(buf, R_OK)) 91 return open(buf, O_RDONLY); 92 snprintf(buf, PATH_MAX, "/dos/freebsd/dists/%s", file); |
93 return open(buf, O_RDONLY); 94} 95 96void 97mediaShutdownDOS(Device *dev) 98{ 99 if (!DOSMounted) 100 return; 101 msgDebug("Unmounting /dos\n"); 102 if (unmount("/dos", 0) != 0) 103 msgConfirm("Could not unmount the DOS partition: %s\n", strerror(errno));
|
100 msgDebug("Unmount returned\n");
|
104 if (isDebug()) 105 msgDebug("Unmount returned\n"); |
106 DOSMounted = FALSE; 107 return; 108}
|