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