Deleted Added
sdiff udiff text old ( 43461 ) new ( 45773 )
full compact
1/*-
2 * Copyright (c) 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley
6 * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
7 * Support code is derived from software contributed to Berkeley
8 * by Atsushi Murai (amurai@spec.co.jp).

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)cd9660_vfsops.c 8.18 (Berkeley) 5/22/95
39 * $Id: cd9660_vfsops.c,v 1.50 1999/01/30 12:26:22 phk Exp $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/namei.h>
45#include <sys/proc.h>
46#include <sys/kernel.h>
47#include <sys/vnode.h>
48#include <miscfs/specfs/specdev.h>
49#include <sys/mount.h>
50#include <sys/buf.h>
51#include <sys/cdio.h>
52#include <sys/conf.h>
53#include <sys/fcntl.h>
54#include <sys/malloc.h>
55#include <sys/stat.h>
56
57#include <isofs/cd9660/iso.h>
58#include <isofs/cd9660/iso_rrip.h>
59#include <isofs/cd9660/cd9660_node.h>
60#include <isofs/cd9660/cd9660_mount.h>
61
62MALLOC_DEFINE(M_ISOFSMNT, "ISOFS mount", "ISOFS mount structure");
63MALLOC_DEFINE(M_ISOFSNODE, "ISOFS node", "ISOFS vnode private part");

--- 212 unchanged lines hidden (view full) ---

276iso_mountfs(devvp, mp, p, argp)
277 register struct vnode *devvp;
278 struct mount *mp;
279 struct proc *p;
280 struct iso_args *argp;
281{
282 register struct iso_mnt *isomp = (struct iso_mnt *)0;
283 struct buf *bp = NULL;
284 dev_t dev = devvp->v_rdev;
285 int error = EINVAL;
286 int needclose = 0;
287 int high_sierra = 0;
288 int iso_bsize;
289 int iso_blknum;
290 struct iso_volume_descriptor *vdp = 0;
291 struct iso_primary_descriptor *pri;
292 struct iso_sierra_primary_descriptor *pri_sierra;
293 struct iso_directory_record *rootp;
294 int logical_block_size;
295
296 if (!(mp->mnt_flag & MNT_RDONLY))
297 return EROFS;
298
299 /*
300 * Disallow multiple mounts of the same device.

--- 13 unchanged lines hidden (view full) ---

314 needclose = 1;
315
316 /* This is the "logical sector size". The standard says this
317 * should be 2048 or the physical sector size on the device,
318 * whichever is greater. For now, we'll just use a constant.
319 */
320 iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
321
322 for (iso_blknum = 16 + argp->ssector;
323 iso_blknum < 100 + argp->ssector;
324 iso_blknum++) {
325 if ((error = bread(devvp, iso_blknum * btodb(iso_bsize),
326 iso_bsize, NOCRED, &bp)) != 0)
327 goto out;
328
329 vdp = (struct iso_volume_descriptor *)bp->b_data;
330 if (bcmp (vdp->id, ISO_STANDARD_ID, sizeof vdp->id) != 0) {
331 if (bcmp (vdp->id_sierra, ISO_SIERRA_ID,
332 sizeof vdp->id) != 0) {
333 error = EINVAL;
334 goto out;
335 } else
336 high_sierra = 1;
337 }
338
339 if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) == ISO_VD_END) {
340 error = EINVAL;
341 goto out;
342 }
343
344 if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) == ISO_VD_PRIMARY)
345 break;
346 brelse(bp);
347 }
348
349 if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) != ISO_VD_PRIMARY) {
350 error = EINVAL;
351 goto out;
352 }
353
354 pri = (struct iso_primary_descriptor *)vdp;
355 pri_sierra = (struct iso_sierra_primary_descriptor *)vdp;
356
357 logical_block_size =
358 isonum_723 (high_sierra?
359 pri_sierra->logical_block_size:
360 pri->logical_block_size);
361
362 if (logical_block_size < DEV_BSIZE || logical_block_size > MAXBSIZE
363 || (logical_block_size & (logical_block_size - 1)) != 0) {
364 error = EINVAL;

--- 7 unchanged lines hidden (view full) ---

372
373 isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK);
374 bzero((caddr_t)isomp, sizeof *isomp);
375 isomp->logical_block_size = logical_block_size;
376 isomp->volume_space_size =
377 isonum_733 (high_sierra?
378 pri_sierra->volume_space_size:
379 pri->volume_space_size);
380 /*
381 * Since an ISO9660 multi-session CD can also access previous
382 * sessions, we have to include them into the space consider-
383 * ations. This doesn't yield a very accurate number since
384 * parts of the old sessions might be inaccessible now, but we
385 * can't do much better. This is also important for the NFS
386 * filehandle validation.
387 */
388 isomp->volume_space_size += argp->ssector;
389 bcopy (rootp, isomp->root, sizeof isomp->root);
390 isomp->root_extent = isonum_733 (rootp->extent);
391 isomp->root_size = isonum_733 (rootp->size);
392
393 isomp->im_bmask = logical_block_size - 1;
394 isomp->im_bshift = 0;
395 while ((1 << isomp->im_bshift) < isomp->logical_block_size)
396 isomp->im_bshift++;
397
398 bp->b_flags |= B_AGE;
399 brelse(bp);
400 bp = NULL;
401
402 mp->mnt_data = (qaddr_t)isomp;
403 mp->mnt_stat.f_fsid.val[0] = (long)dev;
404 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
405 mp->mnt_maxsymlinklen = 0;
406 mp->mnt_flag |= MNT_LOCAL;
407 isomp->im_mountp = mp;
408 isomp->im_dev = dev;

--- 20 unchanged lines hidden (view full) ---

429 /*
430 * The contents are valid,
431 * but they will get reread as part of another vnode, so...
432 */
433 bp->b_flags |= B_AGE;
434 brelse(bp);
435 bp = NULL;
436 }
437 isomp->im_flags = argp->flags&(ISOFSMNT_NORRIP|ISOFSMNT_GENS|ISOFSMNT_EXTATT);
438
439 if(high_sierra)
440 /* this effectively ignores all the mount flags */
441 isomp->iso_ftype = ISO_FTYPE_HIGH_SIERRA;
442 else
443 switch (isomp->im_flags&(ISOFSMNT_NORRIP|ISOFSMNT_GENS)) {
444 default:
445 isomp->iso_ftype = ISO_FTYPE_DEFAULT;
446 break;
447 case ISOFSMNT_GENS|ISOFSMNT_NORRIP:
448 isomp->iso_ftype = ISO_FTYPE_9660;
449 break;
450 case 0:
451 isomp->iso_ftype = ISO_FTYPE_RRIP;
452 break;
453 }
454
455 return 0;
456out:
457 devvp->v_specmountpoint = NULL;
458 if (bp)
459 brelse(bp);
460 if (needclose)
461 (void)VOP_CLOSE(devvp, FREAD, NOCRED, p);
462 if (isomp) {
463 free((caddr_t)isomp, M_ISOFSMNT);
464 mp->mnt_data = (qaddr_t)0;
465 }
466 return error;
467}

--- 427 unchanged lines hidden ---