cd9660_vfsops.c (43461) | cd9660_vfsops.c (45773) |
---|---|
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 | 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 $ | 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> | 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> |
|
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; | 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; |
|
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; | 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; |
|
290 struct iso_volume_descriptor *vdp = 0; | 293 struct iso_volume_descriptor *vdp = 0; |
291 struct iso_primary_descriptor *pri; 292 struct iso_sierra_primary_descriptor *pri_sierra; | 294 struct iso_primary_descriptor *pri = NULL; 295 struct iso_sierra_primary_descriptor *pri_sierra = NULL; 296 struct iso_supplementary_descriptor *sup = NULL; |
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 | 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; |
|
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 } | 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; |
|
338 | 353 |
339 if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) == ISO_VD_END) { 340 error = EINVAL; 341 goto out; 342 } | 354 case ISO_VD_SUPPLEMENTARY: 355 if (supbp == NULL) { 356 supbp = bp; 357 bp = NULL; 358 sup = (struct iso_supplementary_descriptor *)vdp; |
343 | 359 |
344 if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) == ISO_VD_PRIMARY) | 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 } |
345 break; | 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) { |
|
346 brelse(bp); | 387 brelse(bp); |
388 bp = NULL; |
|
347 } 348 | 389 } 390 |
349 if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) != ISO_VD_PRIMARY) { | 391 if (pri == NULL) { |
350 error = EINVAL; 351 goto out; 352 } 353 | 392 error = EINVAL; 393 goto out; 394 } 395 |
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); | 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; |
|
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; | 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; |
394 isomp->im_bshift = 0; 395 while ((1 << isomp->im_bshift) < isomp->logical_block_size) 396 isomp->im_bshift++; | 434 isomp->im_bshift = ffs(logical_block_size) - 1; |
397 | 435 |
398 bp->b_flags |= B_AGE; 399 brelse(bp); 400 bp = NULL; | 436 pribp->b_flags |= B_AGE; 437 brelse(pribp); 438 pribp = 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 } | 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 } |
437 isomp->im_flags = argp->flags&(ISOFSMNT_NORRIP|ISOFSMNT_GENS|ISOFSMNT_EXTATT); | 475 isomp->im_flags = argp->flags & (ISOFSMNT_NORRIP | ISOFSMNT_GENS | 476 ISOFSMNT_EXTATT | ISOFSMNT_NOJOLIET); |
438 | 477 |
439 if(high_sierra) | 478 if (high_sierra) { |
440 /* this effectively ignores all the mount flags */ | 479 /* this effectively ignores all the mount flags */ |
480 log(LOG_INFO, "cd9660: High Sierra Format\n"); |
|
441 isomp->iso_ftype = ISO_FTYPE_HIGH_SIERRA; | 481 isomp->iso_ftype = ISO_FTYPE_HIGH_SIERRA; |
442 else | 482 } 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: | 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"); |
|
451 isomp->iso_ftype = ISO_FTYPE_RRIP; 452 break; 453 } 454 | 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 |
|
455 return 0; 456out: 457 devvp->v_specmountpoint = NULL; 458 if (bp) 459 brelse(bp); | 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); |
|
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 --- | 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 --- |