Deleted Added
sdiff udiff text old ( 14321 ) new ( 15242 )
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.9 1996/03/02 07:31:52 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 *
25 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 */
38
39#include "sysinstall.h"
40#include <sys/stat.h>
41#include <sys/errno.h>
42#include <sys/param.h>
43#include <sys/wait.h>
44#include <unistd.h>
45#include <fcntl.h>
46#include <grp.h>
47
48#define MSDOSFS
49#include <sys/mount.h>
50#undef MSDOSFS
51
52static Boolean DOSMounted;
53
54Boolean
55mediaInitDOS(Device *dev)
56{
57 struct msdosfs_args args;
58
59 if (!RunningAsInit || DOSMounted)
60 return TRUE;
61
62 if (Mkdir("/dos", NULL) != DITEM_SUCCESS)
63 return FALSE;
64
65 memset(&args, 0, sizeof(args));
66 args.fspec = dev->devname;
67 args.uid = args.gid = 0;
68 args.mask = 0777;
69
70 if (mount(MOUNT_MSDOS, "/dos", MNT_RDONLY, (caddr_t)&args) == -1) {
71 dialog_clear();
72 msgConfirm("Error mounting %s on /dos: %s (%u)", args.fspec, strerror(errno), errno);
73 return FALSE;
74 }
75 else
76 msgDebug("Mounted DOS device (%s) on /dos.\n", args.fspec);
77 DOSMounted = TRUE;
78 return TRUE;
79}
80
81int
82mediaGetDOS(Device *dev, char *file, Boolean probe)
83{
84 char buf[PATH_MAX];
85
86 msgDebug("Request for %s from DOS\n", file);
87 snprintf(buf, PATH_MAX, "/dos/freebsd/%s", file);
88 if (file_readable(buf))
89 return open(buf, O_RDONLY);
90 snprintf(buf, PATH_MAX, "/dos/freebsd/dists/%s", file);
91 if (file_readable(buf))
92 return open(buf, O_RDONLY);
93 snprintf(buf, PATH_MAX, "/dos/%s", file);
94 if (file_readable(buf))
95 return open(buf, O_RDONLY);
96 snprintf(buf, PATH_MAX, "/dos/dists/%s", file);
97 return open(buf, O_RDONLY);
98}
99
100void
101mediaShutdownDOS(Device *dev)
102{
103 if (!RunningAsInit || !DOSMounted)
104 return;
105 msgDebug("Unmounting %s from /dos\n", dev->name);
106 if (unmount("/dos", MNT_FORCE) != 0) {
107 dialog_clear();
108 msgConfirm("Could not unmount the DOS partition: %s", strerror(errno));
109 }
110 if (isDebug())
111 msgDebug("Unmount successful\n");
112 DOSMounted = FALSE;
113 return;
114}