1 /* $NetBSD: iso9660_rrip.h,v 1.5 2009/01/10 22:06:29 bjh21 Exp $ */ 2 3 /* 4 * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan 5 * Perez-Rathke and Ram Vedam. All rights reserved. 6 * 7 * This code was written by Daniel Watt, Walter Deignan, Ryan Gabrys, 8 * Alan Perez-Rathke and Ram Vedam. 9 * 10 * Redistribution and use in source and binary forms, with or 11 * without modification, are permitted provided that the following 12 * conditions are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above 16 * copyright notice, this list of conditions and the following 17 * disclaimer in the documentation and/or other materials provided 18 * with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY DANIEL WATT, WALTER DEIGNAN, RYAN 21 * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 * DISCLAIMED. IN NO EVENT SHALL DANIEL WATT, WALTER DEIGNAN, RYAN 25 * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 28 * USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 * OF SUCH DAMAGE. 33 * 34 * $FreeBSD$ 35 */ 36 #ifndef __ISO9660_RRIP_H__ 37 #define __ISO9660_RRIP_H__ 38 39 /* 40 * This will hold all the functions needed to 41 * write an ISO 9660 image with Rock Ridge Extensions 42 */ 43 44 /* For writing must use ISO_RRIP_EXTREF structure */ 45 46 #include "makefs.h" 47 #include <cd9660_rrip.h> 48 #include "cd9660.h" 49 #include <sys/queue.h> 50 51 #define PX_LENGTH 0x2C 52 #define PN_LENGTH 0x14 53 #define TF_CREATION 0x00 54 #define TF_MODIFY 0x01 55 #define TF_ACCESS 0x02 56 #define TF_ATTRIBUTES 0x04 57 #define TF_BACKUP 0x08 58 #define TF_EXPIRATION 0x10 59 #define TF_EFFECTIVE 0x20 60 #define TF_LONGFORM 0x40 61 #define NM_CONTINUE 0x80 62 #define NM_CURRENT 0x100 63 #define NM_PARENT 0x200 64 65 66 #define SUSP_LOC_ENTRY 0x01 67 #define SUSP_LOC_DOT 0x02 68 #define SUSP_LOC_DOTDOT 0x04 69 70 #define SUSP_TYPE_SUSP 1 71 #define SUSP_TYPE_RRIP 2 72 73 #define SUSP_ENTRY_SUSP_CE 1 74 #define SUSP_ENTRY_SUSP_PD 2 75 #define SUSP_ENTRY_SUSP_SP 3 76 #define SUSP_ENTRY_SUSP_ST 4 77 #define SUSP_ENTRY_SUSP_ER 5 78 #define SUSP_ENTRY_SUSP_ES 6 79 80 #define SUSP_ENTRY_RRIP_PX 1 81 #define SUSP_ENTRY_RRIP_PN 2 82 #define SUSP_ENTRY_RRIP_SL 3 83 #define SUSP_ENTRY_RRIP_NM 4 84 #define SUSP_ENTRY_RRIP_CL 5 85 #define SUSP_ENTRY_RRIP_PL 6 86 #define SUSP_ENTRY_RRIP_RE 7 87 #define SUSP_ENTRY_RRIP_TF 8 88 #define SUSP_ENTRY_RRIP_SF 9 89 90 #define SUSP_RRIP_ER_EXT_ID "IEEE_P1282" 91 #define SUSP_RRIP_ER_EXT_DES "THE IEEE P1282 PROTOCOL PROVIDES SUPPORT FOR POSIX FILE SYSTEM SEMANTICS." 92 #define SUSP_RRIP_ER_EXT_SRC "PLEASE CONTACT THE IEEE STANDARDS DEPARTMENT, PISCATAWAY, NJ, USA FOR THE P1282 SPECIFICATION." 93 94 #define SL_FLAGS_NONE 0 95 #define SL_FLAGS_CONTINUE 1 96 #define SL_FLAGS_CURRENT 2 97 #define SL_FLAGS_PARENT 4 98 #define SL_FLAGS_ROOT 8 99 100 typedef struct { 101 ISO_SUSP_HEADER h; 102 u_char mode [ISODCL(5,12)]; 103 u_char links [ISODCL(13,20)]; 104 u_char uid [ISODCL(21,28)]; 105 u_char gid [ISODCL(29,36)]; 106 u_char serial [ISODCL(37,44)]; 107 } ISO_RRIP_PX; 108 109 typedef struct { 110 ISO_SUSP_HEADER h; 111 u_char high [ISODCL(5,12)]; 112 u_char low [ISODCL(13,20)]; 113 } ISO_RRIP_PN; 114 115 typedef struct { 116 ISO_SUSP_HEADER h; 117 u_char flags [ISODCL ( 4, 4)]; 118 u_char component [ISODCL ( 4, 256)]; 119 u_int nBytes; 120 } ISO_RRIP_SL; 121 122 typedef struct { 123 ISO_SUSP_HEADER h; 124 u_char flags [ISODCL ( 4, 4)]; 125 u_char timestamp [ISODCL ( 5, 256)]; 126 } ISO_RRIP_TF; 127 128 #define RRIP_NM_FLAGS_NONE 0x00 129 #define RRIP_NM_FLAGS_CONTINUE 0x01 130 #define RRIP_NM_FLAGS_CURRENT 0x02 131 #define RRIP_NM_FLAGS_PARENT 0x04 132 133 typedef struct { 134 ISO_SUSP_HEADER h; 135 u_char flags [ISODCL ( 4, 4)]; 136 u_char altname [ISODCL ( 4, 256)]; 137 } ISO_RRIP_NM; 138 139 /* Note that this is the same structure as cd9660_rrip.h : ISO_RRIP_CONT */ 140 typedef struct { 141 ISO_SUSP_HEADER h; 142 u_char ca_sector [ISODCL ( 5, 12)]; 143 u_char offset [ISODCL ( 13, 20)]; 144 u_char length [ISODCL ( 21, 28)]; 145 } ISO_SUSP_CE; 146 147 typedef struct { 148 ISO_SUSP_HEADER h; 149 u_char padding_area [ISODCL ( 4, 256)]; 150 } ISO_SUSP_PD; 151 152 typedef struct { 153 ISO_SUSP_HEADER h; 154 u_char check [ISODCL ( 4, 5)]; 155 u_char len_skp [ISODCL ( 6, 6)]; 156 } ISO_SUSP_SP; 157 158 typedef struct { 159 ISO_SUSP_HEADER h; 160 } ISO_SUSP_ST; 161 162 typedef struct { 163 ISO_SUSP_HEADER h; 164 u_char len_id [ISODCL ( 4, 4)]; 165 u_char len_des [ISODCL ( 5, 5)]; 166 u_char len_src [ISODCL ( 6, 6)]; 167 u_char ext_ver [ISODCL ( 7, 7)]; 168 u_char ext_data [ISODCL (8,256)]; 169 /* u_char ext_id [ISODCL ( 8, 256)]; 170 u_char ext_des [ISODCL ( 257, 513)]; 171 u_char ext_src [ISODCL ( 514, 770)];*/ 172 } ISO_SUSP_ER; 173 174 typedef struct { 175 ISO_SUSP_HEADER h; 176 u_char ext_seq [ISODCL ( 4, 4)]; 177 } ISO_SUSP_ES; 178 179 typedef union { 180 ISO_RRIP_PX PX; 181 ISO_RRIP_PN PN; 182 ISO_RRIP_SL SL; 183 ISO_RRIP_NM NM; 184 ISO_RRIP_CLINK CL; 185 ISO_RRIP_PLINK PL; 186 ISO_RRIP_RELDIR RE; 187 ISO_RRIP_TF TF; 188 } rrip_entry; 189 190 typedef union { 191 ISO_SUSP_CE CE; 192 ISO_SUSP_PD PD; 193 ISO_SUSP_SP SP; 194 ISO_SUSP_ST ST; 195 ISO_SUSP_ER ER; 196 ISO_SUSP_ES ES; 197 } susp_entry; 198 199 typedef union { 200 susp_entry su_entry; 201 rrip_entry rr_entry; 202 } SUSP_ENTRIES; 203 204 struct ISO_SUSP_ATTRIBUTES { 205 SUSP_ENTRIES attr; 206 int type; 207 char type_of[2]; 208 char last_in_suf; /* last entry in the System Use Field? */ 209 /* Dan's addons - will merge later. This allows use of a switch */ 210 char susp_type; /* SUSP or RRIP */ 211 char entry_type; /* Record type */ 212 char write_location; 213 TAILQ_ENTRY(ISO_SUSP_ATTRIBUTES) rr_ll; 214 }; 215 216 #define CD9660_SUSP_ENTRY_SIZE(entry)\ 217 ((int) ((entry)->attr.su_entry.SP.h.length[0])) 218 219 /* Recursive function - move later to func pointer code*/ 220 int cd9660_susp_finalize(cd9660node *); 221 222 /* These two operate on single nodes */ 223 int cd9660_susp_finalize_node(cd9660node *); 224 int cd9660_rrip_finalize_node(cd9660node *); 225 226 /* POSIX File attribute */ 227 int cd9660node_rrip_px(struct ISO_SUSP_ATTRIBUTES *, fsnode *); 228 229 /* Device number */ 230 int cd9660node_rrip_pn(struct ISO_SUSP_ATTRIBUTES *, fsnode *); 231 232 /* Symbolic link */ 233 int cd9660node_rrip_SL(struct ISO_SUSP_ATTRIBUTES *, fsnode *); 234 235 /* Alternate Name function */ 236 void cd9660_rrip_NM(cd9660node *); 237 void cd9660_rrip_add_NM(cd9660node *,const char *); 238 239 /* Parent and child link function */ 240 int cd9660_rrip_PL(struct ISO_SUSP_ATTRIBUTES *, cd9660node *); 241 int cd9660_rrip_CL(struct ISO_SUSP_ATTRIBUTES *, cd9660node *); 242 int cd9660_rrip_RE(struct ISO_SUSP_ATTRIBUTES *, cd9660node *); 243 244 int cd9660node_rrip_tf(struct ISO_SUSP_ATTRIBUTES *, fsnode *); 245 246 247 248 /* 249 * Relocation directory function. I'm not quite sure what 250 * sort of parameters are needed, but personally I don't think 251 * any parameters are needed except for the memory address where 252 * the information needs to be put in 253 */ 254 int cd9660node_rrip_re(void *, fsnode *); 255 256 /* 257 * Don't know if this function is needed because it apparently is an 258 * optional feature that does not really need to be implemented but I 259 * thought I should add it anyway. 260 */ 261 int cd9660_susp_ce (struct ISO_SUSP_ATTRIBUTES *, cd9660node *); 262 int cd9660_susp_pd (struct ISO_SUSP_ATTRIBUTES *, int); 263 int cd9660_susp_sp (struct ISO_SUSP_ATTRIBUTES *, cd9660node *); 264 int cd9660_susp_st (struct ISO_SUSP_ATTRIBUTES *, cd9660node *); 265 266 struct ISO_SUSP_ATTRIBUTES *cd9660_susp_ER(cd9660node *, u_char, const char *, 267 const char *, const char *); 268 struct ISO_SUSP_ATTRIBUTES *cd9660_susp_ES(struct ISO_SUSP_ATTRIBUTES*, 269 cd9660node *); 270 271 272 /* Helper functions */ 273 274 /* Common SUSP/RRIP functions */ 275 int cd9660_susp_initialize(cd9660node *, cd9660node *, cd9660node *); 276 int cd9660_susp_initialize_node(cd9660node *); 277 struct ISO_SUSP_ATTRIBUTES *cd9660node_susp_create_node(int, int, const char *, 278 int); 279 struct ISO_SUSP_ATTRIBUTES *cd9660node_susp_add_entry(cd9660node *, 280 struct ISO_SUSP_ATTRIBUTES *, struct ISO_SUSP_ATTRIBUTES *, int); 281 282 /* RRIP specific functions */ 283 int cd9660_rrip_initialize_node(cd9660node *, cd9660node *, cd9660node *); 284 void cd9660_createSL(cd9660node *); 285 286 /* Functions that probably can be removed */ 287 /* int cd9660node_initialize_node(int, char *); */ 288 289 290 #endif 291