cd9660_vfsops.c revision 1.86 1 1.86 hannken /* $NetBSD: cd9660_vfsops.c,v 1.86 2014/06/14 07:39:28 hannken 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.86 hannken __KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.86 2014/06/14 07:39:28 hannken 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.60 ad #include <sys/module.h>
70 1.1 jdolecek
71 1.1 jdolecek #include <fs/cd9660/iso.h>
72 1.1 jdolecek #include <fs/cd9660/cd9660_extern.h>
73 1.1 jdolecek #include <fs/cd9660/iso_rrip.h>
74 1.1 jdolecek #include <fs/cd9660/cd9660_node.h>
75 1.1 jdolecek #include <fs/cd9660/cd9660_mount.h>
76 1.2 thorpej
77 1.60 ad MODULE(MODULE_CLASS_VFS, cd9660, NULL);
78 1.60 ad
79 1.41 pooka MALLOC_JUSTDEFINE(M_ISOFSMNT, "ISOFS mount", "ISOFS mount structure");
80 1.1 jdolecek
81 1.63 rumble static struct sysctllog *cd9660_sysctl_log;
82 1.63 rumble
83 1.1 jdolecek extern const struct vnodeopv_desc cd9660_vnodeop_opv_desc;
84 1.1 jdolecek extern const struct vnodeopv_desc cd9660_specop_opv_desc;
85 1.1 jdolecek extern const struct vnodeopv_desc cd9660_fifoop_opv_desc;
86 1.1 jdolecek
87 1.1 jdolecek const struct vnodeopv_desc * const cd9660_vnodeopv_descs[] = {
88 1.1 jdolecek &cd9660_vnodeop_opv_desc,
89 1.1 jdolecek &cd9660_specop_opv_desc,
90 1.1 jdolecek &cd9660_fifoop_opv_desc,
91 1.1 jdolecek NULL,
92 1.1 jdolecek };
93 1.1 jdolecek
94 1.1 jdolecek struct vfsops cd9660_vfsops = {
95 1.82 hannken .vfs_name = MOUNT_CD9660,
96 1.82 hannken .vfs_min_mount_data = sizeof (struct iso_args),
97 1.82 hannken .vfs_mount = cd9660_mount,
98 1.82 hannken .vfs_start = cd9660_start,
99 1.82 hannken .vfs_unmount = cd9660_unmount,
100 1.82 hannken .vfs_root = cd9660_root,
101 1.82 hannken .vfs_quotactl = (void *)eopnotsupp,
102 1.82 hannken .vfs_statvfs = cd9660_statvfs,
103 1.82 hannken .vfs_sync = cd9660_sync,
104 1.82 hannken .vfs_vget = cd9660_vget,
105 1.82 hannken .vfs_fhtovp = cd9660_fhtovp,
106 1.82 hannken .vfs_vptofh = cd9660_vptofh,
107 1.82 hannken .vfs_init = cd9660_init,
108 1.82 hannken .vfs_reinit = cd9660_reinit,
109 1.82 hannken .vfs_done = cd9660_done,
110 1.82 hannken .vfs_mountroot = cd9660_mountroot,
111 1.82 hannken .vfs_snapshot = (void *)eopnotsupp,
112 1.82 hannken .vfs_extattrctl = vfs_stdextattrctl,
113 1.82 hannken .vfs_suspendctl = (void *)eopnotsupp,
114 1.82 hannken .vfs_renamelock_enter = genfs_renamelock_enter,
115 1.82 hannken .vfs_renamelock_exit = genfs_renamelock_exit,
116 1.82 hannken .vfs_fsync = (void *)eopnotsupp,
117 1.82 hannken .vfs_opv_descs = cd9660_vnodeopv_descs
118 1.1 jdolecek };
119 1.1 jdolecek
120 1.24 yamt static const struct genfs_ops cd9660_genfsops = {
121 1.24 yamt .gop_size = genfs_size,
122 1.1 jdolecek };
123 1.1 jdolecek
124 1.1 jdolecek /*
125 1.1 jdolecek * Called by vfs_mountroot when iso is going to be mounted as root.
126 1.1 jdolecek *
127 1.1 jdolecek * Name is updated by mount(8) after booting.
128 1.1 jdolecek */
129 1.1 jdolecek #define ROOTNAME "root_device"
130 1.1 jdolecek
131 1.26 xtraeme static int iso_makemp(struct iso_mnt *isomp, struct buf *bp, int *ea_len);
132 1.26 xtraeme static int iso_mountfs(struct vnode *devvp, struct mount *mp,
133 1.30 christos struct lwp *l, struct iso_args *argp);
134 1.1 jdolecek
135 1.60 ad static int
136 1.60 ad cd9660_modcmd(modcmd_t cmd, void *arg)
137 1.60 ad {
138 1.63 rumble int error;
139 1.60 ad
140 1.60 ad switch (cmd) {
141 1.60 ad case MODULE_CMD_INIT:
142 1.63 rumble error = vfs_attach(&cd9660_vfsops);
143 1.63 rumble if (error != 0)
144 1.63 rumble break;
145 1.63 rumble sysctl_createv(&cd9660_sysctl_log, 0, NULL, NULL,
146 1.63 rumble CTLFLAG_PERMANENT, CTLTYPE_NODE, "cd9660",
147 1.63 rumble SYSCTL_DESCR("ISO-9660 file system"),
148 1.63 rumble NULL, 0, NULL, 0,
149 1.63 rumble CTL_VFS, 14, CTL_EOL);
150 1.63 rumble sysctl_createv(&cd9660_sysctl_log, 0, NULL, NULL,
151 1.63 rumble CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
152 1.63 rumble CTLTYPE_INT, "utf8_joliet",
153 1.63 rumble SYSCTL_DESCR("Encode Joliet filenames to UTF-8"),
154 1.63 rumble NULL, 0, &cd9660_utf8_joliet, 0,
155 1.63 rumble CTL_VFS, 14, CD9660_UTF8_JOLIET, CTL_EOL);
156 1.63 rumble /*
157 1.63 rumble * XXX the "14" above could be dynamic, thereby eliminating
158 1.63 rumble * one more instance of the "number to vfs" mapping problem,
159 1.63 rumble * but "14" is the order as taken from sys/mount.h
160 1.63 rumble */
161 1.63 rumble break;
162 1.60 ad case MODULE_CMD_FINI:
163 1.63 rumble error = vfs_detach(&cd9660_vfsops);
164 1.63 rumble if (error != 0)
165 1.63 rumble break;
166 1.63 rumble sysctl_teardown(&cd9660_sysctl_log);
167 1.63 rumble break;
168 1.60 ad default:
169 1.63 rumble error = ENOTTY;
170 1.63 rumble break;
171 1.60 ad }
172 1.63 rumble
173 1.63 rumble return (error);
174 1.60 ad }
175 1.60 ad
176 1.1 jdolecek int
177 1.57 matt cd9660_mountroot(void)
178 1.1 jdolecek {
179 1.1 jdolecek struct mount *mp;
180 1.50 pooka struct lwp *l = curlwp;
181 1.1 jdolecek int error;
182 1.1 jdolecek struct iso_args args;
183 1.1 jdolecek
184 1.31 thorpej if (device_class(root_device) != DV_DISK)
185 1.1 jdolecek return (ENODEV);
186 1.22 perry
187 1.1 jdolecek if ((error = vfs_rootmountalloc(MOUNT_CD9660, "root_device", &mp))
188 1.1 jdolecek != 0) {
189 1.1 jdolecek vrele(rootvp);
190 1.1 jdolecek return (error);
191 1.1 jdolecek }
192 1.1 jdolecek
193 1.1 jdolecek args.flags = ISOFSMNT_ROOT;
194 1.30 christos if ((error = iso_mountfs(rootvp, mp, l, &args)) != 0) {
195 1.59 ad vfs_unbusy(mp, false, NULL);
196 1.61 ad vfs_destroy(mp);
197 1.1 jdolecek return (error);
198 1.1 jdolecek }
199 1.80 christos mountlist_append(mp);
200 1.50 pooka (void)cd9660_statvfs(mp, &mp->mnt_stat);
201 1.59 ad vfs_unbusy(mp, false, NULL);
202 1.1 jdolecek return (0);
203 1.1 jdolecek }
204 1.1 jdolecek
205 1.1 jdolecek /*
206 1.1 jdolecek * VFS Operations.
207 1.1 jdolecek *
208 1.1 jdolecek * mount system call
209 1.1 jdolecek */
210 1.1 jdolecek int
211 1.57 matt cd9660_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
212 1.1 jdolecek {
213 1.50 pooka struct lwp *l = curlwp;
214 1.1 jdolecek struct vnode *devvp;
215 1.43 dsl struct iso_args *args = data;
216 1.1 jdolecek int error;
217 1.28 dyoung struct iso_mnt *imp = VFSTOISOFS(mp);
218 1.22 perry
219 1.84 maxv if (args == NULL)
220 1.84 maxv return EINVAL;
221 1.43 dsl if (*data_len < sizeof *args)
222 1.43 dsl return EINVAL;
223 1.43 dsl
224 1.1 jdolecek if (mp->mnt_flag & MNT_GETARGS) {
225 1.1 jdolecek if (imp == NULL)
226 1.1 jdolecek return EIO;
227 1.43 dsl args->fspec = NULL;
228 1.43 dsl args->flags = imp->im_flags;
229 1.43 dsl *data_len = sizeof (*args);
230 1.43 dsl return 0;
231 1.1 jdolecek }
232 1.22 perry
233 1.1 jdolecek if ((mp->mnt_flag & MNT_RDONLY) == 0)
234 1.1 jdolecek return (EROFS);
235 1.22 perry
236 1.43 dsl if ((mp->mnt_flag & MNT_UPDATE) && args->fspec == NULL)
237 1.27 jmmv return EINVAL;
238 1.27 jmmv
239 1.1 jdolecek /*
240 1.1 jdolecek * Not an update, or updating the name: look up the name
241 1.1 jdolecek * and verify that it refers to a sensible block device.
242 1.1 jdolecek */
243 1.67 dholland error = namei_simple_user(args->fspec,
244 1.67 dholland NSM_FOLLOW_NOEMULROOT, &devvp);
245 1.67 dholland if (error != 0)
246 1.1 jdolecek return (error);
247 1.1 jdolecek
248 1.1 jdolecek if (devvp->v_type != VBLK) {
249 1.1 jdolecek vrele(devvp);
250 1.1 jdolecek return ENOTBLK;
251 1.1 jdolecek }
252 1.1 jdolecek if (bdevsw_lookup(devvp->v_rdev) == NULL) {
253 1.1 jdolecek vrele(devvp);
254 1.1 jdolecek return ENXIO;
255 1.1 jdolecek }
256 1.1 jdolecek /*
257 1.1 jdolecek * If mount by non-root, then verify that user has necessary
258 1.1 jdolecek * permissions on the device.
259 1.1 jdolecek */
260 1.66 elad vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
261 1.75 elad error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_MOUNT,
262 1.75 elad KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp, KAUTH_ARG(VREAD));
263 1.66 elad if (error) {
264 1.83 dholland goto fail;
265 1.1 jdolecek }
266 1.21 mycroft if ((mp->mnt_flag & MNT_UPDATE) == 0) {
267 1.50 pooka error = VOP_OPEN(devvp, FREAD, FSCRED);
268 1.21 mycroft if (error)
269 1.21 mycroft goto fail;
270 1.83 dholland VOP_UNLOCK(devvp);
271 1.43 dsl error = iso_mountfs(devvp, mp, l, args);
272 1.83 dholland vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
273 1.21 mycroft if (error) {
274 1.50 pooka (void)VOP_CLOSE(devvp, FREAD, NOCRED);
275 1.21 mycroft goto fail;
276 1.21 mycroft }
277 1.83 dholland VOP_UNLOCK(devvp);
278 1.83 dholland /* reference to devvp is donated through iso_mountfs */
279 1.21 mycroft } else {
280 1.83 dholland if (devvp != imp->im_devvp &&
281 1.83 dholland devvp->v_rdev != imp->im_devvp->v_rdev) {
282 1.83 dholland error = EINVAL; /* needs translation */
283 1.83 dholland goto fail;
284 1.83 dholland }
285 1.83 dholland VOP_UNLOCK(devvp);
286 1.21 mycroft vrele(devvp);
287 1.1 jdolecek }
288 1.43 dsl return set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE,
289 1.44 pooka mp->mnt_op->vfs_name, mp, l);
290 1.21 mycroft
291 1.21 mycroft fail:
292 1.83 dholland VOP_UNLOCK(devvp);
293 1.21 mycroft vrele(devvp);
294 1.21 mycroft return (error);
295 1.1 jdolecek }
296 1.1 jdolecek
297 1.1 jdolecek /*
298 1.1 jdolecek * Make a mount point from a volume descriptor
299 1.1 jdolecek */
300 1.1 jdolecek static int
301 1.57 matt iso_makemp(struct iso_mnt *isomp, struct buf *bp, int *ea_len)
302 1.1 jdolecek {
303 1.1 jdolecek struct iso_primary_descriptor *pri;
304 1.1 jdolecek int logical_block_size;
305 1.1 jdolecek struct iso_directory_record *rootp;
306 1.1 jdolecek
307 1.1 jdolecek pri = (struct iso_primary_descriptor *)bp->b_data;
308 1.22 perry
309 1.1 jdolecek logical_block_size = isonum_723 (pri->logical_block_size);
310 1.22 perry
311 1.1 jdolecek if (logical_block_size < DEV_BSIZE || logical_block_size > MAXBSIZE
312 1.1 jdolecek || (logical_block_size & (logical_block_size - 1)) != 0)
313 1.1 jdolecek return -1;
314 1.22 perry
315 1.1 jdolecek rootp = (struct iso_directory_record *)pri->root_directory_record;
316 1.22 perry
317 1.1 jdolecek isomp->logical_block_size = logical_block_size;
318 1.1 jdolecek isomp->volume_space_size = isonum_733 (pri->volume_space_size);
319 1.1 jdolecek memcpy(isomp->root, rootp, sizeof(isomp->root));
320 1.1 jdolecek isomp->root_extent = isonum_733 (rootp->extent);
321 1.1 jdolecek isomp->root_size = isonum_733 (rootp->size);
322 1.1 jdolecek isomp->im_joliet_level = 0;
323 1.22 perry
324 1.1 jdolecek isomp->im_bmask = logical_block_size - 1;
325 1.1 jdolecek isomp->im_bshift = 0;
326 1.1 jdolecek while ((1 << isomp->im_bshift) < isomp->logical_block_size)
327 1.1 jdolecek isomp->im_bshift++;
328 1.1 jdolecek
329 1.1 jdolecek if (ea_len != NULL)
330 1.1 jdolecek *ea_len = isonum_711(rootp->ext_attr_length);
331 1.1 jdolecek
332 1.1 jdolecek return 0;
333 1.1 jdolecek }
334 1.1 jdolecek
335 1.1 jdolecek /*
336 1.1 jdolecek * Common code for mount and mountroot
337 1.1 jdolecek */
338 1.1 jdolecek static int
339 1.57 matt iso_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l,
340 1.57 matt struct iso_args *argp)
341 1.1 jdolecek {
342 1.1 jdolecek struct iso_mnt *isomp = (struct iso_mnt *)0;
343 1.1 jdolecek struct buf *bp = NULL, *pribp = NULL, *supbp = NULL;
344 1.1 jdolecek dev_t dev = devvp->v_rdev;
345 1.1 jdolecek int error = EINVAL;
346 1.1 jdolecek int ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
347 1.1 jdolecek int iso_bsize;
348 1.1 jdolecek int iso_blknum;
349 1.1 jdolecek int joliet_level;
350 1.1 jdolecek struct iso_volume_descriptor *vdp;
351 1.1 jdolecek struct iso_supplementary_descriptor *sup;
352 1.1 jdolecek int sess = 0;
353 1.1 jdolecek int ext_attr_length;
354 1.1 jdolecek struct disklabel label;
355 1.1 jdolecek
356 1.1 jdolecek if (!ronly)
357 1.1 jdolecek return EROFS;
358 1.22 perry
359 1.21 mycroft /* Flush out any old buffers remaining from a previous use. */
360 1.34 ad if ((error = vinvalbuf(devvp, V_SAVE, l->l_cred, l, 0, 0)) != 0)
361 1.1 jdolecek return (error);
362 1.22 perry
363 1.1 jdolecek /* This is the "logical sector size". The standard says this
364 1.1 jdolecek * should be 2048 or the physical sector size on the device,
365 1.1 jdolecek * whichever is greater. For now, we'll just use a constant.
366 1.1 jdolecek */
367 1.1 jdolecek iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
368 1.1 jdolecek
369 1.50 pooka error = VOP_IOCTL(devvp, DIOCGDINFO, &label, FREAD, FSCRED);
370 1.70 mlelstv if (!error) {
371 1.1 jdolecek /* XXX more sanity checks? */
372 1.1 jdolecek sess = label.d_partitions[DISKPART(dev)].p_cdsession;
373 1.1 jdolecek } else {
374 1.1 jdolecek /* fallback to old method */
375 1.50 pooka error = VOP_IOCTL(devvp, CDIOREADMSADDR, &sess, 0, FSCRED);
376 1.1 jdolecek if (error)
377 1.1 jdolecek sess = 0; /* never mind */
378 1.1 jdolecek }
379 1.4 christos #ifdef ISO_DEBUG
380 1.65 cegger printf("isofs: session offset (part %"PRId32") %d\n", DISKPART(dev), sess);
381 1.1 jdolecek #endif
382 1.1 jdolecek
383 1.1 jdolecek for (iso_blknum = 16; iso_blknum < 100; iso_blknum++) {
384 1.1 jdolecek if ((error = bread(devvp, (iso_blknum+sess) * btodb(iso_bsize),
385 1.62 hannken iso_bsize, NOCRED, 0, &bp)) != 0)
386 1.1 jdolecek goto out;
387 1.22 perry
388 1.1 jdolecek vdp = (struct iso_volume_descriptor *)bp->b_data;
389 1.1 jdolecek if (memcmp(vdp->id, ISO_STANDARD_ID, sizeof(vdp->id)) != 0) {
390 1.1 jdolecek error = EINVAL;
391 1.1 jdolecek goto out;
392 1.1 jdolecek }
393 1.1 jdolecek
394 1.1 jdolecek switch (isonum_711(vdp->type)) {
395 1.1 jdolecek case ISO_VD_PRIMARY:
396 1.1 jdolecek if (pribp == NULL) {
397 1.1 jdolecek pribp = bp;
398 1.1 jdolecek bp = NULL;
399 1.1 jdolecek }
400 1.1 jdolecek break;
401 1.1 jdolecek
402 1.1 jdolecek case ISO_VD_SUPPLEMENTARY:
403 1.1 jdolecek if (supbp == NULL) {
404 1.1 jdolecek supbp = bp;
405 1.1 jdolecek bp = NULL;
406 1.1 jdolecek }
407 1.1 jdolecek break;
408 1.1 jdolecek
409 1.1 jdolecek default:
410 1.1 jdolecek break;
411 1.1 jdolecek }
412 1.1 jdolecek
413 1.1 jdolecek if (isonum_711 (vdp->type) == ISO_VD_END) {
414 1.48 ad brelse(bp, 0);
415 1.1 jdolecek bp = NULL;
416 1.1 jdolecek break;
417 1.1 jdolecek }
418 1.1 jdolecek
419 1.1 jdolecek if (bp != NULL) {
420 1.48 ad brelse(bp, 0);
421 1.1 jdolecek bp = NULL;
422 1.1 jdolecek }
423 1.1 jdolecek }
424 1.1 jdolecek
425 1.1 jdolecek if (pribp == NULL) {
426 1.1 jdolecek error = EINVAL;
427 1.1 jdolecek goto out;
428 1.1 jdolecek }
429 1.1 jdolecek
430 1.1 jdolecek isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK);
431 1.3 dsl memset(isomp, 0, sizeof *isomp);
432 1.1 jdolecek if (iso_makemp(isomp, pribp, &ext_attr_length) == -1) {
433 1.1 jdolecek error = EINVAL;
434 1.1 jdolecek goto out;
435 1.1 jdolecek }
436 1.1 jdolecek
437 1.1 jdolecek isomp->volume_space_size += sess;
438 1.1 jdolecek
439 1.48 ad brelse(pribp, BC_AGE);
440 1.1 jdolecek pribp = NULL;
441 1.22 perry
442 1.1 jdolecek mp->mnt_data = isomp;
443 1.12 christos mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)dev;
444 1.12 christos mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_CD9660);
445 1.12 christos mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
446 1.73 christos mp->mnt_stat.f_namemax = ISO_MAXNAMLEN;
447 1.1 jdolecek mp->mnt_flag |= MNT_LOCAL;
448 1.53 ad mp->mnt_iflag |= IMNT_MPSAFE;
449 1.1 jdolecek mp->mnt_dev_bshift = iso_bsize;
450 1.1 jdolecek mp->mnt_fs_bshift = isomp->im_bshift;
451 1.1 jdolecek isomp->im_mountp = mp;
452 1.1 jdolecek isomp->im_dev = dev;
453 1.1 jdolecek isomp->im_devvp = devvp;
454 1.22 perry
455 1.1 jdolecek /* Check the Rock Ridge Extension support */
456 1.1 jdolecek if (!(argp->flags & ISOFSMNT_NORRIP)) {
457 1.1 jdolecek struct iso_directory_record *rootp;
458 1.1 jdolecek
459 1.1 jdolecek if ((error = bread(isomp->im_devvp,
460 1.1 jdolecek (isomp->root_extent + ext_attr_length) <<
461 1.1 jdolecek (isomp->im_bshift - DEV_BSHIFT),
462 1.1 jdolecek isomp->logical_block_size, NOCRED,
463 1.62 hannken 0, &bp)) != 0)
464 1.1 jdolecek goto out;
465 1.22 perry
466 1.1 jdolecek rootp = (struct iso_directory_record *)bp->b_data;
467 1.22 perry
468 1.1 jdolecek if ((isomp->rr_skip = cd9660_rrip_offset(rootp,isomp)) < 0) {
469 1.1 jdolecek argp->flags |= ISOFSMNT_NORRIP;
470 1.1 jdolecek } else {
471 1.1 jdolecek argp->flags &= ~ISOFSMNT_GENS;
472 1.1 jdolecek }
473 1.22 perry
474 1.1 jdolecek /*
475 1.1 jdolecek * The contents are valid,
476 1.1 jdolecek * but they will get reread as part of another vnode, so...
477 1.1 jdolecek */
478 1.48 ad brelse(bp, BC_AGE);
479 1.1 jdolecek bp = NULL;
480 1.1 jdolecek }
481 1.1 jdolecek isomp->im_flags = argp->flags & (ISOFSMNT_NORRIP | ISOFSMNT_GENS |
482 1.1 jdolecek ISOFSMNT_EXTATT | ISOFSMNT_NOJOLIET | ISOFSMNT_RRCASEINS);
483 1.1 jdolecek
484 1.1 jdolecek if (isomp->im_flags & ISOFSMNT_GENS)
485 1.1 jdolecek isomp->iso_ftype = ISO_FTYPE_9660;
486 1.1 jdolecek else if (isomp->im_flags & ISOFSMNT_NORRIP) {
487 1.1 jdolecek isomp->iso_ftype = ISO_FTYPE_DEFAULT;
488 1.1 jdolecek if (argp->flags & ISOFSMNT_NOCASETRANS)
489 1.1 jdolecek isomp->im_flags |= ISOFSMNT_NOCASETRANS;
490 1.22 perry } else
491 1.1 jdolecek isomp->iso_ftype = ISO_FTYPE_RRIP;
492 1.1 jdolecek
493 1.1 jdolecek /* Check the Joliet Extension support */
494 1.1 jdolecek if ((argp->flags & ISOFSMNT_NORRIP) != 0 &&
495 1.1 jdolecek (argp->flags & ISOFSMNT_NOJOLIET) == 0 &&
496 1.1 jdolecek supbp != NULL) {
497 1.1 jdolecek joliet_level = 0;
498 1.1 jdolecek sup = (struct iso_supplementary_descriptor *)supbp->b_data;
499 1.1 jdolecek
500 1.1 jdolecek if ((isonum_711(sup->flags) & 1) == 0) {
501 1.1 jdolecek if (memcmp(sup->escape, "%/@", 3) == 0)
502 1.1 jdolecek joliet_level = 1;
503 1.1 jdolecek if (memcmp(sup->escape, "%/C", 3) == 0)
504 1.1 jdolecek joliet_level = 2;
505 1.1 jdolecek if (memcmp(sup->escape, "%/E", 3) == 0)
506 1.1 jdolecek joliet_level = 3;
507 1.1 jdolecek }
508 1.1 jdolecek if (joliet_level != 0) {
509 1.1 jdolecek if (iso_makemp(isomp, supbp, NULL) == -1) {
510 1.1 jdolecek error = EINVAL;
511 1.1 jdolecek goto out;
512 1.1 jdolecek }
513 1.1 jdolecek isomp->im_joliet_level = joliet_level;
514 1.1 jdolecek }
515 1.1 jdolecek }
516 1.1 jdolecek
517 1.1 jdolecek if (supbp != NULL) {
518 1.48 ad brelse(supbp, 0);
519 1.1 jdolecek supbp = NULL;
520 1.1 jdolecek }
521 1.22 perry
522 1.79 hannken spec_node_setmountedfs(devvp, mp);
523 1.37 drochner
524 1.1 jdolecek return 0;
525 1.1 jdolecek out:
526 1.1 jdolecek if (bp)
527 1.48 ad brelse(bp, 0);
528 1.1 jdolecek if (pribp)
529 1.48 ad brelse(pribp, 0);
530 1.1 jdolecek if (supbp)
531 1.48 ad brelse(supbp, 0);
532 1.1 jdolecek if (isomp) {
533 1.3 dsl free(isomp, M_ISOFSMNT);
534 1.1 jdolecek mp->mnt_data = NULL;
535 1.1 jdolecek }
536 1.1 jdolecek return error;
537 1.1 jdolecek }
538 1.1 jdolecek
539 1.1 jdolecek /*
540 1.1 jdolecek * Make a filesystem operational.
541 1.1 jdolecek * Nothing to do at the moment.
542 1.1 jdolecek */
543 1.1 jdolecek /* ARGSUSED */
544 1.1 jdolecek int
545 1.50 pooka cd9660_start(struct mount *mp, int flags)
546 1.1 jdolecek {
547 1.1 jdolecek return 0;
548 1.1 jdolecek }
549 1.1 jdolecek
550 1.1 jdolecek /*
551 1.1 jdolecek * unmount system call
552 1.1 jdolecek */
553 1.1 jdolecek int
554 1.57 matt cd9660_unmount(struct mount *mp, int mntflags)
555 1.1 jdolecek {
556 1.1 jdolecek struct iso_mnt *isomp;
557 1.1 jdolecek int error, flags = 0;
558 1.22 perry
559 1.1 jdolecek if (mntflags & MNT_FORCE)
560 1.1 jdolecek flags |= FORCECLOSE;
561 1.1 jdolecek if ((error = vflush(mp, NULLVP, flags)) != 0)
562 1.1 jdolecek return (error);
563 1.1 jdolecek
564 1.1 jdolecek isomp = VFSTOISOFS(mp);
565 1.1 jdolecek
566 1.1 jdolecek if (isomp->im_devvp->v_type != VBAD)
567 1.79 hannken spec_node_setmountedfs(isomp->im_devvp, NULL);
568 1.1 jdolecek
569 1.1 jdolecek vn_lock(isomp->im_devvp, LK_EXCLUSIVE | LK_RETRY);
570 1.50 pooka error = VOP_CLOSE(isomp->im_devvp, FREAD, NOCRED);
571 1.1 jdolecek vput(isomp->im_devvp);
572 1.3 dsl free(isomp, M_ISOFSMNT);
573 1.1 jdolecek mp->mnt_data = NULL;
574 1.1 jdolecek mp->mnt_flag &= ~MNT_LOCAL;
575 1.1 jdolecek return (error);
576 1.1 jdolecek }
577 1.1 jdolecek
578 1.1 jdolecek /*
579 1.1 jdolecek * Return root of a filesystem
580 1.1 jdolecek */
581 1.1 jdolecek int
582 1.57 matt cd9660_root(struct mount *mp, struct vnode **vpp)
583 1.1 jdolecek {
584 1.1 jdolecek struct iso_mnt *imp = VFSTOISOFS(mp);
585 1.1 jdolecek struct iso_directory_record *dp =
586 1.1 jdolecek (struct iso_directory_record *)imp->root;
587 1.1 jdolecek ino_t ino = isodirino(dp, imp);
588 1.22 perry
589 1.86 hannken return cd9660_vget(mp, ino, vpp);
590 1.1 jdolecek }
591 1.1 jdolecek
592 1.1 jdolecek /*
593 1.1 jdolecek * Get file system statistics.
594 1.1 jdolecek */
595 1.1 jdolecek int
596 1.57 matt cd9660_statvfs(struct mount *mp, struct statvfs *sbp)
597 1.1 jdolecek {
598 1.1 jdolecek struct iso_mnt *isomp;
599 1.22 perry
600 1.1 jdolecek isomp = VFSTOISOFS(mp);
601 1.1 jdolecek
602 1.1 jdolecek sbp->f_bsize = isomp->logical_block_size;
603 1.12 christos sbp->f_frsize = sbp->f_bsize;
604 1.1 jdolecek sbp->f_iosize = sbp->f_bsize; /* XXX */
605 1.1 jdolecek sbp->f_blocks = isomp->volume_space_size;
606 1.1 jdolecek sbp->f_bfree = 0; /* total free blocks */
607 1.1 jdolecek sbp->f_bavail = 0; /* blocks free for non superuser */
608 1.12 christos sbp->f_bresvd = 0; /* total reserved blocks */
609 1.1 jdolecek sbp->f_files = 0; /* total files */
610 1.1 jdolecek sbp->f_ffree = 0; /* free file nodes */
611 1.25 jmmv sbp->f_favail = 0; /* free file nodes for non superuser */
612 1.12 christos sbp->f_fresvd = 0; /* reserved file nodes */
613 1.12 christos copy_statvfs_info(sbp, mp);
614 1.1 jdolecek /* Use the first spare for flags: */
615 1.1 jdolecek sbp->f_spare[0] = isomp->im_flags;
616 1.1 jdolecek return 0;
617 1.1 jdolecek }
618 1.1 jdolecek
619 1.1 jdolecek /* ARGSUSED */
620 1.1 jdolecek int
621 1.57 matt cd9660_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
622 1.1 jdolecek {
623 1.57 matt return 0;
624 1.1 jdolecek }
625 1.1 jdolecek
626 1.1 jdolecek /*
627 1.1 jdolecek * File handle to vnode
628 1.1 jdolecek *
629 1.1 jdolecek * Have to be really careful about stale file handles:
630 1.1 jdolecek * - check that the inode number is in range
631 1.1 jdolecek * - call iget() to get the locked inode
632 1.1 jdolecek * - check for an unallocated inode (i_mode == 0)
633 1.1 jdolecek * - check that the generation number matches
634 1.1 jdolecek */
635 1.1 jdolecek
636 1.1 jdolecek struct ifid {
637 1.1 jdolecek ushort ifid_len;
638 1.1 jdolecek ushort ifid_pad;
639 1.85 martin ino_t ifid_ino;
640 1.85 martin #ifdef ISOFS_DBG
641 1.85 martin u_long ifid_start;
642 1.85 martin #endif
643 1.1 jdolecek };
644 1.1 jdolecek
645 1.1 jdolecek /* ARGSUSED */
646 1.1 jdolecek int
647 1.57 matt cd9660_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
648 1.1 jdolecek {
649 1.33 martin struct ifid ifh;
650 1.1 jdolecek struct iso_node *ip;
651 1.1 jdolecek struct vnode *nvp;
652 1.1 jdolecek int error;
653 1.22 perry
654 1.33 martin if (fhp->fid_len != sizeof(ifh))
655 1.33 martin return EINVAL;
656 1.33 martin
657 1.33 martin memcpy(&ifh, fhp, sizeof(ifh));
658 1.1 jdolecek #ifdef ISOFS_DBG
659 1.85 martin printf("fhtovp: ino %"PRIu64", start %lu\n",
660 1.33 martin ifh.ifid_ino, ifh.ifid_start);
661 1.1 jdolecek #endif
662 1.22 perry
663 1.33 martin if ((error = VFS_VGET(mp, ifh.ifid_ino, &nvp)) != 0) {
664 1.1 jdolecek *vpp = NULLVP;
665 1.1 jdolecek return (error);
666 1.1 jdolecek }
667 1.1 jdolecek ip = VTOI(nvp);
668 1.1 jdolecek if (ip->inode.iso_mode == 0) {
669 1.1 jdolecek vput(nvp);
670 1.1 jdolecek *vpp = NULLVP;
671 1.1 jdolecek return (ESTALE);
672 1.1 jdolecek }
673 1.1 jdolecek *vpp = nvp;
674 1.1 jdolecek return (0);
675 1.1 jdolecek }
676 1.1 jdolecek
677 1.1 jdolecek int
678 1.57 matt cd9660_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
679 1.1 jdolecek {
680 1.1 jdolecek
681 1.86 hannken return cd9660_vget_internal(mp, ino, vpp);
682 1.1 jdolecek }
683 1.1 jdolecek
684 1.1 jdolecek int
685 1.86 hannken cd9660_vget_internal(struct mount *mp, ino_t ino, struct vnode **vpp)
686 1.1 jdolecek {
687 1.1 jdolecek struct iso_mnt *imp;
688 1.1 jdolecek struct iso_node *ip;
689 1.86 hannken struct iso_directory_record *isodir;
690 1.1 jdolecek struct buf *bp;
691 1.54 ad struct vnode *vp;
692 1.1 jdolecek dev_t dev;
693 1.86 hannken int lbn, off;
694 1.1 jdolecek int error;
695 1.1 jdolecek
696 1.1 jdolecek imp = VFSTOISOFS(mp);
697 1.1 jdolecek dev = imp->im_dev;
698 1.51 ad
699 1.51 ad retry:
700 1.51 ad if ((*vpp = cd9660_ihashget(dev, ino, LK_EXCLUSIVE)) != NULLVP)
701 1.1 jdolecek return (0);
702 1.1 jdolecek
703 1.1 jdolecek /* Allocate a new vnode/iso_node. */
704 1.72 rmind error = getnewvnode(VT_ISOFS, mp, cd9660_vnodeop_p, NULL, &vp);
705 1.72 rmind if (error) {
706 1.1 jdolecek *vpp = NULLVP;
707 1.1 jdolecek return (error);
708 1.1 jdolecek }
709 1.1 jdolecek ip = pool_get(&cd9660_node_pool, PR_WAITOK);
710 1.51 ad
711 1.51 ad /*
712 1.51 ad * If someone beat us to it, put back the freshly allocated
713 1.51 ad * vnode/inode pair and retry.
714 1.51 ad */
715 1.51 ad mutex_enter(&cd9660_hashlock);
716 1.51 ad if (cd9660_ihashget(dev, ino, 0) != NULL) {
717 1.51 ad mutex_exit(&cd9660_hashlock);
718 1.51 ad ungetnewvnode(vp);
719 1.51 ad pool_put(&cd9660_node_pool, ip);
720 1.51 ad goto retry;
721 1.51 ad }
722 1.51 ad
723 1.3 dsl memset(ip, 0, sizeof(struct iso_node));
724 1.1 jdolecek vp->v_data = ip;
725 1.1 jdolecek ip->i_vnode = vp;
726 1.1 jdolecek ip->i_dev = dev;
727 1.1 jdolecek ip->i_number = ino;
728 1.51 ad ip->i_mnt = imp;
729 1.51 ad ip->i_devvp = imp->im_devvp;
730 1.51 ad genfs_node_init(vp, &cd9660_genfsops);
731 1.1 jdolecek
732 1.1 jdolecek /*
733 1.1 jdolecek * Put it onto its hash chain and lock it so that other requests for
734 1.1 jdolecek * this inode will block if they arrive while we are sleeping waiting
735 1.1 jdolecek * for old data structures to be purged or for the contents of the
736 1.1 jdolecek * disk portion of this inode to be read.
737 1.1 jdolecek */
738 1.1 jdolecek cd9660_ihashins(ip);
739 1.51 ad mutex_exit(&cd9660_hashlock);
740 1.1 jdolecek
741 1.86 hannken lbn = cd9660_lblkno(imp, ino);
742 1.86 hannken if (lbn >= imp->volume_space_size) {
743 1.86 hannken vput(vp);
744 1.86 hannken printf("fhtovp: lbn exceed volume space %d\n", lbn);
745 1.86 hannken return (ESTALE);
746 1.86 hannken }
747 1.1 jdolecek
748 1.86 hannken off = cd9660_blkoff(imp, ino);
749 1.86 hannken if (off + ISO_DIRECTORY_RECORD_SIZE > imp->logical_block_size) {
750 1.86 hannken vput(vp);
751 1.86 hannken printf("fhtovp: crosses block boundary %d\n",
752 1.86 hannken off + ISO_DIRECTORY_RECORD_SIZE);
753 1.86 hannken return (ESTALE);
754 1.86 hannken }
755 1.22 perry
756 1.86 hannken error = bread(imp->im_devvp,
757 1.86 hannken lbn << (imp->im_bshift - DEV_BSHIFT),
758 1.86 hannken imp->logical_block_size, NOCRED, 0, &bp);
759 1.86 hannken if (error) {
760 1.86 hannken vput(vp);
761 1.86 hannken printf("fhtovp: bread error %d\n",error);
762 1.86 hannken return (error);
763 1.86 hannken }
764 1.86 hannken isodir = (struct iso_directory_record *)((char *)bp->b_data + off);
765 1.22 perry
766 1.86 hannken if (off + isonum_711(isodir->length) > imp->logical_block_size) {
767 1.86 hannken vput(vp);
768 1.86 hannken if (bp != 0)
769 1.86 hannken brelse(bp, 0);
770 1.86 hannken printf("fhtovp: directory crosses block boundary %d[off=%d/len=%d]\n",
771 1.86 hannken off +isonum_711(isodir->length), off,
772 1.86 hannken isonum_711(isodir->length));
773 1.86 hannken return (ESTALE);
774 1.86 hannken }
775 1.22 perry
776 1.1 jdolecek #if 0
777 1.86 hannken if (isonum_733(isodir->extent) +
778 1.86 hannken isonum_711(isodir->ext_attr_length) != ifhp->ifid_start) {
779 1.1 jdolecek if (bp != 0)
780 1.48 ad brelse(bp, 0);
781 1.86 hannken printf("fhtovp: file start miss %d vs %d\n",
782 1.86 hannken isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length),
783 1.86 hannken ifhp->ifid_start);
784 1.86 hannken return (ESTALE);
785 1.1 jdolecek }
786 1.86 hannken #endif
787 1.1 jdolecek
788 1.1 jdolecek ip->iso_extent = isonum_733(isodir->extent);
789 1.1 jdolecek ip->i_size = isonum_733(isodir->size);
790 1.1 jdolecek ip->iso_start = isonum_711(isodir->ext_attr_length) + ip->iso_extent;
791 1.22 perry
792 1.1 jdolecek /*
793 1.1 jdolecek * Setup time stamp, attribute
794 1.1 jdolecek */
795 1.1 jdolecek vp->v_type = VNON;
796 1.1 jdolecek switch (imp->iso_ftype) {
797 1.1 jdolecek default: /* ISO_FTYPE_9660 */
798 1.1 jdolecek {
799 1.1 jdolecek struct buf *bp2;
800 1.1 jdolecek if ((imp->im_flags & ISOFSMNT_EXTATT)
801 1.1 jdolecek && (off = isonum_711(isodir->ext_attr_length)))
802 1.29 yamt cd9660_blkatoff(vp, (off_t)-(off << imp->im_bshift),
803 1.29 yamt NULL, &bp2);
804 1.1 jdolecek else
805 1.1 jdolecek bp2 = NULL;
806 1.1 jdolecek cd9660_defattr(isodir, ip, bp2);
807 1.1 jdolecek cd9660_deftstamp(isodir, ip, bp2);
808 1.1 jdolecek if (bp2)
809 1.48 ad brelse(bp2, 0);
810 1.1 jdolecek break;
811 1.1 jdolecek }
812 1.1 jdolecek case ISO_FTYPE_RRIP:
813 1.1 jdolecek cd9660_rrip_analyze(isodir, ip, imp);
814 1.1 jdolecek break;
815 1.1 jdolecek }
816 1.1 jdolecek
817 1.1 jdolecek if (bp != 0)
818 1.48 ad brelse(bp, 0);
819 1.1 jdolecek
820 1.1 jdolecek /*
821 1.1 jdolecek * Initialize the associated vnode
822 1.1 jdolecek */
823 1.1 jdolecek switch (vp->v_type = IFTOVT(ip->inode.iso_mode)) {
824 1.1 jdolecek case VFIFO:
825 1.1 jdolecek vp->v_op = cd9660_fifoop_p;
826 1.1 jdolecek break;
827 1.1 jdolecek case VCHR:
828 1.1 jdolecek case VBLK:
829 1.1 jdolecek /*
830 1.1 jdolecek * if device, look at device number table for translation
831 1.1 jdolecek */
832 1.1 jdolecek vp->v_op = cd9660_specop_p;
833 1.54 ad spec_node_init(vp, ip->inode.iso_rdev);
834 1.1 jdolecek break;
835 1.1 jdolecek case VLNK:
836 1.1 jdolecek case VNON:
837 1.1 jdolecek case VSOCK:
838 1.1 jdolecek case VDIR:
839 1.1 jdolecek case VBAD:
840 1.1 jdolecek break;
841 1.1 jdolecek case VREG:
842 1.1 jdolecek uvm_vnp_setsize(vp, ip->i_size);
843 1.1 jdolecek break;
844 1.1 jdolecek }
845 1.22 perry
846 1.45 pooka if (vp->v_type != VREG)
847 1.45 pooka uvm_vnp_setsize(vp, 0);
848 1.45 pooka
849 1.1 jdolecek if (ip->iso_extent == imp->root_extent)
850 1.49 ad vp->v_vflag |= VV_ROOT;
851 1.1 jdolecek
852 1.1 jdolecek /*
853 1.1 jdolecek * XXX need generation number?
854 1.1 jdolecek */
855 1.22 perry
856 1.1 jdolecek *vpp = vp;
857 1.1 jdolecek return (0);
858 1.1 jdolecek }
859 1.1 jdolecek
860 1.1 jdolecek /*
861 1.1 jdolecek * Vnode pointer to File handle
862 1.1 jdolecek */
863 1.1 jdolecek /* ARGSUSED */
864 1.1 jdolecek int
865 1.57 matt cd9660_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size)
866 1.1 jdolecek {
867 1.1 jdolecek struct iso_node *ip = VTOI(vp);
868 1.33 martin struct ifid ifh;
869 1.22 perry
870 1.33 martin if (*fh_size < sizeof(struct ifid)) {
871 1.33 martin *fh_size = sizeof(struct ifid);
872 1.33 martin return E2BIG;
873 1.33 martin }
874 1.33 martin *fh_size = sizeof(struct ifid);
875 1.33 martin
876 1.33 martin memset(&ifh, 0, sizeof(ifh));
877 1.33 martin ifh.ifid_len = sizeof(struct ifid);
878 1.33 martin ifh.ifid_ino = ip->i_number;
879 1.85 martin #ifdef ISOFS_DBG
880 1.33 martin ifh.ifid_start = ip->iso_start;
881 1.85 martin #endif
882 1.33 martin memcpy(fhp, &ifh, sizeof(ifh));
883 1.22 perry
884 1.1 jdolecek #ifdef ISOFS_DBG
885 1.85 martin printf("vptofh: ino %"PRIu64", start %lu\n",
886 1.33 martin ifh.ifid_ino,ifh.ifid_start);
887 1.1 jdolecek #endif
888 1.1 jdolecek return 0;
889 1.1 jdolecek }
890