iso.h revision 1541
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 391541Srgrimes */ 401541Srgrimes 411541Srgrimes#define ISODCL(from, to) (to - from + 1) 421541Srgrimes 431541Srgrimesstruct iso_volume_descriptor { 441541Srgrimes char type[ISODCL(1,1)]; /* 711 */ 451541Srgrimes char id[ISODCL(2,6)]; 461541Srgrimes char version[ISODCL(7,7)]; 471541Srgrimes char data[ISODCL(8,2048)]; 481541Srgrimes}; 491541Srgrimes 501541Srgrimes/* volume descriptor types */ 511541Srgrimes#define ISO_VD_PRIMARY 1 521541Srgrimes#define ISO_VD_END 255 531541Srgrimes 541541Srgrimes#define ISO_STANDARD_ID "CD001" 551541Srgrimes#define ISO_ECMA_ID "CDW01" 561541Srgrimes 571541Srgrimesstruct iso_primary_descriptor { 581541Srgrimes char type [ISODCL ( 1, 1)]; /* 711 */ 591541Srgrimes char id [ISODCL ( 2, 6)]; 601541Srgrimes char version [ISODCL ( 7, 7)]; /* 711 */ 611541Srgrimes char unused1 [ISODCL ( 8, 8)]; 621541Srgrimes char system_id [ISODCL ( 9, 40)]; /* achars */ 631541Srgrimes char volume_id [ISODCL ( 41, 72)]; /* dchars */ 641541Srgrimes char unused2 [ISODCL ( 73, 80)]; 651541Srgrimes char volume_space_size [ISODCL ( 81, 88)]; /* 733 */ 661541Srgrimes char unused3 [ISODCL ( 89, 120)]; 671541Srgrimes char volume_set_size [ISODCL (121, 124)]; /* 723 */ 681541Srgrimes char volume_sequence_number [ISODCL (125, 128)]; /* 723 */ 691541Srgrimes char logical_block_size [ISODCL (129, 132)]; /* 723 */ 701541Srgrimes char path_table_size [ISODCL (133, 140)]; /* 733 */ 711541Srgrimes char type_l_path_table [ISODCL (141, 144)]; /* 731 */ 721541Srgrimes char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */ 731541Srgrimes char type_m_path_table [ISODCL (149, 152)]; /* 732 */ 741541Srgrimes char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */ 751541Srgrimes char root_directory_record [ISODCL (157, 190)]; /* 9.1 */ 761541Srgrimes char volume_set_id [ISODCL (191, 318)]; /* dchars */ 771541Srgrimes char publisher_id [ISODCL (319, 446)]; /* achars */ 781541Srgrimes char preparer_id [ISODCL (447, 574)]; /* achars */ 791541Srgrimes char application_id [ISODCL (575, 702)]; /* achars */ 801541Srgrimes char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */ 811541Srgrimes char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */ 821541Srgrimes char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */ 831541Srgrimes char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */ 841541Srgrimes char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */ 851541Srgrimes char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */ 861541Srgrimes char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */ 871541Srgrimes char file_structure_version [ISODCL (882, 882)]; /* 711 */ 881541Srgrimes char unused4 [ISODCL (883, 883)]; 891541Srgrimes char application_data [ISODCL (884, 1395)]; 901541Srgrimes char unused5 [ISODCL (1396, 2048)]; 911541Srgrimes}; 921541Srgrimes#define ISO_DEFAULT_BLOCK_SIZE 2048 931541Srgrimes 941541Srgrimesstruct iso_directory_record { 951541Srgrimes char length [ISODCL (1, 1)]; /* 711 */ 961541Srgrimes char ext_attr_length [ISODCL (2, 2)]; /* 711 */ 971541Srgrimes unsigned char extent [ISODCL (3, 10)]; /* 733 */ 981541Srgrimes unsigned char size [ISODCL (11, 18)]; /* 733 */ 991541Srgrimes char date [ISODCL (19, 25)]; /* 7 by 711 */ 1001541Srgrimes char flags [ISODCL (26, 26)]; 1011541Srgrimes char file_unit_size [ISODCL (27, 27)]; /* 711 */ 1021541Srgrimes char interleave [ISODCL (28, 28)]; /* 711 */ 1031541Srgrimes char volume_sequence_number [ISODCL (29, 32)]; /* 723 */ 1041541Srgrimes char name_len [ISODCL (33, 33)]; /* 711 */ 1051541Srgrimes char name [0]; 1061541Srgrimes}; 1071541Srgrimes/* can't take sizeof(iso_directory_record), because of possible alignment 1081541Srgrimes of the last entry (34 instead of 33) */ 1091541Srgrimes#define ISO_DIRECTORY_RECORD_SIZE 33 1101541Srgrimes 1111541Srgrimesstruct iso_extended_attributes { 1121541Srgrimes unsigned char owner [ISODCL (1, 4)]; /* 723 */ 1131541Srgrimes unsigned char group [ISODCL (5, 8)]; /* 723 */ 1141541Srgrimes unsigned char perm [ISODCL (9, 10)]; /* 9.5.3 */ 1151541Srgrimes char ctime [ISODCL (11, 27)]; /* 8.4.26.1 */ 1161541Srgrimes char mtime [ISODCL (28, 44)]; /* 8.4.26.1 */ 1171541Srgrimes char xtime [ISODCL (45, 61)]; /* 8.4.26.1 */ 1181541Srgrimes char ftime [ISODCL (62, 78)]; /* 8.4.26.1 */ 1191541Srgrimes char recfmt [ISODCL (79, 79)]; /* 711 */ 1201541Srgrimes char recattr [ISODCL (80, 80)]; /* 711 */ 1211541Srgrimes unsigned char reclen [ISODCL (81, 84)]; /* 723 */ 1221541Srgrimes char system_id [ISODCL (85, 116)]; /* achars */ 1231541Srgrimes char system_use [ISODCL (117, 180)]; 1241541Srgrimes char version [ISODCL (181, 181)]; /* 711 */ 1251541Srgrimes char len_esc [ISODCL (182, 182)]; /* 711 */ 1261541Srgrimes char reserved [ISODCL (183, 246)]; 1271541Srgrimes unsigned char len_au [ISODCL (247, 250)]; /* 723 */ 1281541Srgrimes}; 1291541Srgrimes 1301541Srgrimes/* CD-ROM Format type */ 1311541Srgrimesenum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP, ISO_FTYPE_ECMA }; 1321541Srgrimes 1331541Srgrimes#ifndef ISOFSMNT_ROOT 1341541Srgrimes#define ISOFSMNT_ROOT 0 1351541Srgrimes#endif 1361541Srgrimes 1371541Srgrimesstruct iso_mnt { 1381541Srgrimes int im_flags; 1391541Srgrimes 1401541Srgrimes struct mount *im_mountp; 1411541Srgrimes dev_t im_dev; 1421541Srgrimes struct vnode *im_devvp; 1431541Srgrimes 1441541Srgrimes int logical_block_size; 1451541Srgrimes int im_bshift; 1461541Srgrimes int im_bmask; 1471541Srgrimes 1481541Srgrimes int volume_space_size; 1491541Srgrimes char im_fsmnt[50]; 1501541Srgrimes struct netexport im_export; 1511541Srgrimes 1521541Srgrimes char root[ISODCL (157, 190)]; 1531541Srgrimes int root_extent; 1541541Srgrimes int root_size; 1551541Srgrimes enum ISO_FTYPE iso_ftype; 1561541Srgrimes 1571541Srgrimes int rr_skip; 1581541Srgrimes int rr_skip0; 1591541Srgrimes}; 1601541Srgrimes 1611541Srgrimes#define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data)) 1621541Srgrimes 1631541Srgrimes#define iso_blkoff(imp, loc) ((loc) & (imp)->im_bmask) 1641541Srgrimes#define iso_lblkno(imp, loc) ((loc) >> (imp)->im_bshift) 1651541Srgrimes#define iso_blksize(imp, ip, lbn) ((imp)->logical_block_size) 1661541Srgrimes#define iso_lblktosize(imp, blk) ((blk) << (imp)->im_bshift) 1671541Srgrimes 1681541Srgrimesint cd9660_mount __P((struct mount *, 1691541Srgrimes char *, caddr_t, struct nameidata *, struct proc *)); 1701541Srgrimesint cd9660_start __P((struct mount *, int, struct proc *)); 1711541Srgrimesint cd9660_unmount __P((struct mount *, int, struct proc *)); 1721541Srgrimesint cd9660_root __P((struct mount *, struct vnode **)); 1731541Srgrimesint cd9660_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *)); 1741541Srgrimesint cd9660_statfs __P((struct mount *, struct statfs *, struct proc *)); 1751541Srgrimesint cd9660_sync __P((struct mount *, int, struct ucred *, struct proc *)); 1761541Srgrimesint cd9660_vget __P((struct mount *, ino_t, struct vnode **)); 1771541Srgrimesint cd9660_fhtovp __P((struct mount *, struct fid *, struct mbuf *, 1781541Srgrimes struct vnode **, int *, struct ucred **)); 1791541Srgrimesint cd9660_vptofh __P((struct vnode *, struct fid *)); 1801541Srgrimesint cd9660_init __P(()); 1811541Srgrimes 1821541Srgrimesstruct iso_node; 1831541Srgrimesint iso_blkatoff __P((struct iso_node *ip, long offset, struct buf **bpp)); 1841541Srgrimesint iso_iget __P((struct iso_node *xp, ino_t ino, int relocated, 1851541Srgrimes struct iso_node **ipp, struct iso_directory_record *isodir)); 1861541Srgrimesint iso_iput __P((struct iso_node *ip)); 1871541Srgrimesint iso_ilock __P((struct iso_node *ip)); 1881541Srgrimesint iso_iunlock __P((struct iso_node *ip)); 1891541Srgrimesint cd9660_mountroot __P((void)); 1901541Srgrimes 1911541Srgrimesextern int (**cd9660_vnodeop_p)(); 1921541Srgrimes 1931541Srgrimesextern inline int 1941541Srgrimesisonum_711(p) 1951541Srgrimes unsigned char *p; 1961541Srgrimes{ 1971541Srgrimes return *p; 1981541Srgrimes} 1991541Srgrimes 2001541Srgrimesextern inline int 2011541Srgrimesisonum_712(p) 2021541Srgrimes char *p; 2031541Srgrimes{ 2041541Srgrimes return *p; 2051541Srgrimes} 2061541Srgrimes 2071541Srgrimesextern inline int 2081541Srgrimesisonum_721(p) 2091541Srgrimes unsigned char *p; 2101541Srgrimes{ 2111541Srgrimes return *p|((char)p[1] << 8); 2121541Srgrimes} 2131541Srgrimes 2141541Srgrimesextern inline int 2151541Srgrimesisonum_722(p) 2161541Srgrimes unsigned char *p; 2171541Srgrimes{ 2181541Srgrimes return ((char)*p << 8)|p[1]; 2191541Srgrimes} 2201541Srgrimes 2211541Srgrimesextern inline int 2221541Srgrimesisonum_723(p) 2231541Srgrimes unsigned char *p; 2241541Srgrimes{ 2251541Srgrimes return isonum_721(p); 2261541Srgrimes} 2271541Srgrimes 2281541Srgrimesextern inline int 2291541Srgrimesisonum_731(p) 2301541Srgrimes unsigned char *p; 2311541Srgrimes{ 2321541Srgrimes return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24); 2331541Srgrimes} 2341541Srgrimes 2351541Srgrimesextern inline int 2361541Srgrimesisonum_732(p) 2371541Srgrimes unsigned char *p; 2381541Srgrimes{ 2391541Srgrimes return (*p << 24)|(p[1] << 16)|(p[2] << 8)|p[3]; 2401541Srgrimes} 2411541Srgrimes 2421541Srgrimesextern inline int 2431541Srgrimesisonum_733(p) 2441541Srgrimes unsigned char *p; 2451541Srgrimes{ 2461541Srgrimes return isonum_731(p); 2471541Srgrimes} 2481541Srgrimes 2491541Srgrimesint isofncmp __P((unsigned char *, int, unsigned char *, int)); 2501541Srgrimesvoid isofntrans __P((unsigned char *, int, unsigned char *, unsigned short *, 2511541Srgrimes int, int)); 2521541Srgrimes 2531541Srgrimes/* 2541541Srgrimes * Associated files have a leading '='. 2551541Srgrimes */ 2561541Srgrimes#define ASSOCCHAR '=' 257