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