1 |
|
|
/* $OpenBSD: ufs_ops.c,v 1.10 2014/10/26 03:28:41 guenther Exp $ */ |
2 |
|
|
|
3 |
|
|
/* |
4 |
|
|
* Copyright (c) 1990 Jan-Simon Pendry |
5 |
|
|
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine |
6 |
|
|
* Copyright (c) 1990, 1993 |
7 |
|
|
* The Regents of the University of California. All rights reserved. |
8 |
|
|
* |
9 |
|
|
* This code is derived from software contributed to Berkeley by |
10 |
|
|
* Jan-Simon Pendry at Imperial College, London. |
11 |
|
|
* |
12 |
|
|
* Redistribution and use in source and binary forms, with or without |
13 |
|
|
* modification, are permitted provided that the following conditions |
14 |
|
|
* are met: |
15 |
|
|
* 1. Redistributions of source code must retain the above copyright |
16 |
|
|
* notice, this list of conditions and the following disclaimer. |
17 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
18 |
|
|
* notice, this list of conditions and the following disclaimer in the |
19 |
|
|
* documentation and/or other materials provided with the distribution. |
20 |
|
|
* 3. Neither the name of the University nor the names of its contributors |
21 |
|
|
* may be used to endorse or promote products derived from this software |
22 |
|
|
* without specific prior written permission. |
23 |
|
|
* |
24 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
25 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
26 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
27 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
28 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
29 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
30 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
31 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
32 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
33 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
34 |
|
|
* SUCH DAMAGE. |
35 |
|
|
* |
36 |
|
|
* from: @(#)ufs_ops.c 8.1 (Berkeley) 6/6/93 |
37 |
|
|
*/ |
38 |
|
|
|
39 |
|
|
#include "am.h" |
40 |
|
|
|
41 |
|
|
#ifdef HAS_UFS |
42 |
|
|
|
43 |
|
|
#include <sys/stat.h> |
44 |
|
|
|
45 |
|
|
/* |
46 |
|
|
* UN*X file system |
47 |
|
|
*/ |
48 |
|
|
|
49 |
|
|
/* |
50 |
|
|
* UFS needs local filesystem and device. |
51 |
|
|
*/ |
52 |
|
|
static char * |
53 |
|
|
ufs_match(am_opts *fo) |
54 |
|
|
{ |
55 |
|
|
if (!fo->opt_dev) { |
56 |
|
|
plog(XLOG_USER, "ufs: no device specified"); |
57 |
|
|
return 0; |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
#ifdef DEBUG |
61 |
|
|
dlog("UFS: mounting device \"%s\" on \"%s\"", |
62 |
|
|
fo->opt_dev, fo->opt_fs); |
63 |
|
|
#endif /* DEBUG */ |
64 |
|
|
|
65 |
|
|
/* |
66 |
|
|
* Determine magic cookie to put in mtab |
67 |
|
|
*/ |
68 |
|
|
return strdup(fo->opt_dev); |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
static int |
72 |
|
|
mount_ufs(char *dir, char *fs_name, char *opts) |
73 |
|
|
{ |
74 |
|
|
struct ufs_args ufs_args; |
75 |
|
|
struct mntent mnt; |
76 |
|
|
int flags; |
77 |
|
|
|
78 |
|
|
/* |
79 |
|
|
* Figure out the name of the file system type. |
80 |
|
|
*/ |
81 |
|
|
const char *type = MOUNT_FFS; |
82 |
|
|
|
83 |
|
|
bzero(&ufs_args, sizeof(ufs_args)); /* Paranoid */ |
84 |
|
|
|
85 |
|
|
/* |
86 |
|
|
* Fill in the mount structure |
87 |
|
|
*/ |
88 |
|
|
mnt.mnt_dir = dir; |
89 |
|
|
mnt.mnt_fsname = fs_name; |
90 |
|
|
mnt.mnt_type = "ffs"; |
91 |
|
|
mnt.mnt_opts = opts; |
92 |
|
|
mnt.mnt_freq = 1; |
93 |
|
|
mnt.mnt_passno = 2; |
94 |
|
|
|
95 |
|
|
flags = compute_mount_flags(&mnt); |
96 |
|
|
|
97 |
|
|
ufs_args.fspec = fs_name; |
98 |
|
|
|
99 |
|
|
/* |
100 |
|
|
* Call generic mount routine |
101 |
|
|
*/ |
102 |
|
|
return mount_fs(&mnt, flags, (caddr_t) &ufs_args, 0, type); |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
static int |
106 |
|
|
ufs_fmount(mntfs *mf) |
107 |
|
|
{ |
108 |
|
|
int error; |
109 |
|
|
|
110 |
|
|
error = mount_ufs(mf->mf_mount, mf->mf_info, mf->mf_mopts); |
111 |
|
|
if (error) { |
112 |
|
|
errno = error; |
113 |
|
|
plog(XLOG_ERROR, "mount_ufs: %m"); |
114 |
|
|
return error; |
115 |
|
|
} |
116 |
|
|
|
117 |
|
|
return 0; |
118 |
|
|
} |
119 |
|
|
|
120 |
|
|
static int |
121 |
|
|
ufs_fumount(mntfs *mf) |
122 |
|
|
{ |
123 |
|
|
return umount_fs(mf->mf_mount); |
124 |
|
|
} |
125 |
|
|
|
126 |
|
|
/* |
127 |
|
|
* Ops structure |
128 |
|
|
*/ |
129 |
|
|
am_ops ufs_ops = { |
130 |
|
|
"ufs", |
131 |
|
|
ufs_match, |
132 |
|
|
0, /* ufs_init */ |
133 |
|
|
auto_fmount, |
134 |
|
|
ufs_fmount, |
135 |
|
|
auto_fumount, |
136 |
|
|
ufs_fumount, |
137 |
|
|
efs_lookuppn, |
138 |
|
|
efs_readdir, |
139 |
|
|
0, /* ufs_readlink */ |
140 |
|
|
0, /* ufs_mounted */ |
141 |
|
|
0, /* ufs_umounted */ |
142 |
|
|
find_afs_srvr, |
143 |
|
|
#ifdef FLUSH_KERNEL_NAME_CACHE |
144 |
|
|
FS_MKMNT|FS_NOTIMEOUT|FS_UBACKGROUND|FS_AMQINFO |
145 |
|
|
#else /* FLUSH_KERNEL_NAME_CACHE */ |
146 |
|
|
FS_MKMNT|FS_NOTIMEOUT|FS_UBACKGROUND|FS_AMQINFO |
147 |
|
|
#endif /* FLUSH_KERNEL_NAME_CACHE */ |
148 |
|
|
}; |
149 |
|
|
|
150 |
|
|
#endif /* HAS_UFS */ |