17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * ISO 9660 filesystem backend for GRUB (GRand Unified Bootloader) 37c478bd9Sstevel@tonic-gate * including Rock Ridge Extensions support 47c478bd9Sstevel@tonic-gate * 57c478bd9Sstevel@tonic-gate * Copyright (C) 1998, 1999 Kousuke Takai <tak@kmc.kyoto-u.ac.jp> 67c478bd9Sstevel@tonic-gate * 77c478bd9Sstevel@tonic-gate * This program is free software; you can redistribute it and/or modify 87c478bd9Sstevel@tonic-gate * it under the terms of the GNU General Public License as published by 97c478bd9Sstevel@tonic-gate * the Free Software Foundation; either version 2 of the License, or 107c478bd9Sstevel@tonic-gate * (at your option) any later version. 117c478bd9Sstevel@tonic-gate * 127c478bd9Sstevel@tonic-gate * This program is distributed in the hope that it will be useful, 137c478bd9Sstevel@tonic-gate * but WITHOUT ANY WARRANTY; without even the implied warranty of 147c478bd9Sstevel@tonic-gate * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 157c478bd9Sstevel@tonic-gate * GNU General Public License for more details. 167c478bd9Sstevel@tonic-gate * 177c478bd9Sstevel@tonic-gate * You should have received a copy of the GNU General Public License 187c478bd9Sstevel@tonic-gate * along with this program; if not, write to the Free Software 197c478bd9Sstevel@tonic-gate * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 227c478bd9Sstevel@tonic-gate * References: 237c478bd9Sstevel@tonic-gate * linux/fs/isofs/rock.[ch] 247c478bd9Sstevel@tonic-gate * mkisofs-1.11.1/diag/isoinfo.c 257c478bd9Sstevel@tonic-gate * mkisofs-1.11.1/iso9660.h 267c478bd9Sstevel@tonic-gate * (all are written by Eric Youngdale) 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _ISO9660_H_ 307c478bd9Sstevel@tonic-gate #define _ISO9660_H_ 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #define ISO_SECTOR_BITS (11) 337c478bd9Sstevel@tonic-gate #define ISO_SECTOR_SIZE (1<<ISO_SECTOR_BITS) 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #define ISO_REGULAR 1 /* regular file */ 367c478bd9Sstevel@tonic-gate #define ISO_DIRECTORY 2 /* directory */ 377c478bd9Sstevel@tonic-gate #define ISO_OTHER 0 /* other file (with Rock Ridge) */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #define RR_FLAG_PX 0x01 /* have POSIX file attributes */ 407c478bd9Sstevel@tonic-gate #define RR_FLAG_PN 0x02 /* POSIX devices */ 417c478bd9Sstevel@tonic-gate #define RR_FLAG_SL 0x04 /* Symbolic link */ 427c478bd9Sstevel@tonic-gate #define RR_FLAG_NM 0x08 /* have alternate file name */ 437c478bd9Sstevel@tonic-gate #define RR_FLAG_CL 0x10 /* Child link */ 447c478bd9Sstevel@tonic-gate #define RR_FLAG_PL 0x20 /* Parent link */ 457c478bd9Sstevel@tonic-gate #define RR_FLAG_RE 0x40 /* Relocation directory */ 467c478bd9Sstevel@tonic-gate #define RR_FLAG_TF 0x80 /* Timestamps */ 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* POSIX file attributes for Rock Ridge extensions */ 497c478bd9Sstevel@tonic-gate #define POSIX_S_IFMT 0xF000 507c478bd9Sstevel@tonic-gate #define POSIX_S_IFREG 0x8000 517c478bd9Sstevel@tonic-gate #define POSIX_S_IFDIR 0x4000 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* volume descriptor types */ 547c478bd9Sstevel@tonic-gate #define ISO_VD_PRIMARY 1 557c478bd9Sstevel@tonic-gate #define ISO_VD_END 255 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate #define ISO_STANDARD_ID "CD001" 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #ifndef ASM_FILE 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate #ifndef __sun 627c478bd9Sstevel@tonic-gate #ifndef __BIT_TYPES_DEFINED__ 637c478bd9Sstevel@tonic-gate typedef int int8_t __attribute__((mode(QI))); 647c478bd9Sstevel@tonic-gate typedef unsigned int u_int8_t __attribute__((mode(QI))); 657c478bd9Sstevel@tonic-gate typedef int int16_t __attribute__((mode(HI))); 667c478bd9Sstevel@tonic-gate typedef unsigned int u_int16_t __attribute__((mode(HI))); 677c478bd9Sstevel@tonic-gate typedef int int32_t __attribute__((mode(SI))); 687c478bd9Sstevel@tonic-gate typedef unsigned int u_int32_t __attribute__((mode(SI))); 697c478bd9Sstevel@tonic-gate #endif 707c478bd9Sstevel@tonic-gate #else 717c478bd9Sstevel@tonic-gate #ifndef GRUB_UTIL 727c478bd9Sstevel@tonic-gate typedef char int8_t; 737c478bd9Sstevel@tonic-gate typedef short int16_t; 747c478bd9Sstevel@tonic-gate typedef int int32_t; 757c478bd9Sstevel@tonic-gate #endif /* ! GRUB_UTIL */ 767c478bd9Sstevel@tonic-gate typedef unsigned char u_int8_t; 777c478bd9Sstevel@tonic-gate typedef unsigned short u_int16_t; 787c478bd9Sstevel@tonic-gate typedef unsigned int u_int32_t; 797c478bd9Sstevel@tonic-gate #endif /* __sun */ 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate typedef union { 827c478bd9Sstevel@tonic-gate u_int8_t l,b; 837c478bd9Sstevel@tonic-gate } iso_8bit_t; 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate struct __iso_16bit { 867c478bd9Sstevel@tonic-gate u_int16_t l, b; 877c478bd9Sstevel@tonic-gate } __attribute__ ((packed)); 887c478bd9Sstevel@tonic-gate typedef struct __iso_16bit iso_16bit_t; 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate struct __iso_32bit { 917c478bd9Sstevel@tonic-gate u_int32_t l, b; 927c478bd9Sstevel@tonic-gate } __attribute__ ((packed)); 937c478bd9Sstevel@tonic-gate typedef struct __iso_32bit iso_32bit_t; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate typedef u_int8_t iso_date_t[7]; 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate struct iso_directory_record { 987c478bd9Sstevel@tonic-gate iso_8bit_t length; 997c478bd9Sstevel@tonic-gate iso_8bit_t ext_attr_length; 1007c478bd9Sstevel@tonic-gate iso_32bit_t extent; 1017c478bd9Sstevel@tonic-gate iso_32bit_t size; 1027c478bd9Sstevel@tonic-gate iso_date_t date; 1037c478bd9Sstevel@tonic-gate iso_8bit_t flags; 1047c478bd9Sstevel@tonic-gate iso_8bit_t file_unit_size; 1057c478bd9Sstevel@tonic-gate iso_8bit_t interleave; 1067c478bd9Sstevel@tonic-gate iso_16bit_t volume_seq_number; 1077c478bd9Sstevel@tonic-gate iso_8bit_t name_len; 1087c478bd9Sstevel@tonic-gate u_int8_t name[1]; 1097c478bd9Sstevel@tonic-gate } __attribute__ ((packed)); 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate struct iso_primary_descriptor { 1127c478bd9Sstevel@tonic-gate iso_8bit_t type; 1137c478bd9Sstevel@tonic-gate u_int8_t id[5]; 1147c478bd9Sstevel@tonic-gate iso_8bit_t version; 1157c478bd9Sstevel@tonic-gate u_int8_t _unused1[1]; 1167c478bd9Sstevel@tonic-gate u_int8_t system_id[32]; 1177c478bd9Sstevel@tonic-gate u_int8_t volume_id[32]; 1187c478bd9Sstevel@tonic-gate u_int8_t _unused2[8]; 1197c478bd9Sstevel@tonic-gate iso_32bit_t volume_space_size; 1207c478bd9Sstevel@tonic-gate u_int8_t _unused3[32]; 1217c478bd9Sstevel@tonic-gate iso_16bit_t volume_set_size; 1227c478bd9Sstevel@tonic-gate iso_16bit_t volume_seq_number; 1237c478bd9Sstevel@tonic-gate iso_16bit_t logical_block_size; 1247c478bd9Sstevel@tonic-gate iso_32bit_t path_table_size; 1257c478bd9Sstevel@tonic-gate u_int8_t type_l_path_table[4]; 1267c478bd9Sstevel@tonic-gate u_int8_t opt_type_l_path_table[4]; 1277c478bd9Sstevel@tonic-gate u_int8_t type_m_path_table[4]; 1287c478bd9Sstevel@tonic-gate u_int8_t opt_type_m_path_table[4]; 1297c478bd9Sstevel@tonic-gate struct iso_directory_record root_directory_record; 1307c478bd9Sstevel@tonic-gate u_int8_t volume_set_id[128]; 1317c478bd9Sstevel@tonic-gate u_int8_t publisher_id[128]; 1327c478bd9Sstevel@tonic-gate u_int8_t preparer_id[128]; 1337c478bd9Sstevel@tonic-gate u_int8_t application_id[128]; 1347c478bd9Sstevel@tonic-gate u_int8_t copyright_file_id[37]; 1357c478bd9Sstevel@tonic-gate u_int8_t abstract_file_id[37]; 1367c478bd9Sstevel@tonic-gate u_int8_t bibliographic_file_id[37]; 1377c478bd9Sstevel@tonic-gate u_int8_t creation_date[17]; 1387c478bd9Sstevel@tonic-gate u_int8_t modification_date[17]; 1397c478bd9Sstevel@tonic-gate u_int8_t expiration_date[17]; 1407c478bd9Sstevel@tonic-gate u_int8_t effective_date[17]; 1417c478bd9Sstevel@tonic-gate iso_8bit_t file_structure_version; 1427c478bd9Sstevel@tonic-gate u_int8_t _unused4[1]; 1437c478bd9Sstevel@tonic-gate u_int8_t application_data[512]; 1447c478bd9Sstevel@tonic-gate u_int8_t _unused5[653]; 1457c478bd9Sstevel@tonic-gate } __attribute__ ((packed)); 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate struct rock_ridge { 1487c478bd9Sstevel@tonic-gate u_int16_t signature; 1497c478bd9Sstevel@tonic-gate u_int8_t len; 1507c478bd9Sstevel@tonic-gate u_int8_t version; 1517c478bd9Sstevel@tonic-gate union { 1527c478bd9Sstevel@tonic-gate struct SP { 1537c478bd9Sstevel@tonic-gate u_int16_t magic; 1547c478bd9Sstevel@tonic-gate u_int8_t skip; 1557c478bd9Sstevel@tonic-gate } sp; 1567c478bd9Sstevel@tonic-gate struct CE { 1577c478bd9Sstevel@tonic-gate iso_32bit_t extent; 1587c478bd9Sstevel@tonic-gate iso_32bit_t offset; 1597c478bd9Sstevel@tonic-gate iso_32bit_t size; 1607c478bd9Sstevel@tonic-gate } ce; 1617c478bd9Sstevel@tonic-gate struct ER { 1627c478bd9Sstevel@tonic-gate u_int8_t len_id; 1637c478bd9Sstevel@tonic-gate u_int8_t len_des; 1647c478bd9Sstevel@tonic-gate u_int8_t len_src; 1657c478bd9Sstevel@tonic-gate u_int8_t ext_ver; 1667c478bd9Sstevel@tonic-gate u_int8_t data[0]; 1677c478bd9Sstevel@tonic-gate } er; 1687c478bd9Sstevel@tonic-gate struct RR { 1697c478bd9Sstevel@tonic-gate iso_8bit_t flags; 1707c478bd9Sstevel@tonic-gate } rr; 1717c478bd9Sstevel@tonic-gate struct PX { 1727c478bd9Sstevel@tonic-gate iso_32bit_t mode; 1737c478bd9Sstevel@tonic-gate iso_32bit_t nlink; 1747c478bd9Sstevel@tonic-gate iso_32bit_t uid; 1757c478bd9Sstevel@tonic-gate iso_32bit_t gid; 1767c478bd9Sstevel@tonic-gate } px; 1777c478bd9Sstevel@tonic-gate struct PN { 1787c478bd9Sstevel@tonic-gate iso_32bit_t dev_high; 1797c478bd9Sstevel@tonic-gate iso_32bit_t dev_low; 1807c478bd9Sstevel@tonic-gate } pn; 1817c478bd9Sstevel@tonic-gate struct SL { 1827c478bd9Sstevel@tonic-gate iso_8bit_t flags; 1837c478bd9Sstevel@tonic-gate struct SL_component { 1847c478bd9Sstevel@tonic-gate iso_8bit_t flags; 1857c478bd9Sstevel@tonic-gate u_int8_t len; 1867c478bd9Sstevel@tonic-gate u_int8_t text[0]; 1877c478bd9Sstevel@tonic-gate } link; 1887c478bd9Sstevel@tonic-gate } sl; 1897c478bd9Sstevel@tonic-gate struct NM { 1907c478bd9Sstevel@tonic-gate iso_8bit_t flags; 1917c478bd9Sstevel@tonic-gate u_int8_t name[0]; 1927c478bd9Sstevel@tonic-gate } nm; 1937c478bd9Sstevel@tonic-gate struct CL { 1947c478bd9Sstevel@tonic-gate iso_32bit_t location; 1957c478bd9Sstevel@tonic-gate } cl; 1967c478bd9Sstevel@tonic-gate struct PL { 1977c478bd9Sstevel@tonic-gate iso_32bit_t location; 1987c478bd9Sstevel@tonic-gate } pl; 1997c478bd9Sstevel@tonic-gate struct TF { 2007c478bd9Sstevel@tonic-gate iso_8bit_t flags; 2017c478bd9Sstevel@tonic-gate iso_date_t times[0]; 2027c478bd9Sstevel@tonic-gate } tf; 2037c478bd9Sstevel@tonic-gate } u; 2047c478bd9Sstevel@tonic-gate } __attribute__ ((packed)); 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate typedef union RR_ptr { 2077c478bd9Sstevel@tonic-gate struct rock_ridge *rr; 2087c478bd9Sstevel@tonic-gate char *ptr; 2097c478bd9Sstevel@tonic-gate int i; 2107c478bd9Sstevel@tonic-gate } RR_ptr_t; 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate #define RRMAGIC(c1, c2) ((c1)|(c2) << 8) 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate #define CHECK2(ptr, c1, c2) \ 2157c478bd9Sstevel@tonic-gate (*(unsigned short *)(ptr) == (((c1) | (c2) << 8) & 0xFFFF)) 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate #endif /* !ASM_FILE */ 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate #endif /* _ISO9660_H_ */ 220