cd9660_vfsops.c revision 1.59 1 1.59 ad /* $NetBSD: cd9660_vfsops.c,v 1.59 2008/04/30 12:49:16 ad Exp $ */
2 1.1 jdolecek
3 1.1 jdolecek /*-
4 1.1 jdolecek * Copyright (c) 1994
5 1.1 jdolecek * The Regents of the University of California. All rights reserved.
6 1.1 jdolecek *
7 1.1 jdolecek * This code is derived from software contributed to Berkeley
8 1.1 jdolecek * by Pace Willisson (pace (at) blitz.com). The Rock Ridge Extension
9 1.1 jdolecek * Support code is derived from software contributed to Berkeley
10 1.1 jdolecek * by Atsushi Murai (amurai (at) spec.co.jp).
11 1.1 jdolecek *
12 1.1 jdolecek * Redistribution and use in source and binary forms, with or without
13 1.1 jdolecek * modification, are permitted provided that the following conditions
14 1.1 jdolecek * are met:
15 1.1 jdolecek * 1. Redistributions of source code must retain the above copyright
16 1.1 jdolecek * notice, this list of conditions and the following disclaimer.
17 1.1 jdolecek * 2. Redistributions in binary form must reproduce the above copyright
18 1.1 jdolecek * notice, this list of conditions and the following disclaimer in the
19 1.1 jdolecek * documentation and/or other materials provided with the distribution.
20 1.9 agc * 3. Neither the name of the University nor the names of its contributors
21 1.1 jdolecek * may be used to endorse or promote products derived from this software
22 1.1 jdolecek * without specific prior written permission.
23 1.1 jdolecek *
24 1.1 jdolecek * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 1.1 jdolecek * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 1.1 jdolecek * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 1.1 jdolecek * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 1.1 jdolecek * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 1.1 jdolecek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 1.1 jdolecek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.1 jdolecek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.1 jdolecek * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.1 jdolecek * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.1 jdolecek * SUCH DAMAGE.
35 1.1 jdolecek *
36 1.1 jdolecek * @(#)cd9660_vfsops.c 8.18 (Berkeley) 5/22/95
37 1.1 jdolecek */
38 1.1 jdolecek
39 1.1 jdolecek #include <sys/cdefs.h>
40 1.59 ad __KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.59 2008/04/30 12:49:16 ad Exp $");
41 1.1 jdolecek
42 1.1 jdolecek #if defined(_KERNEL_OPT)
43 1.1 jdolecek #include "opt_compat_netbsd.h"
44 1.1 jdolecek #endif
45 1.1 jdolecek
46 1.1 jdolecek #include <sys/param.h>
47 1.10 atatat #include <sys/sysctl.h>
48 1.1 jdolecek #include <sys/systm.h>
49 1.1 jdolecek #include <sys/namei.h>
50 1.1 jdolecek #include <sys/proc.h>
51 1.1 jdolecek #include <sys/kernel.h>
52 1.1 jdolecek #include <sys/vnode.h>
53 1.55 dholland #include <miscfs/genfs/genfs.h>
54 1.1 jdolecek #include <miscfs/specfs/specdev.h>
55 1.1 jdolecek #include <sys/mount.h>
56 1.1 jdolecek #include <sys/buf.h>
57 1.1 jdolecek #include <sys/file.h>
58 1.1 jdolecek #include <sys/disklabel.h>
59 1.1 jdolecek #include <sys/device.h>
60 1.1 jdolecek #include <sys/ioctl.h>
61 1.1 jdolecek #include <sys/cdio.h>
62 1.1 jdolecek #include <sys/errno.h>
63 1.1 jdolecek #include <sys/malloc.h>
64 1.1 jdolecek #include <sys/pool.h>
65 1.1 jdolecek #include <sys/stat.h>
66 1.1 jdolecek #include <sys/conf.h>
67 1.18 jdolecek #include <sys/dirent.h>
68 1.32 elad #include <sys/kauth.h>
69 1.1 jdolecek
70 1.1 jdolecek #include <fs/cd9660/iso.h>
71 1.1 jdolecek #include <fs/cd9660/cd9660_extern.h>
72 1.1 jdolecek #include <fs/cd9660/iso_rrip.h>
73 1.1 jdolecek #include <fs/cd9660/cd9660_node.h>
74 1.1 jdolecek #include <fs/cd9660/cd9660_mount.h>
75 1.2 thorpej
76 1.41 pooka MALLOC_JUSTDEFINE(M_ISOFSMNT, "ISOFS mount", "ISOFS mount structure");
77 1.1 jdolecek
78 1.1 jdolecek extern const struct vnodeopv_desc cd9660_vnodeop_opv_desc;
79 1.1 jdolecek extern const struct vnodeopv_desc cd9660_specop_opv_desc;
80 1.1 jdolecek extern const struct vnodeopv_desc cd9660_fifoop_opv_desc;
81 1.1 jdolecek
82 1.1 jdolecek const struct vnodeopv_desc * const cd9660_vnodeopv_descs[] = {
83 1.1 jdolecek &cd9660_vnodeop_opv_desc,
84 1.1 jdolecek &cd9660_specop_opv_desc,
85 1.1 jdolecek &cd9660_fifoop_opv_desc,
86 1.1 jdolecek NULL,
87 1.1 jdolecek };
88 1.1 jdolecek
89 1.1 jdolecek struct vfsops cd9660_vfsops = {
90 1.1 jdolecek MOUNT_CD9660,
91 1.43 dsl sizeof (struct iso_args),
92 1.1 jdolecek cd9660_mount,
93 1.1 jdolecek cd9660_start,
94 1.1 jdolecek cd9660_unmount,
95 1.1 jdolecek cd9660_root,
96 1.50 pooka (void *)eopnotsupp,
97 1.12 christos cd9660_statvfs,
98 1.1 jdolecek cd9660_sync,
99 1.1 jdolecek cd9660_vget,
100 1.1 jdolecek cd9660_fhtovp,
101 1.1 jdolecek cd9660_vptofh,
102 1.1 jdolecek cd9660_init,
103 1.1 jdolecek cd9660_reinit,
104 1.1 jdolecek cd9660_done,
105 1.1 jdolecek cd9660_mountroot,
106 1.15 hannken (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp,
107 1.20 thorpej vfs_stdextattrctl,
108 1.46 pooka (void *)eopnotsupp, /* vfs_suspendctl */
109 1.55 dholland genfs_renamelock_enter,
110 1.55 dholland genfs_renamelock_exit,
111 1.58 ad (void *)eopnotsupp,
112 1.1 jdolecek cd9660_vnodeopv_descs,
113 1.35 christos 0, /* refcount */
114 1.35 christos { NULL, NULL } /* list */
115 1.1 jdolecek };
116 1.23 thorpej VFS_ATTACH(cd9660_vfsops);
117 1.1 jdolecek
118 1.24 yamt static const struct genfs_ops cd9660_genfsops = {
119 1.24 yamt .gop_size = genfs_size,
120 1.1 jdolecek };
121 1.1 jdolecek
122 1.1 jdolecek /*
123 1.1 jdolecek * Called by vfs_mountroot when iso is going to be mounted as root.
124 1.1 jdolecek *
125 1.1 jdolecek * Name is updated by mount(8) after booting.
126 1.1 jdolecek */
127 1.1 jdolecek #define ROOTNAME "root_device"
128 1.1 jdolecek
129 1.26 xtraeme static int iso_makemp(struct iso_mnt *isomp, struct buf *bp, int *ea_len);
130 1.26 xtraeme static int iso_mountfs(struct vnode *devvp, struct mount *mp,
131 1.30 christos struct lwp *l, struct iso_args *argp);
132 1.1 jdolecek
133 1.1 jdolecek int
134 1.57 matt cd9660_mountroot(void)
135 1.1 jdolecek {
136 1.1 jdolecek struct mount *mp;
137 1.50 pooka struct lwp *l = curlwp;
138 1.1 jdolecek int error;
139 1.1 jdolecek struct iso_args args;
140 1.1 jdolecek
141 1.31 thorpej if (device_class(root_device) != DV_DISK)
142 1.1 jdolecek return (ENODEV);
143 1.22 perry
144 1.1 jdolecek if ((error = vfs_rootmountalloc(MOUNT_CD9660, "root_device", &mp))
145 1.1 jdolecek != 0) {
146 1.1 jdolecek vrele(rootvp);
147 1.1 jdolecek return (error);
148 1.1 jdolecek }
149 1.1 jdolecek
150 1.1 jdolecek args.flags = ISOFSMNT_ROOT;
151 1.30 christos if ((error = iso_mountfs(rootvp, mp, l, &args)) != 0) {
152 1.59 ad vfs_unbusy(mp, false, NULL);
153 1.59 ad vfs_destroy(mp, false);
154 1.1 jdolecek return (error);
155 1.1 jdolecek }
156 1.49 ad mutex_enter(&mountlist_lock);
157 1.1 jdolecek CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
158 1.59 ad mp->mnt_iflag |= IMNT_ONLIST;
159 1.49 ad mutex_exit(&mountlist_lock);
160 1.50 pooka (void)cd9660_statvfs(mp, &mp->mnt_stat);
161 1.59 ad vfs_unbusy(mp, false, NULL);
162 1.1 jdolecek return (0);
163 1.1 jdolecek }
164 1.1 jdolecek
165 1.1 jdolecek /*
166 1.1 jdolecek * VFS Operations.
167 1.1 jdolecek *
168 1.1 jdolecek * mount system call
169 1.1 jdolecek */
170 1.1 jdolecek int
171 1.57 matt cd9660_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
172 1.1 jdolecek {
173 1.50 pooka struct lwp *l = curlwp;
174 1.47 pooka struct nameidata nd;
175 1.1 jdolecek struct vnode *devvp;
176 1.43 dsl struct iso_args *args = data;
177 1.1 jdolecek int error;
178 1.28 dyoung struct iso_mnt *imp = VFSTOISOFS(mp);
179 1.22 perry
180 1.43 dsl if (*data_len < sizeof *args)
181 1.43 dsl return EINVAL;
182 1.43 dsl
183 1.1 jdolecek if (mp->mnt_flag & MNT_GETARGS) {
184 1.1 jdolecek if (imp == NULL)
185 1.1 jdolecek return EIO;
186 1.43 dsl args->fspec = NULL;
187 1.43 dsl args->flags = imp->im_flags;
188 1.43 dsl *data_len = sizeof (*args);
189 1.43 dsl return 0;
190 1.1 jdolecek }
191 1.22 perry
192 1.1 jdolecek if ((mp->mnt_flag & MNT_RDONLY) == 0)
193 1.1 jdolecek return (EROFS);
194 1.22 perry
195 1.43 dsl if ((mp->mnt_flag & MNT_UPDATE) && args->fspec == NULL)
196 1.27 jmmv return EINVAL;
197 1.27 jmmv
198 1.1 jdolecek /*
199 1.1 jdolecek * Not an update, or updating the name: look up the name
200 1.1 jdolecek * and verify that it refers to a sensible block device.
201 1.1 jdolecek */
202 1.52 pooka NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, args->fspec);
203 1.47 pooka if ((error = namei(&nd)) != 0)
204 1.1 jdolecek return (error);
205 1.47 pooka devvp = nd.ni_vp;
206 1.1 jdolecek
207 1.1 jdolecek if (devvp->v_type != VBLK) {
208 1.1 jdolecek vrele(devvp);
209 1.1 jdolecek return ENOTBLK;
210 1.1 jdolecek }
211 1.1 jdolecek if (bdevsw_lookup(devvp->v_rdev) == NULL) {
212 1.1 jdolecek vrele(devvp);
213 1.1 jdolecek return ENXIO;
214 1.1 jdolecek }
215 1.1 jdolecek /*
216 1.1 jdolecek * If mount by non-root, then verify that user has necessary
217 1.1 jdolecek * permissions on the device.
218 1.1 jdolecek */
219 1.34 ad if (kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, NULL) != 0) {
220 1.1 jdolecek vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
221 1.50 pooka error = VOP_ACCESS(devvp, VREAD, l->l_cred);
222 1.1 jdolecek VOP_UNLOCK(devvp, 0);
223 1.1 jdolecek if (error) {
224 1.1 jdolecek vrele(devvp);
225 1.1 jdolecek return (error);
226 1.1 jdolecek }
227 1.1 jdolecek }
228 1.21 mycroft if ((mp->mnt_flag & MNT_UPDATE) == 0) {
229 1.50 pooka error = VOP_OPEN(devvp, FREAD, FSCRED);
230 1.21 mycroft if (error)
231 1.21 mycroft goto fail;
232 1.43 dsl error = iso_mountfs(devvp, mp, l, args);
233 1.21 mycroft if (error) {
234 1.21 mycroft vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
235 1.50 pooka (void)VOP_CLOSE(devvp, FREAD, NOCRED);
236 1.21 mycroft VOP_UNLOCK(devvp, 0);
237 1.21 mycroft goto fail;
238 1.21 mycroft }
239 1.21 mycroft } else {
240 1.21 mycroft vrele(devvp);
241 1.1 jdolecek if (devvp != imp->im_devvp)
242 1.21 mycroft return (EINVAL); /* needs translation */
243 1.1 jdolecek }
244 1.43 dsl return set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE,
245 1.44 pooka mp->mnt_op->vfs_name, mp, l);
246 1.21 mycroft
247 1.21 mycroft fail:
248 1.21 mycroft vrele(devvp);
249 1.21 mycroft return (error);
250 1.1 jdolecek }
251 1.1 jdolecek
252 1.1 jdolecek /*
253 1.1 jdolecek * Make a mount point from a volume descriptor
254 1.1 jdolecek */
255 1.1 jdolecek static int
256 1.57 matt iso_makemp(struct iso_mnt *isomp, struct buf *bp, int *ea_len)
257 1.1 jdolecek {
258 1.1 jdolecek struct iso_primary_descriptor *pri;
259 1.1 jdolecek int logical_block_size;
260 1.1 jdolecek struct iso_directory_record *rootp;
261 1.1 jdolecek
262 1.1 jdolecek pri = (struct iso_primary_descriptor *)bp->b_data;
263 1.22 perry
264 1.1 jdolecek logical_block_size = isonum_723 (pri->logical_block_size);
265 1.22 perry
266 1.1 jdolecek if (logical_block_size < DEV_BSIZE || logical_block_size > MAXBSIZE
267 1.1 jdolecek || (logical_block_size & (logical_block_size - 1)) != 0)
268 1.1 jdolecek return -1;
269 1.22 perry
270 1.1 jdolecek rootp = (struct iso_directory_record *)pri->root_directory_record;
271 1.22 perry
272 1.1 jdolecek isomp->logical_block_size = logical_block_size;
273 1.1 jdolecek isomp->volume_space_size = isonum_733 (pri->volume_space_size);
274 1.1 jdolecek memcpy(isomp->root, rootp, sizeof(isomp->root));
275 1.1 jdolecek isomp->root_extent = isonum_733 (rootp->extent);
276 1.1 jdolecek isomp->root_size = isonum_733 (rootp->size);
277 1.1 jdolecek isomp->im_joliet_level = 0;
278 1.22 perry
279 1.1 jdolecek isomp->im_bmask = logical_block_size - 1;
280 1.1 jdolecek isomp->im_bshift = 0;
281 1.1 jdolecek while ((1 << isomp->im_bshift) < isomp->logical_block_size)
282 1.1 jdolecek isomp->im_bshift++;
283 1.1 jdolecek
284 1.1 jdolecek if (ea_len != NULL)
285 1.1 jdolecek *ea_len = isonum_711(rootp->ext_attr_length);
286 1.1 jdolecek
287 1.1 jdolecek return 0;
288 1.1 jdolecek }
289 1.1 jdolecek
290 1.1 jdolecek /*
291 1.1 jdolecek * Common code for mount and mountroot
292 1.1 jdolecek */
293 1.1 jdolecek static int
294 1.57 matt iso_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l,
295 1.57 matt struct iso_args *argp)
296 1.1 jdolecek {
297 1.1 jdolecek struct iso_mnt *isomp = (struct iso_mnt *)0;
298 1.1 jdolecek struct buf *bp = NULL, *pribp = NULL, *supbp = NULL;
299 1.1 jdolecek dev_t dev = devvp->v_rdev;
300 1.1 jdolecek int error = EINVAL;
301 1.1 jdolecek int ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
302 1.1 jdolecek int iso_bsize;
303 1.1 jdolecek int iso_blknum;
304 1.1 jdolecek int joliet_level;
305 1.1 jdolecek struct iso_volume_descriptor *vdp;
306 1.1 jdolecek struct iso_supplementary_descriptor *sup;
307 1.1 jdolecek int sess = 0;
308 1.1 jdolecek int ext_attr_length;
309 1.1 jdolecek struct disklabel label;
310 1.1 jdolecek
311 1.1 jdolecek if (!ronly)
312 1.1 jdolecek return EROFS;
313 1.22 perry
314 1.21 mycroft /* Flush out any old buffers remaining from a previous use. */
315 1.34 ad if ((error = vinvalbuf(devvp, V_SAVE, l->l_cred, l, 0, 0)) != 0)
316 1.1 jdolecek return (error);
317 1.22 perry
318 1.1 jdolecek /* This is the "logical sector size". The standard says this
319 1.1 jdolecek * should be 2048 or the physical sector size on the device,
320 1.1 jdolecek * whichever is greater. For now, we'll just use a constant.
321 1.1 jdolecek */
322 1.1 jdolecek iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
323 1.1 jdolecek
324 1.50 pooka error = VOP_IOCTL(devvp, DIOCGDINFO, &label, FREAD, FSCRED);
325 1.1 jdolecek if (!error &&
326 1.1 jdolecek label.d_partitions[DISKPART(dev)].p_fstype == FS_ISO9660) {
327 1.1 jdolecek /* XXX more sanity checks? */
328 1.1 jdolecek sess = label.d_partitions[DISKPART(dev)].p_cdsession;
329 1.1 jdolecek } else {
330 1.1 jdolecek /* fallback to old method */
331 1.50 pooka error = VOP_IOCTL(devvp, CDIOREADMSADDR, &sess, 0, FSCRED);
332 1.1 jdolecek if (error)
333 1.1 jdolecek sess = 0; /* never mind */
334 1.1 jdolecek }
335 1.4 christos #ifdef ISO_DEBUG
336 1.1 jdolecek printf("isofs: session offset (part %d) %d\n", DISKPART(dev), sess);
337 1.1 jdolecek #endif
338 1.1 jdolecek
339 1.1 jdolecek for (iso_blknum = 16; iso_blknum < 100; iso_blknum++) {
340 1.1 jdolecek if ((error = bread(devvp, (iso_blknum+sess) * btodb(iso_bsize),
341 1.1 jdolecek iso_bsize, NOCRED, &bp)) != 0)
342 1.1 jdolecek goto out;
343 1.22 perry
344 1.1 jdolecek vdp = (struct iso_volume_descriptor *)bp->b_data;
345 1.1 jdolecek if (memcmp(vdp->id, ISO_STANDARD_ID, sizeof(vdp->id)) != 0) {
346 1.1 jdolecek error = EINVAL;
347 1.1 jdolecek goto out;
348 1.1 jdolecek }
349 1.1 jdolecek
350 1.1 jdolecek switch (isonum_711(vdp->type)) {
351 1.1 jdolecek case ISO_VD_PRIMARY:
352 1.1 jdolecek if (pribp == NULL) {
353 1.1 jdolecek pribp = bp;
354 1.1 jdolecek bp = NULL;
355 1.1 jdolecek }
356 1.1 jdolecek break;
357 1.1 jdolecek
358 1.1 jdolecek case ISO_VD_SUPPLEMENTARY:
359 1.1 jdolecek if (supbp == NULL) {
360 1.1 jdolecek supbp = bp;
361 1.1 jdolecek bp = NULL;
362 1.1 jdolecek }
363 1.1 jdolecek break;
364 1.1 jdolecek
365 1.1 jdolecek default:
366 1.1 jdolecek break;
367 1.1 jdolecek }
368 1.1 jdolecek
369 1.1 jdolecek if (isonum_711 (vdp->type) == ISO_VD_END) {
370 1.48 ad brelse(bp, 0);
371 1.1 jdolecek bp = NULL;
372 1.1 jdolecek break;
373 1.1 jdolecek }
374 1.1 jdolecek
375 1.1 jdolecek if (bp != NULL) {
376 1.48 ad brelse(bp, 0);
377 1.1 jdolecek bp = NULL;
378 1.1 jdolecek }
379 1.1 jdolecek }
380 1.1 jdolecek
381 1.1 jdolecek if (pribp == NULL) {
382 1.1 jdolecek error = EINVAL;
383 1.1 jdolecek goto out;
384 1.1 jdolecek }
385 1.1 jdolecek
386 1.1 jdolecek isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK);
387 1.3 dsl memset(isomp, 0, sizeof *isomp);
388 1.1 jdolecek if (iso_makemp(isomp, pribp, &ext_attr_length) == -1) {
389 1.1 jdolecek error = EINVAL;
390 1.1 jdolecek goto out;
391 1.1 jdolecek }
392 1.1 jdolecek
393 1.1 jdolecek isomp->volume_space_size += sess;
394 1.1 jdolecek
395 1.48 ad brelse(pribp, BC_AGE);
396 1.1 jdolecek pribp = NULL;
397 1.22 perry
398 1.1 jdolecek mp->mnt_data = isomp;
399 1.12 christos mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)dev;
400 1.12 christos mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_CD9660);
401 1.12 christos mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
402 1.18 jdolecek mp->mnt_stat.f_namemax = MAXNAMLEN;
403 1.1 jdolecek mp->mnt_flag |= MNT_LOCAL;
404 1.53 ad mp->mnt_iflag |= IMNT_MPSAFE;
405 1.1 jdolecek mp->mnt_dev_bshift = iso_bsize;
406 1.1 jdolecek mp->mnt_fs_bshift = isomp->im_bshift;
407 1.1 jdolecek isomp->im_mountp = mp;
408 1.1 jdolecek isomp->im_dev = dev;
409 1.1 jdolecek isomp->im_devvp = devvp;
410 1.22 perry
411 1.1 jdolecek /* Check the Rock Ridge Extension support */
412 1.1 jdolecek if (!(argp->flags & ISOFSMNT_NORRIP)) {
413 1.1 jdolecek struct iso_directory_record *rootp;
414 1.1 jdolecek
415 1.1 jdolecek if ((error = bread(isomp->im_devvp,
416 1.1 jdolecek (isomp->root_extent + ext_attr_length) <<
417 1.1 jdolecek (isomp->im_bshift - DEV_BSHIFT),
418 1.1 jdolecek isomp->logical_block_size, NOCRED,
419 1.1 jdolecek &bp)) != 0)
420 1.1 jdolecek goto out;
421 1.22 perry
422 1.1 jdolecek rootp = (struct iso_directory_record *)bp->b_data;
423 1.22 perry
424 1.1 jdolecek if ((isomp->rr_skip = cd9660_rrip_offset(rootp,isomp)) < 0) {
425 1.1 jdolecek argp->flags |= ISOFSMNT_NORRIP;
426 1.1 jdolecek } else {
427 1.1 jdolecek argp->flags &= ~ISOFSMNT_GENS;
428 1.1 jdolecek }
429 1.22 perry
430 1.1 jdolecek /*
431 1.1 jdolecek * The contents are valid,
432 1.1 jdolecek * but they will get reread as part of another vnode, so...
433 1.1 jdolecek */
434 1.48 ad brelse(bp, BC_AGE);
435 1.1 jdolecek bp = NULL;
436 1.1 jdolecek }
437 1.1 jdolecek isomp->im_flags = argp->flags & (ISOFSMNT_NORRIP | ISOFSMNT_GENS |
438 1.1 jdolecek ISOFSMNT_EXTATT | ISOFSMNT_NOJOLIET | ISOFSMNT_RRCASEINS);
439 1.1 jdolecek
440 1.1 jdolecek if (isomp->im_flags & ISOFSMNT_GENS)
441 1.1 jdolecek isomp->iso_ftype = ISO_FTYPE_9660;
442 1.1 jdolecek else if (isomp->im_flags & ISOFSMNT_NORRIP) {
443 1.1 jdolecek isomp->iso_ftype = ISO_FTYPE_DEFAULT;
444 1.1 jdolecek if (argp->flags & ISOFSMNT_NOCASETRANS)
445 1.1 jdolecek isomp->im_flags |= ISOFSMNT_NOCASETRANS;
446 1.22 perry } else
447 1.1 jdolecek isomp->iso_ftype = ISO_FTYPE_RRIP;
448 1.1 jdolecek
449 1.1 jdolecek /* Check the Joliet Extension support */
450 1.1 jdolecek if ((argp->flags & ISOFSMNT_NORRIP) != 0 &&
451 1.1 jdolecek (argp->flags & ISOFSMNT_NOJOLIET) == 0 &&
452 1.1 jdolecek supbp != NULL) {
453 1.1 jdolecek joliet_level = 0;
454 1.1 jdolecek sup = (struct iso_supplementary_descriptor *)supbp->b_data;
455 1.1 jdolecek
456 1.1 jdolecek if ((isonum_711(sup->flags) & 1) == 0) {
457 1.1 jdolecek if (memcmp(sup->escape, "%/@", 3) == 0)
458 1.1 jdolecek joliet_level = 1;
459 1.1 jdolecek if (memcmp(sup->escape, "%/C", 3) == 0)
460 1.1 jdolecek joliet_level = 2;
461 1.1 jdolecek if (memcmp(sup->escape, "%/E", 3) == 0)
462 1.1 jdolecek joliet_level = 3;
463 1.1 jdolecek }
464 1.1 jdolecek if (joliet_level != 0) {
465 1.1 jdolecek if (iso_makemp(isomp, supbp, NULL) == -1) {
466 1.1 jdolecek error = EINVAL;
467 1.1 jdolecek goto out;
468 1.1 jdolecek }
469 1.1 jdolecek isomp->im_joliet_level = joliet_level;
470 1.1 jdolecek }
471 1.1 jdolecek }
472 1.1 jdolecek
473 1.1 jdolecek if (supbp != NULL) {
474 1.48 ad brelse(supbp, 0);
475 1.1 jdolecek supbp = NULL;
476 1.1 jdolecek }
477 1.22 perry
478 1.37 drochner devvp->v_specmountpoint = mp;
479 1.37 drochner
480 1.1 jdolecek return 0;
481 1.1 jdolecek out:
482 1.1 jdolecek if (bp)
483 1.48 ad brelse(bp, 0);
484 1.1 jdolecek if (pribp)
485 1.48 ad brelse(pribp, 0);
486 1.1 jdolecek if (supbp)
487 1.48 ad brelse(supbp, 0);
488 1.1 jdolecek if (isomp) {
489 1.3 dsl free(isomp, M_ISOFSMNT);
490 1.1 jdolecek mp->mnt_data = NULL;
491 1.1 jdolecek }
492 1.1 jdolecek return error;
493 1.1 jdolecek }
494 1.1 jdolecek
495 1.1 jdolecek /*
496 1.1 jdolecek * Make a filesystem operational.
497 1.1 jdolecek * Nothing to do at the moment.
498 1.1 jdolecek */
499 1.1 jdolecek /* ARGSUSED */
500 1.1 jdolecek int
501 1.50 pooka cd9660_start(struct mount *mp, int flags)
502 1.1 jdolecek {
503 1.1 jdolecek return 0;
504 1.1 jdolecek }
505 1.1 jdolecek
506 1.1 jdolecek /*
507 1.1 jdolecek * unmount system call
508 1.1 jdolecek */
509 1.1 jdolecek int
510 1.57 matt cd9660_unmount(struct mount *mp, int mntflags)
511 1.1 jdolecek {
512 1.1 jdolecek struct iso_mnt *isomp;
513 1.1 jdolecek int error, flags = 0;
514 1.22 perry
515 1.1 jdolecek if (mntflags & MNT_FORCE)
516 1.1 jdolecek flags |= FORCECLOSE;
517 1.1 jdolecek if ((error = vflush(mp, NULLVP, flags)) != 0)
518 1.1 jdolecek return (error);
519 1.1 jdolecek
520 1.1 jdolecek isomp = VFSTOISOFS(mp);
521 1.1 jdolecek
522 1.1 jdolecek if (isomp->im_devvp->v_type != VBAD)
523 1.1 jdolecek isomp->im_devvp->v_specmountpoint = NULL;
524 1.1 jdolecek
525 1.1 jdolecek vn_lock(isomp->im_devvp, LK_EXCLUSIVE | LK_RETRY);
526 1.50 pooka error = VOP_CLOSE(isomp->im_devvp, FREAD, NOCRED);
527 1.1 jdolecek vput(isomp->im_devvp);
528 1.3 dsl free(isomp, M_ISOFSMNT);
529 1.1 jdolecek mp->mnt_data = NULL;
530 1.1 jdolecek mp->mnt_flag &= ~MNT_LOCAL;
531 1.1 jdolecek return (error);
532 1.1 jdolecek }
533 1.1 jdolecek
534 1.1 jdolecek /*
535 1.1 jdolecek * Return root of a filesystem
536 1.1 jdolecek */
537 1.1 jdolecek int
538 1.57 matt cd9660_root(struct mount *mp, struct vnode **vpp)
539 1.1 jdolecek {
540 1.1 jdolecek struct iso_mnt *imp = VFSTOISOFS(mp);
541 1.1 jdolecek struct iso_directory_record *dp =
542 1.1 jdolecek (struct iso_directory_record *)imp->root;
543 1.1 jdolecek ino_t ino = isodirino(dp, imp);
544 1.22 perry
545 1.1 jdolecek /*
546 1.1 jdolecek * With RRIP we must use the `.' entry of the root directory.
547 1.1 jdolecek * Simply tell vget, that it's a relocated directory.
548 1.1 jdolecek */
549 1.1 jdolecek return (cd9660_vget_internal(mp, ino, vpp,
550 1.7 thorpej imp->iso_ftype == ISO_FTYPE_RRIP, dp));
551 1.1 jdolecek }
552 1.1 jdolecek
553 1.1 jdolecek /*
554 1.1 jdolecek * Get file system statistics.
555 1.1 jdolecek */
556 1.1 jdolecek int
557 1.57 matt cd9660_statvfs(struct mount *mp, struct statvfs *sbp)
558 1.1 jdolecek {
559 1.1 jdolecek struct iso_mnt *isomp;
560 1.22 perry
561 1.1 jdolecek isomp = VFSTOISOFS(mp);
562 1.1 jdolecek
563 1.1 jdolecek sbp->f_bsize = isomp->logical_block_size;
564 1.12 christos sbp->f_frsize = sbp->f_bsize;
565 1.1 jdolecek sbp->f_iosize = sbp->f_bsize; /* XXX */
566 1.1 jdolecek sbp->f_blocks = isomp->volume_space_size;
567 1.1 jdolecek sbp->f_bfree = 0; /* total free blocks */
568 1.1 jdolecek sbp->f_bavail = 0; /* blocks free for non superuser */
569 1.12 christos sbp->f_bresvd = 0; /* total reserved blocks */
570 1.1 jdolecek sbp->f_files = 0; /* total files */
571 1.1 jdolecek sbp->f_ffree = 0; /* free file nodes */
572 1.25 jmmv sbp->f_favail = 0; /* free file nodes for non superuser */
573 1.12 christos sbp->f_fresvd = 0; /* reserved file nodes */
574 1.12 christos copy_statvfs_info(sbp, mp);
575 1.1 jdolecek /* Use the first spare for flags: */
576 1.1 jdolecek sbp->f_spare[0] = isomp->im_flags;
577 1.1 jdolecek return 0;
578 1.1 jdolecek }
579 1.1 jdolecek
580 1.1 jdolecek /* ARGSUSED */
581 1.1 jdolecek int
582 1.57 matt cd9660_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
583 1.1 jdolecek {
584 1.57 matt return 0;
585 1.1 jdolecek }
586 1.1 jdolecek
587 1.1 jdolecek /*
588 1.1 jdolecek * File handle to vnode
589 1.1 jdolecek *
590 1.1 jdolecek * Have to be really careful about stale file handles:
591 1.1 jdolecek * - check that the inode number is in range
592 1.1 jdolecek * - call iget() to get the locked inode
593 1.1 jdolecek * - check for an unallocated inode (i_mode == 0)
594 1.1 jdolecek * - check that the generation number matches
595 1.1 jdolecek */
596 1.1 jdolecek
597 1.1 jdolecek struct ifid {
598 1.1 jdolecek ushort ifid_len;
599 1.1 jdolecek ushort ifid_pad;
600 1.1 jdolecek int ifid_ino;
601 1.1 jdolecek long ifid_start;
602 1.1 jdolecek };
603 1.1 jdolecek
604 1.1 jdolecek /* ARGSUSED */
605 1.1 jdolecek int
606 1.57 matt cd9660_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
607 1.1 jdolecek {
608 1.33 martin struct ifid ifh;
609 1.1 jdolecek struct iso_node *ip;
610 1.1 jdolecek struct vnode *nvp;
611 1.1 jdolecek int error;
612 1.22 perry
613 1.33 martin if (fhp->fid_len != sizeof(ifh))
614 1.33 martin return EINVAL;
615 1.33 martin
616 1.33 martin memcpy(&ifh, fhp, sizeof(ifh));
617 1.1 jdolecek #ifdef ISOFS_DBG
618 1.1 jdolecek printf("fhtovp: ino %d, start %ld\n",
619 1.33 martin ifh.ifid_ino, ifh.ifid_start);
620 1.1 jdolecek #endif
621 1.22 perry
622 1.33 martin if ((error = VFS_VGET(mp, ifh.ifid_ino, &nvp)) != 0) {
623 1.1 jdolecek *vpp = NULLVP;
624 1.1 jdolecek return (error);
625 1.1 jdolecek }
626 1.1 jdolecek ip = VTOI(nvp);
627 1.1 jdolecek if (ip->inode.iso_mode == 0) {
628 1.1 jdolecek vput(nvp);
629 1.1 jdolecek *vpp = NULLVP;
630 1.1 jdolecek return (ESTALE);
631 1.1 jdolecek }
632 1.1 jdolecek *vpp = nvp;
633 1.1 jdolecek return (0);
634 1.1 jdolecek }
635 1.1 jdolecek
636 1.1 jdolecek int
637 1.57 matt cd9660_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
638 1.1 jdolecek {
639 1.1 jdolecek
640 1.1 jdolecek /*
641 1.1 jdolecek * XXXX
642 1.1 jdolecek * It would be nice if we didn't always set the `relocated' flag
643 1.1 jdolecek * and force the extra read, but I don't want to think about fixing
644 1.1 jdolecek * that right now.
645 1.1 jdolecek */
646 1.1 jdolecek return (cd9660_vget_internal(mp, ino, vpp,
647 1.1 jdolecek #if 0
648 1.1 jdolecek VFSTOISOFS(mp)->iso_ftype == ISO_FTYPE_RRIP,
649 1.1 jdolecek #else
650 1.1 jdolecek 0,
651 1.1 jdolecek #endif
652 1.7 thorpej NULL));
653 1.1 jdolecek }
654 1.1 jdolecek
655 1.1 jdolecek int
656 1.57 matt cd9660_vget_internal(struct mount *mp, ino_t ino, struct vnode **vpp,
657 1.57 matt int relocated, struct iso_directory_record *isodir)
658 1.1 jdolecek {
659 1.1 jdolecek struct iso_mnt *imp;
660 1.1 jdolecek struct iso_node *ip;
661 1.1 jdolecek struct buf *bp;
662 1.54 ad struct vnode *vp;
663 1.1 jdolecek dev_t dev;
664 1.1 jdolecek int error;
665 1.1 jdolecek
666 1.1 jdolecek imp = VFSTOISOFS(mp);
667 1.1 jdolecek dev = imp->im_dev;
668 1.51 ad
669 1.51 ad retry:
670 1.51 ad if ((*vpp = cd9660_ihashget(dev, ino, LK_EXCLUSIVE)) != NULLVP)
671 1.1 jdolecek return (0);
672 1.1 jdolecek
673 1.1 jdolecek /* Allocate a new vnode/iso_node. */
674 1.1 jdolecek if ((error = getnewvnode(VT_ISOFS, mp, cd9660_vnodeop_p, &vp)) != 0) {
675 1.1 jdolecek *vpp = NULLVP;
676 1.1 jdolecek return (error);
677 1.1 jdolecek }
678 1.1 jdolecek ip = pool_get(&cd9660_node_pool, PR_WAITOK);
679 1.51 ad
680 1.51 ad /*
681 1.51 ad * If someone beat us to it, put back the freshly allocated
682 1.51 ad * vnode/inode pair and retry.
683 1.51 ad */
684 1.51 ad mutex_enter(&cd9660_hashlock);
685 1.51 ad if (cd9660_ihashget(dev, ino, 0) != NULL) {
686 1.51 ad mutex_exit(&cd9660_hashlock);
687 1.51 ad ungetnewvnode(vp);
688 1.51 ad pool_put(&cd9660_node_pool, ip);
689 1.51 ad goto retry;
690 1.51 ad }
691 1.51 ad
692 1.3 dsl memset(ip, 0, sizeof(struct iso_node));
693 1.1 jdolecek vp->v_data = ip;
694 1.1 jdolecek ip->i_vnode = vp;
695 1.1 jdolecek ip->i_dev = dev;
696 1.1 jdolecek ip->i_number = ino;
697 1.51 ad ip->i_mnt = imp;
698 1.51 ad ip->i_devvp = imp->im_devvp;
699 1.51 ad genfs_node_init(vp, &cd9660_genfsops);
700 1.1 jdolecek
701 1.1 jdolecek /*
702 1.1 jdolecek * Put it onto its hash chain and lock it so that other requests for
703 1.1 jdolecek * this inode will block if they arrive while we are sleeping waiting
704 1.1 jdolecek * for old data structures to be purged or for the contents of the
705 1.1 jdolecek * disk portion of this inode to be read.
706 1.1 jdolecek */
707 1.1 jdolecek cd9660_ihashins(ip);
708 1.51 ad mutex_exit(&cd9660_hashlock);
709 1.1 jdolecek
710 1.1 jdolecek if (isodir == 0) {
711 1.1 jdolecek int lbn, off;
712 1.1 jdolecek
713 1.1 jdolecek lbn = lblkno(imp, ino);
714 1.1 jdolecek if (lbn >= imp->volume_space_size) {
715 1.1 jdolecek vput(vp);
716 1.1 jdolecek printf("fhtovp: lbn exceed volume space %d\n", lbn);
717 1.1 jdolecek return (ESTALE);
718 1.1 jdolecek }
719 1.22 perry
720 1.1 jdolecek off = blkoff(imp, ino);
721 1.1 jdolecek if (off + ISO_DIRECTORY_RECORD_SIZE > imp->logical_block_size) {
722 1.1 jdolecek vput(vp);
723 1.1 jdolecek printf("fhtovp: crosses block boundary %d\n",
724 1.1 jdolecek off + ISO_DIRECTORY_RECORD_SIZE);
725 1.1 jdolecek return (ESTALE);
726 1.1 jdolecek }
727 1.22 perry
728 1.1 jdolecek error = bread(imp->im_devvp,
729 1.1 jdolecek lbn << (imp->im_bshift - DEV_BSHIFT),
730 1.1 jdolecek imp->logical_block_size, NOCRED, &bp);
731 1.1 jdolecek if (error) {
732 1.1 jdolecek vput(vp);
733 1.48 ad brelse(bp, 0);
734 1.1 jdolecek printf("fhtovp: bread error %d\n",error);
735 1.1 jdolecek return (error);
736 1.1 jdolecek }
737 1.40 christos isodir = (struct iso_directory_record *)((char *)bp->b_data + off);
738 1.1 jdolecek
739 1.1 jdolecek if (off + isonum_711(isodir->length) >
740 1.1 jdolecek imp->logical_block_size) {
741 1.1 jdolecek vput(vp);
742 1.1 jdolecek if (bp != 0)
743 1.48 ad brelse(bp, 0);
744 1.1 jdolecek printf("fhtovp: directory crosses block boundary %d[off=%d/len=%d]\n",
745 1.1 jdolecek off +isonum_711(isodir->length), off,
746 1.1 jdolecek isonum_711(isodir->length));
747 1.1 jdolecek return (ESTALE);
748 1.1 jdolecek }
749 1.22 perry
750 1.1 jdolecek #if 0
751 1.1 jdolecek if (isonum_733(isodir->extent) +
752 1.1 jdolecek isonum_711(isodir->ext_attr_length) != ifhp->ifid_start) {
753 1.1 jdolecek if (bp != 0)
754 1.48 ad brelse(bp, 0);
755 1.1 jdolecek printf("fhtovp: file start miss %d vs %d\n",
756 1.1 jdolecek isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length),
757 1.1 jdolecek ifhp->ifid_start);
758 1.1 jdolecek return (ESTALE);
759 1.1 jdolecek }
760 1.1 jdolecek #endif
761 1.1 jdolecek } else
762 1.1 jdolecek bp = 0;
763 1.1 jdolecek
764 1.1 jdolecek VREF(ip->i_devvp);
765 1.1 jdolecek
766 1.1 jdolecek if (relocated) {
767 1.1 jdolecek /*
768 1.1 jdolecek * On relocated directories we must
769 1.1 jdolecek * read the `.' entry out of a dir.
770 1.1 jdolecek */
771 1.1 jdolecek ip->iso_start = ino >> imp->im_bshift;
772 1.1 jdolecek if (bp != 0)
773 1.48 ad brelse(bp, 0);
774 1.29 yamt if ((error = cd9660_blkatoff(vp, (off_t)0, NULL, &bp)) != 0) {
775 1.1 jdolecek vput(vp);
776 1.1 jdolecek return (error);
777 1.1 jdolecek }
778 1.1 jdolecek isodir = (struct iso_directory_record *)bp->b_data;
779 1.1 jdolecek }
780 1.1 jdolecek
781 1.1 jdolecek ip->iso_extent = isonum_733(isodir->extent);
782 1.1 jdolecek ip->i_size = isonum_733(isodir->size);
783 1.1 jdolecek ip->iso_start = isonum_711(isodir->ext_attr_length) + ip->iso_extent;
784 1.22 perry
785 1.1 jdolecek /*
786 1.1 jdolecek * Setup time stamp, attribute
787 1.1 jdolecek */
788 1.1 jdolecek vp->v_type = VNON;
789 1.1 jdolecek switch (imp->iso_ftype) {
790 1.1 jdolecek default: /* ISO_FTYPE_9660 */
791 1.1 jdolecek {
792 1.1 jdolecek struct buf *bp2;
793 1.1 jdolecek int off;
794 1.1 jdolecek if ((imp->im_flags & ISOFSMNT_EXTATT)
795 1.1 jdolecek && (off = isonum_711(isodir->ext_attr_length)))
796 1.29 yamt cd9660_blkatoff(vp, (off_t)-(off << imp->im_bshift),
797 1.29 yamt NULL, &bp2);
798 1.1 jdolecek else
799 1.1 jdolecek bp2 = NULL;
800 1.1 jdolecek cd9660_defattr(isodir, ip, bp2);
801 1.1 jdolecek cd9660_deftstamp(isodir, ip, bp2);
802 1.1 jdolecek if (bp2)
803 1.48 ad brelse(bp2, 0);
804 1.1 jdolecek break;
805 1.1 jdolecek }
806 1.1 jdolecek case ISO_FTYPE_RRIP:
807 1.1 jdolecek cd9660_rrip_analyze(isodir, ip, imp);
808 1.1 jdolecek break;
809 1.1 jdolecek }
810 1.1 jdolecek
811 1.1 jdolecek if (bp != 0)
812 1.48 ad brelse(bp, 0);
813 1.1 jdolecek
814 1.1 jdolecek /*
815 1.1 jdolecek * Initialize the associated vnode
816 1.1 jdolecek */
817 1.1 jdolecek switch (vp->v_type = IFTOVT(ip->inode.iso_mode)) {
818 1.1 jdolecek case VFIFO:
819 1.1 jdolecek vp->v_op = cd9660_fifoop_p;
820 1.1 jdolecek break;
821 1.1 jdolecek case VCHR:
822 1.1 jdolecek case VBLK:
823 1.1 jdolecek /*
824 1.1 jdolecek * if device, look at device number table for translation
825 1.1 jdolecek */
826 1.1 jdolecek vp->v_op = cd9660_specop_p;
827 1.54 ad spec_node_init(vp, ip->inode.iso_rdev);
828 1.1 jdolecek break;
829 1.1 jdolecek case VLNK:
830 1.1 jdolecek case VNON:
831 1.1 jdolecek case VSOCK:
832 1.1 jdolecek case VDIR:
833 1.1 jdolecek case VBAD:
834 1.1 jdolecek break;
835 1.1 jdolecek case VREG:
836 1.1 jdolecek uvm_vnp_setsize(vp, ip->i_size);
837 1.1 jdolecek break;
838 1.1 jdolecek }
839 1.22 perry
840 1.45 pooka if (vp->v_type != VREG)
841 1.45 pooka uvm_vnp_setsize(vp, 0);
842 1.45 pooka
843 1.1 jdolecek if (ip->iso_extent == imp->root_extent)
844 1.49 ad vp->v_vflag |= VV_ROOT;
845 1.1 jdolecek
846 1.1 jdolecek /*
847 1.1 jdolecek * XXX need generation number?
848 1.1 jdolecek */
849 1.22 perry
850 1.1 jdolecek *vpp = vp;
851 1.1 jdolecek return (0);
852 1.1 jdolecek }
853 1.1 jdolecek
854 1.1 jdolecek /*
855 1.1 jdolecek * Vnode pointer to File handle
856 1.1 jdolecek */
857 1.1 jdolecek /* ARGSUSED */
858 1.1 jdolecek int
859 1.57 matt cd9660_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size)
860 1.1 jdolecek {
861 1.1 jdolecek struct iso_node *ip = VTOI(vp);
862 1.33 martin struct ifid ifh;
863 1.22 perry
864 1.33 martin if (*fh_size < sizeof(struct ifid)) {
865 1.33 martin *fh_size = sizeof(struct ifid);
866 1.33 martin return E2BIG;
867 1.33 martin }
868 1.33 martin *fh_size = sizeof(struct ifid);
869 1.33 martin
870 1.33 martin memset(&ifh, 0, sizeof(ifh));
871 1.33 martin ifh.ifid_len = sizeof(struct ifid);
872 1.33 martin ifh.ifid_ino = ip->i_number;
873 1.33 martin ifh.ifid_start = ip->iso_start;
874 1.33 martin memcpy(fhp, &ifh, sizeof(ifh));
875 1.22 perry
876 1.1 jdolecek #ifdef ISOFS_DBG
877 1.1 jdolecek printf("vptofh: ino %d, start %ld\n",
878 1.33 martin ifh.ifid_ino,ifh.ifid_start);
879 1.1 jdolecek #endif
880 1.1 jdolecek return 0;
881 1.1 jdolecek }
882 1.1 jdolecek
883 1.10 atatat SYSCTL_SETUP(sysctl_vfs_cd9660_setup, "sysctl vfs.cd9660 subtree setup")
884 1.1 jdolecek {
885 1.10 atatat
886 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
887 1.11 atatat CTLFLAG_PERMANENT, CTLTYPE_NODE, "vfs", NULL,
888 1.10 atatat NULL, 0, NULL, 0,
889 1.10 atatat CTL_VFS, CTL_EOL);
890 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
891 1.14 atatat CTLFLAG_PERMANENT, CTLTYPE_NODE, "cd9660",
892 1.14 atatat SYSCTL_DESCR("ISO-9660 file system"),
893 1.10 atatat NULL, 0, NULL, 0,
894 1.10 atatat CTL_VFS, 14, CTL_EOL);
895 1.19 jdolecek
896 1.19 jdolecek sysctl_createv(clog, 0, NULL, NULL,
897 1.19 jdolecek CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
898 1.22 perry CTLTYPE_INT, "utf8_joliet",
899 1.19 jdolecek SYSCTL_DESCR("Encode Joliet file names to UTF-8"),
900 1.19 jdolecek NULL, 0, &cd9660_utf8_joliet, 0,
901 1.19 jdolecek CTL_VFS, 14, CD9660_UTF8_JOLIET, CTL_EOL);
902 1.19 jdolecek
903 1.1 jdolecek }
904