1 /* 2 Copyright (C) 2003, 2004, 2005, 2006, 2008, 2012 3 Rocky Bernstein <rocky@gnu.org> 4 Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> 5 6 See also iso9660.h by Eric Youngdale (1993) and in cdrtools. These are 7 8 Copyright 1993 Yggdrasil Computing, Incorporated 9 Copyright (c) 1999,2000 J. Schilling 10 11 This program is free software: you can redistribute it and/or modify 12 it under the terms of the GNU General Public License as published by 13 the Free Software Foundation, either version 3 of the License, or 14 (at your option) any later version. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License for more details. 20 21 You should have received a copy of the GNU General Public License 22 along with this program. If not, see <http://www.gnu.org/licenses/>. 23 */ 24 /*! 25 \file xa.h 26 \brief Things related to the ISO-9660 XA (Extended Attributes) format 27 28 Applications will probably not include this directly but via 29 the iso9660.h header. 30 */ 31 32 33 #ifndef CDIO_XA_H_ 34 #define CDIO_XA_H_ 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif /* __cplusplus */ 39 40 /*! An enumeration for some of the XA_* \#defines below. This isn't 41 really an enumeration one would really use in a program it is to 42 be helpful in debuggers where wants just to refer to the XA_* 43 names and get something. 44 */ 45 typedef enum { 46 ISO_XA_MARKER_OFFSET = 1024, 47 XA_PERM_RSYS = 0x0001, /**< System Group Read */ 48 XA_PERM_XSYS = 0x0004, /**< System Group Execute */ 49 50 XA_PERM_RUSR = 0x0010, /**< User (owner) Read */ 51 XA_PERM_XUSR = 0x0040, /**< User (owner) Execute */ 52 53 XA_PERM_RGRP = 0x0100, /**< Group Read */ 54 XA_PERM_XGRP = 0x0400, /**< Group Execute */ 55 56 XA_PERM_ROTH = 0x1000, /**< Other (world) Read */ 57 XA_PERM_XOTH = 0x4000, /**< Other (world) Execute */ 58 59 XA_ATTR_MODE2FORM1 = (1 << 11), 60 XA_ATTR_MODE2FORM2 = (1 << 12), 61 XA_ATTR_INTERLEAVED = (1 << 13), 62 XA_ATTR_CDDA = (1 << 14), 63 XA_ATTR_DIRECTORY = (1 << 15), 64 65 XA_PERM_ALL_READ = (XA_PERM_RUSR | XA_PERM_RSYS | XA_PERM_RGRP), 66 XA_PERM_ALL_EXEC = (XA_PERM_XUSR | XA_PERM_XSYS | XA_PERM_XGRP), 67 XA_PERM_ALL_ALL = (XA_PERM_ALL_READ | XA_PERM_ALL_EXEC), 68 69 XA_FORM1_DIR = (XA_ATTR_DIRECTORY | XA_ATTR_MODE2FORM1 | XA_PERM_ALL_ALL), 70 XA_FORM1_FILE = (XA_ATTR_MODE2FORM1 | XA_PERM_ALL_ALL), 71 XA_FORM2_FILE = (XA_ATTR_MODE2FORM2 | XA_PERM_ALL_ALL) 72 } xa_misc_enum_t; 73 74 extern const char ISO_XA_MARKER_STRING[sizeof("CD-XA001")-1]; 75 76 #define ISO_XA_MARKER_STRING "CD-XA001" 77 78 /*! \brief "Extended Architecture" according to the Philips Yellow Book. 79 80 CD-ROM EXtended Architecture is a modification to the CD-ROM 81 specification that defines two new types of sectors. CD-ROM XA was 82 developed jointly by Sony, Philips, and Microsoft, and announced in 83 August 1988. Its specifications were published in an extension to the 84 Yellow Book. CD-i, Photo CD, Video CD and CD-EXTRA have all 85 subsequently been based on CD-ROM XA. 86 87 CD-XA defines another way of formatting sectors on a CD-ROM, including 88 headers in the sectors that describe the type (audio, video, data) and 89 some additional info (markers, resolution in case of a video or audio 90 sector, file numbers, etc). 91 92 The data written on a CD-XA is consistent with and can be in ISO-9660 93 file system format and therefore be readable by ISO-9660 file system 94 translators. But also a CD-I player can also read CD-XA discs even if 95 its own `Green Book' file system only resembles ISO 9660 and isn't 96 fully compatible. 97 98 Note structure is big-endian. 99 */ 100 typedef struct iso9660_xa_s 101 { 102 uint16_t group_id; /**< 0 */ 103 uint16_t user_id; /**< 0 */ 104 uint16_t attributes; /**< XA_ATTR_ */ 105 char signature[2]; /**< { 'X', 'A' } */ 106 uint8_t filenum; /**< file number, see also XA subheader */ 107 uint8_t reserved[5]; /**< zero */ 108 } GNUC_PACKED iso9660_xa_t; 109 110 111 /*! 112 Returns POSIX mode bitstring for a given file. 113 */ 114 posix_mode_t iso9660_get_posix_filemode_from_xa(uint16_t i_perms); 115 116 /*! 117 Returns a string interpreting the extended attribute xa_attr. 118 For example: 119 \verbatim 120 d---1xrxrxr 121 ---2--r-r-r 122 -a--1xrxrxr 123 \endverbatim 124 125 A description of the characters in the string follows. 126 The 1st character is either "d" if the entry is a directory, or "-" if not 127 The 2nd character is either "a" if the entry is CDDA (audio), or "-" if not 128 The 3rd character is either "i" if the entry is interleaved, or "-" if not 129 The 4th character is either "2" if the entry is mode2 form2 or "-" if not 130 The 5th character is either "1" if the entry is mode2 form1 or "-" if not 131 Note that an entry will either be in mode2 form1 or mode form2. That 132 is you will either see "2-" or "-1" in the 4th & 5th positions. 133 134 The 6th and 7th characters refer to permissions for a user while the 135 the 8th and 9th characters refer to permissions for a group while, and 136 the 10th and 11th characters refer to permissions for everyone. 137 138 In each of these pairs the first character (6, 8, 10) is "x" if the 139 entry is executable. For a directory this means the directory is 140 allowed to be listed or "searched". 141 The second character of a pair (7, 9, 11) is "r" if the entry is allowed 142 to be read. 143 */ 144 const char * 145 iso9660_get_xa_attr_str (uint16_t xa_attr); 146 147 /*! 148 Allocates and initalizes a new iso9600_xa_t variable and returns 149 it. The caller must free the returned result using iso9660_xa_free(). 150 151 @see iso9660_xa 152 */ 153 iso9660_xa_t * 154 iso9660_xa_init (iso9660_xa_t *_xa, uint16_t uid, uint16_t gid, uint16_t attr, 155 uint8_t filenum); 156 157 /*! 158 Frees the passed iso9600_xa_t structure. 159 160 @see iso9660_xa 161 */ 162 void 163 iso9660_xa_free (iso9660_xa_t *_xa); 164 165 #ifdef __cplusplus 166 } 167 168 /** The below variables are trickery to force the above enum symbol 169 values to be recorded in debug symbol tables. They are used to 170 allow one to refer to the enumeration value names in the typedefs 171 above in a debugger and debugger expressions. 172 */ 173 extern xa_misc_enum_t debugger_xa_misc_enum; 174 175 176 #endif /* __cplusplus */ 177 178 #endif /* CDIO_XA_H_ */ 179 180 /* 181 * Local variables: 182 * c-file-style: "gnu" 183 * tab-width: 8 184 * indent-tabs-mode: nil 185 * End: 186 */ 187