Deleted Added
full compact
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 $
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 args.fspec = dev->devname;
73 args.uid = args.gid = 0;
74
75 if (mount(MOUNT_MSDOS, "/dos", MNT_RDONLY, (caddr_t)&args) == -1) {
76 msgConfirm("Error mounting %s on /dos: %s (%u)\n", dev, strerror(errno), errno);
77 return FALSE;
78 }
79 DOSMounted = TRUE;
80 return TRUE;
81}
82
83int
84mediaGetDOS(char *file)
85{
86 char buf[PATH_MAX];
87
88 snprintf(buf, PATH_MAX, "/dos/%s", file);
89 return open(buf, O_RDONLY);
90}
91
92void
93mediaShutdownDOS(Device *dev)
94{
95 if (!DOSMounted)
96 return;
97 msgDebug("Unmounting /dos\n");
98 if (unmount("/dos", 0) != 0)
99 msgConfirm("Could not unmount the DOS partition: %s\n", strerror(errno));
100 msgDebug("Unmount returned\n");
101 DOSMounted = FALSE;
102 return;
103}