iso.h revision 5651
11541Srgrimes/*- 21541Srgrimes * Copyright (c) 1994 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * This code is derived from software contributed to Berkeley 61541Srgrimes * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension 71541Srgrimes * Support code is derived from software contributed to Berkeley 81541Srgrimes * by Atsushi Murai (amurai@spec.co.jp). 91541Srgrimes * 101541Srgrimes * Redistribution and use in source and binary forms, with or without 111541Srgrimes * modification, are permitted provided that the following conditions 121541Srgrimes * are met: 131541Srgrimes * 1. Redistributions of source code must retain the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer. 151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161541Srgrimes * notice, this list of conditions and the following disclaimer in the 171541Srgrimes * documentation and/or other materials provided with the distribution. 181541Srgrimes * 3. All advertising materials mentioning features or use of this software 191541Srgrimes * must display the following acknowledgement: 201541Srgrimes * This product includes software developed by the University of 211541Srgrimes * California, Berkeley and its contributors. 221541Srgrimes * 4. Neither the name of the University nor the names of its contributors 231541Srgrimes * may be used to endorse or promote products derived from this software 241541Srgrimes * without specific prior written permission. 251541Srgrimes * 261541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 271541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 281541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 291541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 301541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 311541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 321541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 331541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 341541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 351541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 361541Srgrimes * SUCH DAMAGE. 371541Srgrimes * 381541Srgrimes * @(#)iso.h 8.2 (Berkeley) 1/23/94 395651Sjoerg * $Id: iso.h,v 1.3 1994/09/09 11:11:01 dfr Exp $ 401541Srgrimes */ 411541Srgrimes 421541Srgrimes#define ISODCL(from, to) (to - from + 1) 431541Srgrimes 441541Srgrimesstruct iso_volume_descriptor { 451541Srgrimes char type[ISODCL(1,1)]; /* 711 */ 461541Srgrimes char id[ISODCL(2,6)]; 471541Srgrimes char version[ISODCL(7,7)]; 485651Sjoerg char unused[ISODCL(8,8)]; 495651Sjoerg char type_sierra[ISODCL(9,9)]; /* 711 */ 505651Sjoerg char id_sierra[ISODCL(10,14)]; 515651Sjoerg char version_sierra[ISODCL(15,15)]; 525651Sjoerg char data[ISODCL(16,2048)]; 531541Srgrimes}; 541541Srgrimes 551541Srgrimes/* volume descriptor types */ 561541Srgrimes#define ISO_VD_PRIMARY 1 571541Srgrimes#define ISO_VD_END 255 581541Srgrimes 591541Srgrimes#define ISO_STANDARD_ID "CD001" 605651Sjoerg#define ISO_ECMA_ID "CDW01" 611541Srgrimes 625651Sjoerg#define ISO_SIERRA_ID "CDROM" 635651Sjoerg 641541Srgrimesstruct iso_primary_descriptor { 655651Sjoerg char type [ISODCL ( 1, 1)]; /* 711 */ 665651Sjoerg char id [ISODCL ( 2, 6)]; 675651Sjoerg char version [ISODCL ( 7, 7)]; /* 711 */ 685651Sjoerg char unused1 [ISODCL ( 8, 8)]; 691541Srgrimes char system_id [ISODCL ( 9, 40)]; /* achars */ 701541Srgrimes char volume_id [ISODCL ( 41, 72)]; /* dchars */ 711541Srgrimes char unused2 [ISODCL ( 73, 80)]; 721541Srgrimes char volume_space_size [ISODCL ( 81, 88)]; /* 733 */ 731541Srgrimes char unused3 [ISODCL ( 89, 120)]; 741541Srgrimes char volume_set_size [ISODCL (121, 124)]; /* 723 */ 751541Srgrimes char volume_sequence_number [ISODCL (125, 128)]; /* 723 */ 761541Srgrimes char logical_block_size [ISODCL (129, 132)]; /* 723 */ 771541Srgrimes char path_table_size [ISODCL (133, 140)]; /* 733 */ 781541Srgrimes char type_l_path_table [ISODCL (141, 144)]; /* 731 */ 791541Srgrimes char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */ 801541Srgrimes char type_m_path_table [ISODCL (149, 152)]; /* 732 */ 811541Srgrimes char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */ 821541Srgrimes char root_directory_record [ISODCL (157, 190)]; /* 9.1 */ 831541Srgrimes char volume_set_id [ISODCL (191, 318)]; /* dchars */ 841541Srgrimes char publisher_id [ISODCL (319, 446)]; /* achars */ 851541Srgrimes char preparer_id [ISODCL (447, 574)]; /* achars */ 861541Srgrimes char application_id [ISODCL (575, 702)]; /* achars */ 871541Srgrimes char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */ 881541Srgrimes char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */ 891541Srgrimes char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */ 901541Srgrimes char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */ 911541Srgrimes char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */ 921541Srgrimes char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */ 931541Srgrimes char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */ 941541Srgrimes char file_structure_version [ISODCL (882, 882)]; /* 711 */ 951541Srgrimes char unused4 [ISODCL (883, 883)]; 961541Srgrimes char application_data [ISODCL (884, 1395)]; 971541Srgrimes char unused5 [ISODCL (1396, 2048)]; 981541Srgrimes}; 991541Srgrimes#define ISO_DEFAULT_BLOCK_SIZE 2048 1001541Srgrimes 1015651Sjoergstruct iso_sierra_primary_descriptor { 1025651Sjoerg char unknown1 [ISODCL ( 1, 8)]; /* 733 */ 1035651Sjoerg char type [ISODCL ( 9, 9)]; /* 711 */ 1045651Sjoerg char id [ISODCL ( 10, 14)]; 1055651Sjoerg char version [ISODCL ( 15, 15)]; /* 711 */ 1065651Sjoerg char unused1 [ISODCL ( 16, 16)]; 1075651Sjoerg char system_id [ISODCL ( 17, 48)]; /* achars */ 1085651Sjoerg char volume_id [ISODCL ( 49, 80)]; /* dchars */ 1095651Sjoerg char unused2 [ISODCL ( 81, 88)]; 1105651Sjoerg char volume_space_size [ISODCL ( 89, 96)]; /* 733 */ 1115651Sjoerg char unused3 [ISODCL ( 97, 128)]; 1125651Sjoerg char volume_set_size [ISODCL (129, 132)]; /* 723 */ 1135651Sjoerg char volume_sequence_number [ISODCL (133, 136)]; /* 723 */ 1145651Sjoerg char logical_block_size [ISODCL (137, 140)]; /* 723 */ 1155651Sjoerg char path_table_size [ISODCL (141, 148)]; /* 733 */ 1165651Sjoerg char type_l_path_table [ISODCL (149, 152)]; /* 731 */ 1175651Sjoerg char opt_type_l_path_table [ISODCL (153, 156)]; /* 731 */ 1185651Sjoerg char unknown2 [ISODCL (157, 160)]; /* 731 */ 1195651Sjoerg char unknown3 [ISODCL (161, 164)]; /* 731 */ 1205651Sjoerg char type_m_path_table [ISODCL (165, 168)]; /* 732 */ 1215651Sjoerg char opt_type_m_path_table [ISODCL (169, 172)]; /* 732 */ 1225651Sjoerg char unknown4 [ISODCL (173, 176)]; /* 732 */ 1235651Sjoerg char unknown5 [ISODCL (177, 180)]; /* 732 */ 1245651Sjoerg char root_directory_record [ISODCL (181, 214)]; /* 9.1 */ 1255651Sjoerg char volume_set_id [ISODCL (215, 342)]; /* dchars */ 1265651Sjoerg char publisher_id [ISODCL (343, 470)]; /* achars */ 1275651Sjoerg char preparer_id [ISODCL (471, 598)]; /* achars */ 1285651Sjoerg char application_id [ISODCL (599, 726)]; /* achars */ 1295651Sjoerg char copyright_id [ISODCL (727, 790)]; /* achars */ 1305651Sjoerg char creation_date [ISODCL (791, 806)]; /* ? */ 1315651Sjoerg char modification_date [ISODCL (807, 822)]; /* ? */ 1325651Sjoerg char expiration_date [ISODCL (823, 838)]; /* ? */ 1335651Sjoerg char effective_date [ISODCL (839, 854)]; /* ? */ 1345651Sjoerg char file_structure_version [ISODCL (855, 855)]; /* 711 */ 1355651Sjoerg char unused4 [ISODCL (856, 2048)]; 1365651Sjoerg}; 1375651Sjoerg 1381541Srgrimesstruct iso_directory_record { 1391541Srgrimes char length [ISODCL (1, 1)]; /* 711 */ 1401541Srgrimes char ext_attr_length [ISODCL (2, 2)]; /* 711 */ 1411541Srgrimes unsigned char extent [ISODCL (3, 10)]; /* 733 */ 1421541Srgrimes unsigned char size [ISODCL (11, 18)]; /* 733 */ 1431541Srgrimes char date [ISODCL (19, 25)]; /* 7 by 711 */ 1441541Srgrimes char flags [ISODCL (26, 26)]; 1451541Srgrimes char file_unit_size [ISODCL (27, 27)]; /* 711 */ 1461541Srgrimes char interleave [ISODCL (28, 28)]; /* 711 */ 1471541Srgrimes char volume_sequence_number [ISODCL (29, 32)]; /* 723 */ 1481541Srgrimes char name_len [ISODCL (33, 33)]; /* 711 */ 1491541Srgrimes char name [0]; 1501541Srgrimes}; 1511541Srgrimes/* can't take sizeof(iso_directory_record), because of possible alignment 1521541Srgrimes of the last entry (34 instead of 33) */ 1531541Srgrimes#define ISO_DIRECTORY_RECORD_SIZE 33 1541541Srgrimes 1551541Srgrimesstruct iso_extended_attributes { 1561541Srgrimes unsigned char owner [ISODCL (1, 4)]; /* 723 */ 1571541Srgrimes unsigned char group [ISODCL (5, 8)]; /* 723 */ 1581541Srgrimes unsigned char perm [ISODCL (9, 10)]; /* 9.5.3 */ 1591541Srgrimes char ctime [ISODCL (11, 27)]; /* 8.4.26.1 */ 1601541Srgrimes char mtime [ISODCL (28, 44)]; /* 8.4.26.1 */ 1611541Srgrimes char xtime [ISODCL (45, 61)]; /* 8.4.26.1 */ 1621541Srgrimes char ftime [ISODCL (62, 78)]; /* 8.4.26.1 */ 1631541Srgrimes char recfmt [ISODCL (79, 79)]; /* 711 */ 1641541Srgrimes char recattr [ISODCL (80, 80)]; /* 711 */ 1651541Srgrimes unsigned char reclen [ISODCL (81, 84)]; /* 723 */ 1661541Srgrimes char system_id [ISODCL (85, 116)]; /* achars */ 1671541Srgrimes char system_use [ISODCL (117, 180)]; 1681541Srgrimes char version [ISODCL (181, 181)]; /* 711 */ 1691541Srgrimes char len_esc [ISODCL (182, 182)]; /* 711 */ 1701541Srgrimes char reserved [ISODCL (183, 246)]; 1711541Srgrimes unsigned char len_au [ISODCL (247, 250)]; /* 723 */ 1721541Srgrimes}; 1731541Srgrimes 1741541Srgrimes/* CD-ROM Format type */ 1755651Sjoergenum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP, 1765651Sjoerg ISO_FTYPE_ECMA, ISO_FTYPE_HIGH_SIERRA }; 1771541Srgrimes 1781541Srgrimes#ifndef ISOFSMNT_ROOT 1791541Srgrimes#define ISOFSMNT_ROOT 0 1801541Srgrimes#endif 1811541Srgrimes 1821541Srgrimesstruct iso_mnt { 1831541Srgrimes int im_flags; 1841541Srgrimes 1851541Srgrimes struct mount *im_mountp; 1861541Srgrimes dev_t im_dev; 1871541Srgrimes struct vnode *im_devvp; 1881541Srgrimes 1891541Srgrimes int logical_block_size; 1901541Srgrimes int im_bshift; 1911541Srgrimes int im_bmask; 1921541Srgrimes 1931541Srgrimes int volume_space_size; 1941541Srgrimes char im_fsmnt[50]; 1951541Srgrimes struct netexport im_export; 1961541Srgrimes 1971541Srgrimes char root[ISODCL (157, 190)]; 1981541Srgrimes int root_extent; 1991541Srgrimes int root_size; 2005651Sjoerg enum ISO_FTYPE iso_ftype; 2011541Srgrimes 2021541Srgrimes int rr_skip; 2031541Srgrimes int rr_skip0; 2041541Srgrimes}; 2051541Srgrimes 2061541Srgrimes#define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data)) 2071541Srgrimes 2081541Srgrimes#define iso_blkoff(imp, loc) ((loc) & (imp)->im_bmask) 2091541Srgrimes#define iso_lblkno(imp, loc) ((loc) >> (imp)->im_bshift) 2101541Srgrimes#define iso_blksize(imp, ip, lbn) ((imp)->logical_block_size) 2111541Srgrimes#define iso_lblktosize(imp, blk) ((blk) << (imp)->im_bshift) 2122604Sdfr#define iso_lblktodaddr(imp, lbn) btodb(iso_lblktosize(imp, lbn)) 2132604Sdfr#define iso_dblkinc(imp, lbn) ((lbn) + iso_lblktodaddr(imp, 1)) 2142604Sdfr#define iso_dblkno(imp, loc) iso_lblktodaddr(imp, iso_lblkno(imp, loc)) 2151541Srgrimes 2161541Srgrimesint cd9660_mount __P((struct mount *, 2171541Srgrimes char *, caddr_t, struct nameidata *, struct proc *)); 2181541Srgrimesint cd9660_start __P((struct mount *, int, struct proc *)); 2191541Srgrimesint cd9660_unmount __P((struct mount *, int, struct proc *)); 2201541Srgrimesint cd9660_root __P((struct mount *, struct vnode **)); 2211541Srgrimesint cd9660_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *)); 2221541Srgrimesint cd9660_statfs __P((struct mount *, struct statfs *, struct proc *)); 2231541Srgrimesint cd9660_sync __P((struct mount *, int, struct ucred *, struct proc *)); 2241541Srgrimesint cd9660_vget __P((struct mount *, ino_t, struct vnode **)); 2251541Srgrimesint cd9660_fhtovp __P((struct mount *, struct fid *, struct mbuf *, 2261541Srgrimes struct vnode **, int *, struct ucred **)); 2271541Srgrimesint cd9660_vptofh __P((struct vnode *, struct fid *)); 2281541Srgrimesint cd9660_init __P(()); 2291541Srgrimes 2301541Srgrimesstruct iso_node; 2311541Srgrimesint iso_blkatoff __P((struct iso_node *ip, long offset, struct buf **bpp)); 2321541Srgrimesint iso_iget __P((struct iso_node *xp, ino_t ino, int relocated, 2331541Srgrimes struct iso_node **ipp, struct iso_directory_record *isodir)); 2341541Srgrimesint iso_iput __P((struct iso_node *ip)); 2351541Srgrimesint iso_ilock __P((struct iso_node *ip)); 2361541Srgrimesint iso_iunlock __P((struct iso_node *ip)); 2371541Srgrimesint cd9660_mountroot __P((void)); 2381541Srgrimes 2391541Srgrimesextern int (**cd9660_vnodeop_p)(); 2401541Srgrimes 2411541Srgrimesextern inline int 2421541Srgrimesisonum_711(p) 2431541Srgrimes unsigned char *p; 2441541Srgrimes{ 2451541Srgrimes return *p; 2461541Srgrimes} 2471541Srgrimes 2481541Srgrimesextern inline int 2491541Srgrimesisonum_712(p) 2501541Srgrimes char *p; 2511541Srgrimes{ 2521541Srgrimes return *p; 2531541Srgrimes} 2541541Srgrimes 2551541Srgrimesextern inline int 2561541Srgrimesisonum_721(p) 2571541Srgrimes unsigned char *p; 2581541Srgrimes{ 2591541Srgrimes return *p|((char)p[1] << 8); 2601541Srgrimes} 2611541Srgrimes 2621541Srgrimesextern inline int 2631541Srgrimesisonum_722(p) 2641541Srgrimes unsigned char *p; 2651541Srgrimes{ 2661541Srgrimes return ((char)*p << 8)|p[1]; 2671541Srgrimes} 2681541Srgrimes 2691541Srgrimesextern inline int 2701541Srgrimesisonum_723(p) 2711541Srgrimes unsigned char *p; 2721541Srgrimes{ 2731541Srgrimes return isonum_721(p); 2741541Srgrimes} 2751541Srgrimes 2761541Srgrimesextern inline int 2771541Srgrimesisonum_731(p) 2781541Srgrimes unsigned char *p; 2791541Srgrimes{ 2801541Srgrimes return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24); 2811541Srgrimes} 2821541Srgrimes 2831541Srgrimesextern inline int 2841541Srgrimesisonum_732(p) 2851541Srgrimes unsigned char *p; 2861541Srgrimes{ 2871541Srgrimes return (*p << 24)|(p[1] << 16)|(p[2] << 8)|p[3]; 2881541Srgrimes} 2891541Srgrimes 2901541Srgrimesextern inline int 2911541Srgrimesisonum_733(p) 2921541Srgrimes unsigned char *p; 2931541Srgrimes{ 2941541Srgrimes return isonum_731(p); 2951541Srgrimes} 2961541Srgrimes 2971541Srgrimesint isofncmp __P((unsigned char *, int, unsigned char *, int)); 2981541Srgrimesvoid isofntrans __P((unsigned char *, int, unsigned char *, unsigned short *, 2991541Srgrimes int, int)); 3001541Srgrimes 3011541Srgrimes/* 3021541Srgrimes * Associated files have a leading '='. 3031541Srgrimes */ 3041541Srgrimes#define ASSOCCHAR '=' 305