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