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.51 1999/01/31 11:54:29 bde 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#include <sys/syslog.h> |
57 58#include <isofs/cd9660/iso.h> 59#include <isofs/cd9660/iso_rrip.h> 60#include <isofs/cd9660/cd9660_node.h> 61#include <isofs/cd9660/cd9660_mount.h> 62 63MALLOC_DEFINE(M_ISOFSMNT, "ISOFS mount", "ISOFS mount structure"); 64MALLOC_DEFINE(M_ISOFSNODE, "ISOFS node", "ISOFS vnode private part"); --- 212 unchanged lines hidden (view full) --- 277iso_mountfs(devvp, mp, p, argp) 278 register struct vnode *devvp; 279 struct mount *mp; 280 struct proc *p; 281 struct iso_args *argp; 282{ 283 register struct iso_mnt *isomp = (struct iso_mnt *)0; 284 struct buf *bp = NULL; |
285 struct buf *pribp = NULL, *supbp = NULL; |
286 dev_t dev = devvp->v_rdev; 287 int error = EINVAL; 288 int needclose = 0; 289 int high_sierra = 0; 290 int iso_bsize; 291 int iso_blknum; |
292 int joliet_level; |
293 struct iso_volume_descriptor *vdp = 0; |
294 struct iso_primary_descriptor *pri = NULL; 295 struct iso_sierra_primary_descriptor *pri_sierra = NULL; 296 struct iso_supplementary_descriptor *sup = NULL; |
297 struct iso_directory_record *rootp; 298 int logical_block_size; 299 300 if (!(mp->mnt_flag & MNT_RDONLY)) 301 return EROFS; 302 303 /* 304 * Disallow multiple mounts of the same device. --- 13 unchanged lines hidden (view full) --- 318 needclose = 1; 319 320 /* This is the "logical sector size". The standard says this 321 * should be 2048 or the physical sector size on the device, 322 * whichever is greater. For now, we'll just use a constant. 323 */ 324 iso_bsize = ISO_DEFAULT_BLOCK_SIZE; 325 |
326 joliet_level = 0; |
327 for (iso_blknum = 16 + argp->ssector; 328 iso_blknum < 100 + argp->ssector; 329 iso_blknum++) { 330 if ((error = bread(devvp, iso_blknum * btodb(iso_bsize), 331 iso_bsize, NOCRED, &bp)) != 0) 332 goto out; 333 334 vdp = (struct iso_volume_descriptor *)bp->b_data; 335 if (bcmp (vdp->id, ISO_STANDARD_ID, sizeof vdp->id) != 0) { 336 if (bcmp (vdp->id_sierra, ISO_SIERRA_ID, 337 sizeof vdp->id) != 0) { 338 error = EINVAL; 339 goto out; 340 } else 341 high_sierra = 1; 342 } |
343 switch (isonum_711 (high_sierra? vdp->type_sierra: vdp->type)){ 344 case ISO_VD_PRIMARY: 345 if (pribp == NULL) { 346 pribp = bp; 347 bp = NULL; 348 pri = (struct iso_primary_descriptor *)vdp; 349 pri_sierra = 350 (struct iso_sierra_primary_descriptor *)vdp; 351 } 352 break; |
353 |
354 case ISO_VD_SUPPLEMENTARY: 355 if (supbp == NULL) { 356 supbp = bp; 357 bp = NULL; 358 sup = (struct iso_supplementary_descriptor *)vdp; |
359 |
360 if (!(argp->flags & ISOFSMNT_NOJOLIET)) { 361 if (bcmp(sup->escape, "%/@", 3) == 0) 362 joliet_level = 1; 363 if (bcmp(sup->escape, "%/C", 3) == 0) 364 joliet_level = 2; 365 if (bcmp(sup->escape, "%/E", 3) == 0) 366 joliet_level = 3; 367 368 if (isonum_711 (sup->flags) & 1) 369 joliet_level = 0; 370 } 371 } |
372 break; |
373 374 case ISO_VD_END: 375 goto vd_end; 376 377 default: 378 break; 379 } 380 if (bp) { 381 brelse(bp); 382 bp = NULL; 383 } 384 } 385 vd_end: 386 if (bp) { |
387 brelse(bp); |
388 bp = NULL; |
389 } 390 |
391 if (pri == NULL) { |
392 error = EINVAL; 393 goto out; 394 } 395 |
396 logical_block_size = 397 isonum_723 (high_sierra? 398 pri_sierra->logical_block_size: 399 pri->logical_block_size); 400 401 if (logical_block_size < DEV_BSIZE || logical_block_size > MAXBSIZE 402 || (logical_block_size & (logical_block_size - 1)) != 0) { 403 error = EINVAL; --- 7 unchanged lines hidden (view full) --- 411 412 isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK); 413 bzero((caddr_t)isomp, sizeof *isomp); 414 isomp->logical_block_size = logical_block_size; 415 isomp->volume_space_size = 416 isonum_733 (high_sierra? 417 pri_sierra->volume_space_size: 418 pri->volume_space_size); |
419 isomp->joliet_level = 0; |
420 /* 421 * Since an ISO9660 multi-session CD can also access previous 422 * sessions, we have to include them into the space consider- 423 * ations. This doesn't yield a very accurate number since 424 * parts of the old sessions might be inaccessible now, but we 425 * can't do much better. This is also important for the NFS 426 * filehandle validation. 427 */ 428 isomp->volume_space_size += argp->ssector; 429 bcopy (rootp, isomp->root, sizeof isomp->root); 430 isomp->root_extent = isonum_733 (rootp->extent); 431 isomp->root_size = isonum_733 (rootp->size); 432 433 isomp->im_bmask = logical_block_size - 1; |
434 isomp->im_bshift = ffs(logical_block_size) - 1; |
435 |
436 pribp->b_flags |= B_AGE; 437 brelse(pribp); 438 pribp = NULL; |
439 440 mp->mnt_data = (qaddr_t)isomp; 441 mp->mnt_stat.f_fsid.val[0] = (long)dev; 442 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; 443 mp->mnt_maxsymlinklen = 0; 444 mp->mnt_flag |= MNT_LOCAL; 445 isomp->im_mountp = mp; 446 isomp->im_dev = dev; --- 20 unchanged lines hidden (view full) --- 467 /* 468 * The contents are valid, 469 * but they will get reread as part of another vnode, so... 470 */ 471 bp->b_flags |= B_AGE; 472 brelse(bp); 473 bp = NULL; 474 } |
475 isomp->im_flags = argp->flags & (ISOFSMNT_NORRIP | ISOFSMNT_GENS | 476 ISOFSMNT_EXTATT | ISOFSMNT_NOJOLIET); |
477 |
478 if (high_sierra) { |
479 /* this effectively ignores all the mount flags */ |
480 log(LOG_INFO, "cd9660: High Sierra Format\n"); |
481 isomp->iso_ftype = ISO_FTYPE_HIGH_SIERRA; |
482 } else |
483 switch (isomp->im_flags&(ISOFSMNT_NORRIP|ISOFSMNT_GENS)) { 484 default: 485 isomp->iso_ftype = ISO_FTYPE_DEFAULT; 486 break; 487 case ISOFSMNT_GENS|ISOFSMNT_NORRIP: 488 isomp->iso_ftype = ISO_FTYPE_9660; 489 break; 490 case 0: |
491 log(LOG_INFO, "cd9660: RockRidge Extension\n"); |
492 isomp->iso_ftype = ISO_FTYPE_RRIP; 493 break; 494 } 495 |
496 /* Decide whether to use the Joliet descriptor */ 497 498 if (isomp->iso_ftype != ISO_FTYPE_RRIP && joliet_level) { 499 log(LOG_INFO, "cd9660: Joliet Extension\n"); 500 rootp = (struct iso_directory_record *) 501 sup->root_directory_record; 502 bcopy (rootp, isomp->root, sizeof isomp->root); 503 isomp->root_extent = isonum_733 (rootp->extent); 504 isomp->root_size = isonum_733 (rootp->size); 505 isomp->joliet_level = joliet_level; 506 supbp->b_flags |= B_AGE; 507 } 508 509 if (supbp) { 510 brelse(supbp); 511 supbp = NULL; 512 } 513 |
514 return 0; 515out: 516 devvp->v_specmountpoint = NULL; 517 if (bp) 518 brelse(bp); |
519 if (pribp) 520 brelse(pribp); 521 if (supbp) 522 brelse(supbp); |
523 if (needclose) 524 (void)VOP_CLOSE(devvp, FREAD, NOCRED, p); 525 if (isomp) { 526 free((caddr_t)isomp, M_ISOFSMNT); 527 mp->mnt_data = (qaddr_t)0; 528 } 529 return error; 530} --- 427 unchanged lines hidden --- |