cd9660_node.c (3396) | cd9660_node.c (5651) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1989, 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_node.c 8.2 (Berkeley) 1/23/94 | 1/*- 2 * Copyright (c) 1982, 1986, 1989, 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_node.c 8.2 (Berkeley) 1/23/94 |
39 * $Id: cd9660_node.c,v 1.6 1994/09/26 00:32:56 gpalmer Exp $ | 39 * $Id: cd9660_node.c,v 1.7 1994/10/06 21:06:17 davidg Exp $ |
40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/mount.h> 45#include <sys/proc.h> 46#include <sys/file.h> 47#include <sys/buf.h> --- 213 unchanged lines hidden (view full) --- 261 262 vp = ITOV(ip); 263 264 /* 265 * Setup time stamp, attribute 266 */ 267 vp->v_type = VNON; 268 switch (imp->iso_ftype) { | 40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/mount.h> 45#include <sys/proc.h> 46#include <sys/file.h> 47#include <sys/buf.h> --- 213 unchanged lines hidden (view full) --- 261 262 vp = ITOV(ip); 263 264 /* 265 * Setup time stamp, attribute 266 */ 267 vp->v_type = VNON; 268 switch (imp->iso_ftype) { |
269 default: /* ISO_FTYPE_9660 */ | 269 default: /* ISO_FTYPE_9660 || ISO_FTYPE_HIGH_SIERRA */ |
270 if ((imp->im_flags&ISOFSMNT_EXTATT) 271 && isonum_711(isodir->ext_attr_length)) 272 iso_blkatoff(ip,-isonum_711(isodir->ext_attr_length), 273 &bp2); | 270 if ((imp->im_flags&ISOFSMNT_EXTATT) 271 && isonum_711(isodir->ext_attr_length)) 272 iso_blkatoff(ip,-isonum_711(isodir->ext_attr_length), 273 &bp2); |
274 cd9660_defattr(isodir,ip,bp2 ); 275 cd9660_deftstamp(isodir,ip,bp2 ); | 274 cd9660_defattr(isodir,ip,bp2,imp->iso_ftype ); 275 cd9660_deftstamp(isodir,ip,bp2,imp->iso_ftype ); |
276 break; 277 case ISO_FTYPE_RRIP: 278 result = cd9660_rrip_analyze(isodir,ip,imp); 279 break; 280 } 281 if (bp2) 282 brelse(bp2); 283 if (bp) --- 164 unchanged lines hidden (view full) --- 448 } 449 return (0); 450} 451 452/* 453 * File attributes 454 */ 455void | 276 break; 277 case ISO_FTYPE_RRIP: 278 result = cd9660_rrip_analyze(isodir,ip,imp); 279 break; 280 } 281 if (bp2) 282 brelse(bp2); 283 if (bp) --- 164 unchanged lines hidden (view full) --- 448 } 449 return (0); 450} 451 452/* 453 * File attributes 454 */ 455void |
456cd9660_defattr(isodir,inop,bp) | 456cd9660_defattr(isodir,inop,bp,ftype) |
457 struct iso_directory_record *isodir; 458 struct iso_node *inop; 459 struct buf *bp; | 457 struct iso_directory_record *isodir; 458 struct iso_node *inop; 459 struct buf *bp; |
460 enum ISO_FTYPE ftype; |
|
460{ 461 struct buf *bp2 = NULL; 462 struct iso_mnt *imp; 463 struct iso_extended_attributes *ap = NULL; 464 int off; 465 | 461{ 462 struct buf *bp2 = NULL; 463 struct iso_mnt *imp; 464 struct iso_extended_attributes *ap = NULL; 465 int off; 466 |
466 if (isonum_711(isodir->flags)&2) { | 467 /* high sierra does not have timezone data, flag is one byte ahead */ 468 if (isonum_711(ftype == ISO_FTYPE_HIGH_SIERRA? 469 &isodir->date[6]: isodir->flags)&2) { |
467 inop->inode.iso_mode = S_IFDIR; 468 /* 469 * If we return 2, fts() will assume there are no subdirectories 470 * (just links for the path and .), so instead we return 1. 471 */ 472 inop->inode.iso_links = 1; 473 } else { 474 inop->inode.iso_mode = S_IFREG; --- 34 unchanged lines hidden (view full) --- 509 if (bp2) 510 brelse(bp2); 511} 512 513/* 514 * Time stamps 515 */ 516void | 470 inop->inode.iso_mode = S_IFDIR; 471 /* 472 * If we return 2, fts() will assume there are no subdirectories 473 * (just links for the path and .), so instead we return 1. 474 */ 475 inop->inode.iso_links = 1; 476 } else { 477 inop->inode.iso_mode = S_IFREG; --- 34 unchanged lines hidden (view full) --- 512 if (bp2) 513 brelse(bp2); 514} 515 516/* 517 * Time stamps 518 */ 519void |
517cd9660_deftstamp(isodir,inop,bp) | 520cd9660_deftstamp(isodir,inop,bp,ftype) |
518 struct iso_directory_record *isodir; 519 struct iso_node *inop; 520 struct buf *bp; | 521 struct iso_directory_record *isodir; 522 struct iso_node *inop; 523 struct buf *bp; |
524 enum ISO_FTYPE ftype; |
|
521{ 522 struct buf *bp2 = NULL; 523 struct iso_mnt *imp; 524 struct iso_extended_attributes *ap = NULL; 525 int off; 526 527 if (!bp 528 && ((imp = inop->i_mnt)->im_flags&ISOFSMNT_EXTATT) 529 && (off = isonum_711(isodir->ext_attr_length))) { 530 iso_blkatoff(inop,-off * imp->logical_block_size,&bp2); 531 bp = bp2; 532 } 533 if (bp) { 534 ap = (struct iso_extended_attributes *)bp->b_un.b_addr; 535 | 525{ 526 struct buf *bp2 = NULL; 527 struct iso_mnt *imp; 528 struct iso_extended_attributes *ap = NULL; 529 int off; 530 531 if (!bp 532 && ((imp = inop->i_mnt)->im_flags&ISOFSMNT_EXTATT) 533 && (off = isonum_711(isodir->ext_attr_length))) { 534 iso_blkatoff(inop,-off * imp->logical_block_size,&bp2); 535 bp = bp2; 536 } 537 if (bp) { 538 ap = (struct iso_extended_attributes *)bp->b_un.b_addr; 539 |
536 if (isonum_711(ap->version) == 1) { | 540 if (ftype != ISO_FTYPE_HIGH_SIERRA 541 && isonum_711(ap->version) == 1) { |
537 if (!cd9660_tstamp_conv17(ap->ftime,&inop->inode.iso_atime)) 538 cd9660_tstamp_conv17(ap->ctime,&inop->inode.iso_atime); 539 if (!cd9660_tstamp_conv17(ap->ctime,&inop->inode.iso_ctime)) 540 inop->inode.iso_ctime = inop->inode.iso_atime; 541 if (!cd9660_tstamp_conv17(ap->mtime,&inop->inode.iso_mtime)) 542 inop->inode.iso_mtime = inop->inode.iso_ctime; 543 } else 544 ap = NULL; 545 } 546 if (!ap) { | 542 if (!cd9660_tstamp_conv17(ap->ftime,&inop->inode.iso_atime)) 543 cd9660_tstamp_conv17(ap->ctime,&inop->inode.iso_atime); 544 if (!cd9660_tstamp_conv17(ap->ctime,&inop->inode.iso_ctime)) 545 inop->inode.iso_ctime = inop->inode.iso_atime; 546 if (!cd9660_tstamp_conv17(ap->mtime,&inop->inode.iso_mtime)) 547 inop->inode.iso_mtime = inop->inode.iso_ctime; 548 } else 549 ap = NULL; 550 } 551 if (!ap) { |
547 cd9660_tstamp_conv7(isodir->date,&inop->inode.iso_ctime); | 552 cd9660_tstamp_conv7(isodir->date,&inop->inode.iso_ctime,ftype); |
548 inop->inode.iso_atime = inop->inode.iso_ctime; 549 inop->inode.iso_mtime = inop->inode.iso_ctime; 550 } 551 if (bp2) 552 brelse(bp2); 553} 554 555int | 553 inop->inode.iso_atime = inop->inode.iso_ctime; 554 inop->inode.iso_mtime = inop->inode.iso_ctime; 555 } 556 if (bp2) 557 brelse(bp2); 558} 559 560int |
556cd9660_tstamp_conv7(pi,pu) | 561cd9660_tstamp_conv7(pi,pu,ftype) |
557char *pi; 558struct timespec *pu; | 562char *pi; 563struct timespec *pu; |
564enum ISO_FTYPE ftype; |
|
559{ 560 int crtime, days; 561 int y, m, d, hour, minute, second, tz; 562 563 y = pi[0] + 1900; 564 m = pi[1]; 565 d = pi[2]; 566 hour = pi[3]; 567 minute = pi[4]; 568 second = pi[5]; | 565{ 566 int crtime, days; 567 int y, m, d, hour, minute, second, tz; 568 569 y = pi[0] + 1900; 570 m = pi[1]; 571 d = pi[2]; 572 hour = pi[3]; 573 minute = pi[4]; 574 second = pi[5]; |
569 tz = pi[6]; | 575 if(ftype != ISO_FTYPE_HIGH_SIERRA) 576 tz = pi[6]; 577 else 578 /* original high sierra misses timezone data */ 579 tz = 0; |
570 571 if (y < 1970) { 572 pu->ts_sec = 0; 573 pu->ts_nsec = 0; 574 return 0; 575 } else { 576#ifdef ORIGINAL 577 /* computes day number relative to Sept. 19th,1989 */ --- 33 unchanged lines hidden (view full) --- 611 612int 613cd9660_tstamp_conv17(pi,pu) 614 unsigned char *pi; 615 struct timespec *pu; 616{ 617 unsigned char buf[7]; 618 | 580 581 if (y < 1970) { 582 pu->ts_sec = 0; 583 pu->ts_nsec = 0; 584 return 0; 585 } else { 586#ifdef ORIGINAL 587 /* computes day number relative to Sept. 19th,1989 */ --- 33 unchanged lines hidden (view full) --- 621 622int 623cd9660_tstamp_conv17(pi,pu) 624 unsigned char *pi; 625 struct timespec *pu; 626{ 627 unsigned char buf[7]; 628 |
619 /* year:"0001"-"9999" -> -1900 */ | 629 /* year:"0001"-"9999" -> -1900 */ |
620 buf[0] = cd9660_chars2ui(pi,4) - 1900; 621 | 630 buf[0] = cd9660_chars2ui(pi,4) - 1900; 631 |
622 /* month: " 1"-"12" -> 1 - 12 */ | 632 /* month: " 1"-"12" -> 1 - 12 */ |
623 buf[1] = cd9660_chars2ui(pi + 4,2); 624 | 633 buf[1] = cd9660_chars2ui(pi + 4,2); 634 |
625 /* day: " 1"-"31" -> 1 - 31 */ | 635 /* day: " 1"-"31" -> 1 - 31 */ |
626 buf[2] = cd9660_chars2ui(pi + 6,2); 627 | 636 buf[2] = cd9660_chars2ui(pi + 6,2); 637 |
628 /* hour: " 0"-"23" -> 0 - 23 */ | 638 /* hour: " 0"-"23" -> 0 - 23 */ |
629 buf[3] = cd9660_chars2ui(pi + 8,2); 630 | 639 buf[3] = cd9660_chars2ui(pi + 8,2); 640 |
631 /* minute:" 0"-"59" -> 0 - 59 */ | 641 /* minute:" 0"-"59" -> 0 - 59 */ |
632 buf[4] = cd9660_chars2ui(pi + 10,2); 633 | 642 buf[4] = cd9660_chars2ui(pi + 10,2); 643 |
634 /* second:" 0"-"59" -> 0 - 59 */ | 644 /* second:" 0"-"59" -> 0 - 59 */ |
635 buf[5] = cd9660_chars2ui(pi + 12,2); 636 637 /* difference of GMT */ 638 buf[6] = pi[16]; 639 | 645 buf[5] = cd9660_chars2ui(pi + 12,2); 646 647 /* difference of GMT */ 648 buf[6] = pi[16]; 649 |
640 return cd9660_tstamp_conv7(buf,pu); | 650 return cd9660_tstamp_conv7(buf, pu, ISO_FTYPE_DEFAULT); |
641} 642 643void 644isodirino(inump,isodir,imp) 645 ino_t *inump; 646 struct iso_directory_record *isodir; 647 struct iso_mnt *imp; 648{ 649 *inump = (isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length)) 650 * imp->logical_block_size; 651} | 651} 652 653void 654isodirino(inump,isodir,imp) 655 ino_t *inump; 656 struct iso_directory_record *isodir; 657 struct iso_mnt *imp; 658{ 659 *inump = (isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length)) 660 * imp->logical_block_size; 661} |