Tue Apr 18 22:56:41 2023 UTC ()
The bit definitions for the TF_* timestamp bits (TF_MODIFY, etc.) were
incorrect, and timestamps were written in the wrong order.

See RRIP 4.1.6 Description of the "TF" System Use Entry for details.

From: https://reviews.freebsd.org/D39221


(christos)
diff -r1.14 -r1.15 src/usr.sbin/makefs/cd9660/iso9660_rrip.c
diff -r1.6 -r1.7 src/usr.sbin/makefs/cd9660/iso9660_rrip.h

cvs diff -r1.14 -r1.15 src/usr.sbin/makefs/cd9660/iso9660_rrip.c (switch to unified diff)

--- src/usr.sbin/makefs/cd9660/iso9660_rrip.c 2014/05/30 13:14:47 1.14
+++ src/usr.sbin/makefs/cd9660/iso9660_rrip.c 2023/04/18 22:56:41 1.15
@@ -1,839 +1,839 @@ @@ -1,839 +1,839 @@
1/* $NetBSD: iso9660_rrip.c,v 1.14 2014/05/30 13:14:47 martin Exp $ */ 1/* $NetBSD: iso9660_rrip.c,v 1.15 2023/04/18 22:56:41 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan 4 * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
5 * Perez-Rathke and Ram Vedam. All rights reserved. 5 * Perez-Rathke and Ram Vedam. All rights reserved.
6 * 6 *
7 * This code was written by Daniel Watt, Walter Deignan, Ryan Gabrys, 7 * This code was written by Daniel Watt, Walter Deignan, Ryan Gabrys,
8 * Alan Perez-Rathke and Ram Vedam. 8 * Alan Perez-Rathke and Ram Vedam.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or 10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following 11 * without modification, are permitted provided that the following
12 * conditions are met: 12 * conditions are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above 15 * 2. Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following 16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided 17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution. 18 * with the distribution.
19 * 19 *
20 * THIS SOFTWARE IS PROVIDED BY DANIEL WATT, WALTER DEIGNAN, RYAN 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 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 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL DANIEL WATT, WALTER DEIGNAN, RYAN 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, 25 * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 * USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 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 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 * OF SUCH DAMAGE. 32 * OF SUCH DAMAGE.
33 */ 33 */
34/* This will hold all the function definitions 34/* This will hold all the function definitions
35 * defined in iso9660_rrip.h 35 * defined in iso9660_rrip.h
36 */ 36 */
37 37
38#include "makefs.h" 38#include "makefs.h"
39#include "cd9660.h" 39#include "cd9660.h"
40#include "iso9660_rrip.h" 40#include "iso9660_rrip.h"
41#include <sys/queue.h> 41#include <sys/queue.h>
42#include <stdio.h> 42#include <stdio.h>
43#include <util.h> 43#include <util.h>
44 44
45#include <sys/cdefs.h> 45#include <sys/cdefs.h>
46#if defined(__RCSID) && !defined(__lint) 46#if defined(__RCSID) && !defined(__lint)
47__RCSID("$NetBSD: iso9660_rrip.c,v 1.14 2014/05/30 13:14:47 martin Exp $"); 47__RCSID("$NetBSD: iso9660_rrip.c,v 1.15 2023/04/18 22:56:41 christos Exp $");
48#endif /* !__lint */ 48#endif /* !__lint */
49 49
50static void cd9660_rrip_initialize_inode(cd9660node *); 50static void cd9660_rrip_initialize_inode(cd9660node *);
51static int cd9660_susp_handle_continuation(iso9660_disk *, cd9660node *); 51static int cd9660_susp_handle_continuation(iso9660_disk *, cd9660node *);
52static int cd9660_susp_handle_continuation_common(iso9660_disk *, cd9660node *, 52static int cd9660_susp_handle_continuation_common(iso9660_disk *, cd9660node *,
53 int); 53 int);
54 54
55int 55int
56cd9660_susp_initialize(iso9660_disk *diskStructure, cd9660node *node, 56cd9660_susp_initialize(iso9660_disk *diskStructure, cd9660node *node,
57 cd9660node *parent, cd9660node *grandparent) 57 cd9660node *parent, cd9660node *grandparent)
58{ 58{
59 cd9660node *cn; 59 cd9660node *cn;
60 int r; 60 int r;
61 61
62 /* Make sure the node is not NULL. If it is, there are major problems */ 62 /* Make sure the node is not NULL. If it is, there are major problems */
63 assert(node != NULL); 63 assert(node != NULL);
64 64
65 if (!(node->type & CD9660_TYPE_DOT) && 65 if (!(node->type & CD9660_TYPE_DOT) &&
66 !(node->type & CD9660_TYPE_DOTDOT)) 66 !(node->type & CD9660_TYPE_DOTDOT))
67 TAILQ_INIT(&(node->head)); 67 TAILQ_INIT(&(node->head));
68 if (node->dot_record != 0) 68 if (node->dot_record != 0)
69 TAILQ_INIT(&(node->dot_record->head)); 69 TAILQ_INIT(&(node->dot_record->head));
70 if (node->dot_dot_record != 0) 70 if (node->dot_dot_record != 0)
71 TAILQ_INIT(&(node->dot_dot_record->head)); 71 TAILQ_INIT(&(node->dot_dot_record->head));
72 72
73 /* SUSP specific entries here */ 73 /* SUSP specific entries here */
74 if ((r = cd9660_susp_initialize_node(diskStructure, node)) < 0) 74 if ((r = cd9660_susp_initialize_node(diskStructure, node)) < 0)
75 return r; 75 return r;
76 76
77 /* currently called cd9660node_rrip_init_links */ 77 /* currently called cd9660node_rrip_init_links */
78 r = cd9660_rrip_initialize_node(diskStructure, node, parent, grandparent); 78 r = cd9660_rrip_initialize_node(diskStructure, node, parent, grandparent);
79 if (r < 0) 79 if (r < 0)
80 return r; 80 return r;
81 81
82 /* 82 /*
83 * See if we need a CE record, and set all of the 83 * See if we need a CE record, and set all of the
84 * associated counters. 84 * associated counters.
85 * 85 *
86 * This should be called after all extensions. After 86 * This should be called after all extensions. After
87 * this is called, no new records should be added. 87 * this is called, no new records should be added.
88 */ 88 */
89 if ((r = cd9660_susp_handle_continuation(diskStructure, node)) < 0) 89 if ((r = cd9660_susp_handle_continuation(diskStructure, node)) < 0)
90 return r; 90 return r;
91 91
92 /* Recurse on children. */ 92 /* Recurse on children. */
93 TAILQ_FOREACH(cn, &node->cn_children, cn_next_child) { 93 TAILQ_FOREACH(cn, &node->cn_children, cn_next_child) {
94 if ((r = cd9660_susp_initialize(diskStructure, cn, node, parent)) < 0) 94 if ((r = cd9660_susp_initialize(diskStructure, cn, node, parent)) < 0)
95 return 0; 95 return 0;
96 } 96 }
97 return 1; 97 return 1;
98} 98}
99 99
100int 100int
101cd9660_susp_finalize(iso9660_disk *diskStructure, cd9660node *node) 101cd9660_susp_finalize(iso9660_disk *diskStructure, cd9660node *node)
102{ 102{
103 cd9660node *temp; 103 cd9660node *temp;
104 int r; 104 int r;
105 105
106 assert(node != NULL); 106 assert(node != NULL);
107 107
108 if (node == diskStructure->rootNode) 108 if (node == diskStructure->rootNode)
109 diskStructure->susp_continuation_area_current_free = 0; 109 diskStructure->susp_continuation_area_current_free = 0;
110 110
111 if ((r = cd9660_susp_finalize_node(diskStructure, node)) < 0) 111 if ((r = cd9660_susp_finalize_node(diskStructure, node)) < 0)
112 return r; 112 return r;
113 if ((r = cd9660_rrip_finalize_node(diskStructure, node)) < 0) 113 if ((r = cd9660_rrip_finalize_node(diskStructure, node)) < 0)
114 return r; 114 return r;
115 115
116 TAILQ_FOREACH(temp, &node->cn_children, cn_next_child) { 116 TAILQ_FOREACH(temp, &node->cn_children, cn_next_child) {
117 if ((r = cd9660_susp_finalize(diskStructure, temp)) < 0) 117 if ((r = cd9660_susp_finalize(diskStructure, temp)) < 0)
118 return r; 118 return r;
119 } 119 }
120 return 1; 120 return 1;
121} 121}
122 122
123/* 123/*
124 * If we really wanted to speed things up, we could have some sort of 124 * If we really wanted to speed things up, we could have some sort of
125 * lookup table on the SUSP entry type that calls a functor. Or, we could 125 * lookup table on the SUSP entry type that calls a functor. Or, we could
126 * combine the functions. These functions are kept separate to allow 126 * combine the functions. These functions are kept separate to allow
127 * easier addition of other extensions. 127 * easier addition of other extensions.
128 128
129 * For the sake of simplicity and clarity, we won't be doing that for now. 129 * For the sake of simplicity and clarity, we won't be doing that for now.
130 */ 130 */
131 131
132/* 132/*
133 * SUSP needs to update the following types: 133 * SUSP needs to update the following types:
134 * CE (continuation area) 134 * CE (continuation area)
135 */ 135 */
136int 136int
137cd9660_susp_finalize_node(iso9660_disk *diskStructure, cd9660node *node) 137cd9660_susp_finalize_node(iso9660_disk *diskStructure, cd9660node *node)
138{ 138{
139 struct ISO_SUSP_ATTRIBUTES *t; 139 struct ISO_SUSP_ATTRIBUTES *t;
140 140
141 /* Handle CE counters */ 141 /* Handle CE counters */
142 if (node->susp_entry_ce_length > 0) { 142 if (node->susp_entry_ce_length > 0) {
143 node->susp_entry_ce_start = 143 node->susp_entry_ce_start =
144 diskStructure->susp_continuation_area_current_free; 144 diskStructure->susp_continuation_area_current_free;
145 diskStructure->susp_continuation_area_current_free += 145 diskStructure->susp_continuation_area_current_free +=
146 node->susp_entry_ce_length; 146 node->susp_entry_ce_length;
147 } 147 }
148 148
149 TAILQ_FOREACH(t, &node->head, rr_ll) { 149 TAILQ_FOREACH(t, &node->head, rr_ll) {
150 if (t->susp_type != SUSP_TYPE_SUSP || 150 if (t->susp_type != SUSP_TYPE_SUSP ||
151 t->entry_type != SUSP_ENTRY_SUSP_CE) 151 t->entry_type != SUSP_ENTRY_SUSP_CE)
152 continue; 152 continue;
153 cd9660_bothendian_dword( 153 cd9660_bothendian_dword(
154 diskStructure-> 154 diskStructure->
155 susp_continuation_area_start_sector, 155 susp_continuation_area_start_sector,
156 t->attr.su_entry.CE.ca_sector); 156 t->attr.su_entry.CE.ca_sector);
157 157
158 cd9660_bothendian_dword( 158 cd9660_bothendian_dword(
159 diskStructure-> 159 diskStructure->
160 susp_continuation_area_start_sector, 160 susp_continuation_area_start_sector,
161 t->attr.su_entry.CE.ca_sector); 161 t->attr.su_entry.CE.ca_sector);
162 cd9660_bothendian_dword(node->susp_entry_ce_start, 162 cd9660_bothendian_dword(node->susp_entry_ce_start,
163 t->attr.su_entry.CE.offset); 163 t->attr.su_entry.CE.offset);
164 cd9660_bothendian_dword(node->susp_entry_ce_length, 164 cd9660_bothendian_dword(node->susp_entry_ce_length,
165 t->attr.su_entry.CE.length); 165 t->attr.su_entry.CE.length);
166 } 166 }
167 return 0; 167 return 0;
168} 168}
169 169
170int 170int
171cd9660_rrip_finalize_node(iso9660_disk *diskStructure __unused, 171cd9660_rrip_finalize_node(iso9660_disk *diskStructure __unused,
172 cd9660node *node) 172 cd9660node *node)
173{ 173{
174 struct ISO_SUSP_ATTRIBUTES *t; 174 struct ISO_SUSP_ATTRIBUTES *t;
175 175
176 TAILQ_FOREACH(t, &node->head, rr_ll) { 176 TAILQ_FOREACH(t, &node->head, rr_ll) {
177 if (t->susp_type != SUSP_TYPE_RRIP) 177 if (t->susp_type != SUSP_TYPE_RRIP)
178 continue; 178 continue;
179 switch (t->entry_type) { 179 switch (t->entry_type) {
180 case SUSP_ENTRY_RRIP_CL: 180 case SUSP_ENTRY_RRIP_CL:
181 /* Look at rr_relocated*/ 181 /* Look at rr_relocated*/
182 if (node->rr_relocated == NULL) 182 if (node->rr_relocated == NULL)
183 return -1; 183 return -1;
184 cd9660_bothendian_dword( 184 cd9660_bothendian_dword(
185 node->rr_relocated->fileDataSector, 185 node->rr_relocated->fileDataSector,
186 (unsigned char *) 186 (unsigned char *)
187 t->attr.rr_entry.CL.dir_loc); 187 t->attr.rr_entry.CL.dir_loc);
188 break; 188 break;
189 case SUSP_ENTRY_RRIP_PL: 189 case SUSP_ENTRY_RRIP_PL:
190 /* Look at rr_real_parent */ 190 /* Look at rr_real_parent */
191 if (node->parent == NULL || 191 if (node->parent == NULL ||
192 node->parent->rr_real_parent == NULL) 192 node->parent->rr_real_parent == NULL)
193 return -1; 193 return -1;
194 cd9660_bothendian_dword( 194 cd9660_bothendian_dword(
195 node->parent->rr_real_parent->fileDataSector, 195 node->parent->rr_real_parent->fileDataSector,
196 (unsigned char *) 196 (unsigned char *)
197 t->attr.rr_entry.PL.dir_loc); 197 t->attr.rr_entry.PL.dir_loc);
198 break; 198 break;
199 } 199 }
200 } 200 }
201 return 0; 201 return 0;
202} 202}
203 203
204static int 204static int
205cd9660_susp_handle_continuation_common(iso9660_disk *diskStructure, 205cd9660_susp_handle_continuation_common(iso9660_disk *diskStructure,
206 cd9660node *node, int space) 206 cd9660node *node, int space)
207{ 207{
208 int ca_used, susp_used, susp_used_pre_ce, working; 208 int ca_used, susp_used, susp_used_pre_ce, working;
209 struct ISO_SUSP_ATTRIBUTES *temp, *pre_ce, *last, *CE, *ST; 209 struct ISO_SUSP_ATTRIBUTES *temp, *pre_ce, *last, *CE, *ST;
210 210
211 pre_ce = last = NULL; 211 pre_ce = last = NULL;
212 working = 254 - space; 212 working = 254 - space;
213 if (node->su_tail_size > 0) 213 if (node->su_tail_size > 0)
214 /* Allow 4 bytes for "ST" record. */ 214 /* Allow 4 bytes for "ST" record. */
215 working -= node->su_tail_size + 4; 215 working -= node->su_tail_size + 4;
216 /* printf("There are %i bytes to work with\n",working); */ 216 /* printf("There are %i bytes to work with\n",working); */
217 217
218 susp_used_pre_ce = susp_used = 0; 218 susp_used_pre_ce = susp_used = 0;
219 ca_used = 0; 219 ca_used = 0;
220 TAILQ_FOREACH(temp, &node->head, rr_ll) { 220 TAILQ_FOREACH(temp, &node->head, rr_ll) {
221 if (working < 0) 221 if (working < 0)
222 break; 222 break;
223 /* 223 /*
224 * printf("SUSP Entry found, length is %i\n", 224 * printf("SUSP Entry found, length is %i\n",
225 * CD9660_SUSP_ENTRY_SIZE(temp)); 225 * CD9660_SUSP_ENTRY_SIZE(temp));
226 */ 226 */
227 working -= CD9660_SUSP_ENTRY_SIZE(temp); 227 working -= CD9660_SUSP_ENTRY_SIZE(temp);
228 if (working >= 0) { 228 if (working >= 0) {
229 last = temp; 229 last = temp;
230 susp_used += CD9660_SUSP_ENTRY_SIZE(temp); 230 susp_used += CD9660_SUSP_ENTRY_SIZE(temp);
231 } 231 }
232 if (working >= 28) { 232 if (working >= 28) {
233 /* 233 /*
234 * Remember the last entry after which we 234 * Remember the last entry after which we
235 * could insert a "CE" entry. 235 * could insert a "CE" entry.
236 */ 236 */
237 pre_ce = last; 237 pre_ce = last;
238 susp_used_pre_ce = susp_used; 238 susp_used_pre_ce = susp_used;
239 } 239 }
240 } 240 }
241 241
242 /* A CE entry is needed */ 242 /* A CE entry is needed */
243 if (working <= 0) { 243 if (working <= 0) {
244 CE = cd9660node_susp_create_node(SUSP_TYPE_SUSP, 244 CE = cd9660node_susp_create_node(SUSP_TYPE_SUSP,
245 SUSP_ENTRY_SUSP_CE, "CE", SUSP_LOC_ENTRY); 245 SUSP_ENTRY_SUSP_CE, "CE", SUSP_LOC_ENTRY);
246 cd9660_susp_ce(CE, node); 246 cd9660_susp_ce(CE, node);
247 /* This will automatically insert at the appropriate location */ 247 /* This will automatically insert at the appropriate location */
248 if (pre_ce != NULL) 248 if (pre_ce != NULL)
249 TAILQ_INSERT_AFTER(&node->head, pre_ce, CE, rr_ll); 249 TAILQ_INSERT_AFTER(&node->head, pre_ce, CE, rr_ll);
250 else 250 else
251 TAILQ_INSERT_HEAD(&node->head, CE, rr_ll); 251 TAILQ_INSERT_HEAD(&node->head, CE, rr_ll);
252 last = CE; 252 last = CE;
253 susp_used = susp_used_pre_ce + 28; 253 susp_used = susp_used_pre_ce + 28;
254 /* Count how much CA data is necessary */ 254 /* Count how much CA data is necessary */
255 for (temp = TAILQ_NEXT(last, rr_ll); temp != NULL; 255 for (temp = TAILQ_NEXT(last, rr_ll); temp != NULL;
256 temp = TAILQ_NEXT(temp, rr_ll)) { 256 temp = TAILQ_NEXT(temp, rr_ll)) {
257 ca_used += CD9660_SUSP_ENTRY_SIZE(temp); 257 ca_used += CD9660_SUSP_ENTRY_SIZE(temp);
258 } 258 }
259 } 259 }
260 260
261 /* An ST entry is needed */ 261 /* An ST entry is needed */
262 if (node->su_tail_size > 0) { 262 if (node->su_tail_size > 0) {
263 ST = cd9660node_susp_create_node(SUSP_TYPE_SUSP, 263 ST = cd9660node_susp_create_node(SUSP_TYPE_SUSP,
264 SUSP_ENTRY_SUSP_ST, "ST", SUSP_LOC_ENTRY); 264 SUSP_ENTRY_SUSP_ST, "ST", SUSP_LOC_ENTRY);
265 cd9660_susp_st(ST, node); 265 cd9660_susp_st(ST, node);
266 if (last != NULL) 266 if (last != NULL)
267 TAILQ_INSERT_AFTER(&node->head, last, ST, rr_ll); 267 TAILQ_INSERT_AFTER(&node->head, last, ST, rr_ll);
268 else 268 else
269 TAILQ_INSERT_HEAD(&node->head, ST, rr_ll); 269 TAILQ_INSERT_HEAD(&node->head, ST, rr_ll);
270 last = ST; 270 last = ST;
271 susp_used += 4; 271 susp_used += 4;
272 } 272 }
273 if (last != NULL) 273 if (last != NULL)
274 last->last_in_suf = 1; 274 last->last_in_suf = 1;
275 275
276 node->susp_entry_size = susp_used; 276 node->susp_entry_size = susp_used;
277 node->susp_entry_ce_length = ca_used; 277 node->susp_entry_ce_length = ca_used;
278 278
279 diskStructure->susp_continuation_area_size += ca_used; 279 diskStructure->susp_continuation_area_size += ca_used;
280 return 1; 280 return 1;
281} 281}
282 282
283/* See if a continuation entry is needed for each of the different types */ 283/* See if a continuation entry is needed for each of the different types */
284static int 284static int
285cd9660_susp_handle_continuation(iso9660_disk *diskStructure, cd9660node *node) 285cd9660_susp_handle_continuation(iso9660_disk *diskStructure, cd9660node *node)
286{ 286{
287 assert (node != NULL); 287 assert (node != NULL);
288 288
289 /* Entry */ 289 /* Entry */
290 if (cd9660_susp_handle_continuation_common(diskStructure, 290 if (cd9660_susp_handle_continuation_common(diskStructure,
291 node,(int)(node->isoDirRecord->length[0])) < 0) 291 node,(int)(node->isoDirRecord->length[0])) < 0)
292 return 0; 292 return 0;
293 293
294 return 1; 294 return 1;
295} 295}
296 296
297int 297int
298cd9660_susp_initialize_node(iso9660_disk *diskStructure, cd9660node *node) 298cd9660_susp_initialize_node(iso9660_disk *diskStructure, cd9660node *node)
299{ 299{
300 struct ISO_SUSP_ATTRIBUTES *temp; 300 struct ISO_SUSP_ATTRIBUTES *temp;
301 301
302 /* 302 /*
303 * Requirements/notes: 303 * Requirements/notes:
304 * CE: is added for us where needed 304 * CE: is added for us where needed
305 * ST: not sure if it is even required, but if so, should be 305 * ST: not sure if it is even required, but if so, should be
306 * handled by the CE code 306 * handled by the CE code
307 * PD: isnt needed (though might be added for testing) 307 * PD: isnt needed (though might be added for testing)
308 * SP: is stored ONLY on the . record of the root directory 308 * SP: is stored ONLY on the . record of the root directory
309 * ES: not sure 309 * ES: not sure
310 */ 310 */
311 311
312 /* Check for root directory, add SP and ER if needed. */ 312 /* Check for root directory, add SP and ER if needed. */
313 if (node->type & CD9660_TYPE_DOT) { 313 if (node->type & CD9660_TYPE_DOT) {
314 if (node->parent == diskStructure->rootNode) { 314 if (node->parent == diskStructure->rootNode) {
315 temp = cd9660node_susp_create_node(SUSP_TYPE_SUSP, 315 temp = cd9660node_susp_create_node(SUSP_TYPE_SUSP,
316 SUSP_ENTRY_SUSP_SP, "SP", SUSP_LOC_DOT); 316 SUSP_ENTRY_SUSP_SP, "SP", SUSP_LOC_DOT);
317 cd9660_susp_sp(temp, node); 317 cd9660_susp_sp(temp, node);
318 318
319 /* Should be first entry. */ 319 /* Should be first entry. */
320 TAILQ_INSERT_HEAD(&node->head, temp, rr_ll); 320 TAILQ_INSERT_HEAD(&node->head, temp, rr_ll);
321 } 321 }
322 } 322 }
323 return 1; 323 return 1;
324} 324}
325 325
326static void 326static void
327cd9660_rrip_initialize_inode(cd9660node *node) 327cd9660_rrip_initialize_inode(cd9660node *node)
328{ 328{
329 struct ISO_SUSP_ATTRIBUTES *attr; 329 struct ISO_SUSP_ATTRIBUTES *attr;
330 330
331 /* 331 /*
332 * Inode dependent values - this may change, 332 * Inode dependent values - this may change,
333 * but for now virtual files and directories do 333 * but for now virtual files and directories do
334 * not have an inode structure 334 * not have an inode structure
335 */ 335 */
336 336
337 if ((node->node != NULL) && (node->node->inode != NULL)) { 337 if ((node->node != NULL) && (node->node->inode != NULL)) {
338 /* PX - POSIX attributes */ 338 /* PX - POSIX attributes */
339 attr = cd9660node_susp_create_node(SUSP_TYPE_RRIP, 339 attr = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
340 SUSP_ENTRY_RRIP_PX, "PX", SUSP_LOC_ENTRY); 340 SUSP_ENTRY_RRIP_PX, "PX", SUSP_LOC_ENTRY);
341 cd9660node_rrip_px(attr, node->node); 341 cd9660node_rrip_px(attr, node->node);
342 342
343 TAILQ_INSERT_TAIL(&node->head, attr, rr_ll); 343 TAILQ_INSERT_TAIL(&node->head, attr, rr_ll);
344 344
345 /* TF - timestamp */ 345 /* TF - timestamp */
346 attr = cd9660node_susp_create_node(SUSP_TYPE_RRIP, 346 attr = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
347 SUSP_ENTRY_RRIP_TF, "TF", SUSP_LOC_ENTRY); 347 SUSP_ENTRY_RRIP_TF, "TF", SUSP_LOC_ENTRY);
348 cd9660node_rrip_tf(attr, node->node); 348 cd9660node_rrip_tf(attr, node->node);
349 TAILQ_INSERT_TAIL(&node->head, attr, rr_ll); 349 TAILQ_INSERT_TAIL(&node->head, attr, rr_ll);
350 350
351 /* SL - Symbolic link */ 351 /* SL - Symbolic link */
352 /* ?????????? Dan - why is this here? */ 352 /* ?????????? Dan - why is this here? */
353 if (TAILQ_EMPTY(&node->cn_children) && 353 if (TAILQ_EMPTY(&node->cn_children) &&
354 node->node->inode != NULL && 354 node->node->inode != NULL &&
355 S_ISLNK(node->node->inode->st.st_mode)) 355 S_ISLNK(node->node->inode->st.st_mode))
356 cd9660_createSL(node); 356 cd9660_createSL(node);
357 357
358 /* PN - device number */ 358 /* PN - device number */
359 if (node->node->inode != NULL && 359 if (node->node->inode != NULL &&
360 ((S_ISCHR(node->node->inode->st.st_mode) || 360 ((S_ISCHR(node->node->inode->st.st_mode) ||
361 S_ISBLK(node->node->inode->st.st_mode)))) { 361 S_ISBLK(node->node->inode->st.st_mode)))) {
362 attr = 362 attr =
363 cd9660node_susp_create_node(SUSP_TYPE_RRIP, 363 cd9660node_susp_create_node(SUSP_TYPE_RRIP,
364 SUSP_ENTRY_RRIP_PN, "PN", 364 SUSP_ENTRY_RRIP_PN, "PN",
365 SUSP_LOC_ENTRY); 365 SUSP_LOC_ENTRY);
366 cd9660node_rrip_pn(attr, node->node); 366 cd9660node_rrip_pn(attr, node->node);
367 TAILQ_INSERT_TAIL(&node->head, attr, rr_ll); 367 TAILQ_INSERT_TAIL(&node->head, attr, rr_ll);
368 } 368 }
369 } 369 }
370} 370}
371 371
372int 372int
373cd9660_rrip_initialize_node(iso9660_disk *diskStructure, cd9660node *node, 373cd9660_rrip_initialize_node(iso9660_disk *diskStructure, cd9660node *node,
374 cd9660node *parent, cd9660node *grandparent) 374 cd9660node *parent, cd9660node *grandparent)
375{ 375{
376 struct ISO_SUSP_ATTRIBUTES *current = NULL; 376 struct ISO_SUSP_ATTRIBUTES *current = NULL;
377 377
378 assert(node != NULL); 378 assert(node != NULL);
379 379
380 if (node->type & CD9660_TYPE_DOT) { 380 if (node->type & CD9660_TYPE_DOT) {
381 /* 381 /*
382 * Handle ER - should be the only entry to appear on 382 * Handle ER - should be the only entry to appear on
383 * a "." record 383 * a "." record
384 */ 384 */
385 if (node->parent == diskStructure->rootNode) { 385 if (node->parent == diskStructure->rootNode) {
386 cd9660_susp_ER(node, 1, SUSP_RRIP_ER_EXT_ID, 386 cd9660_susp_ER(node, 1, SUSP_RRIP_ER_EXT_ID,
387 SUSP_RRIP_ER_EXT_DES, SUSP_RRIP_ER_EXT_SRC); 387 SUSP_RRIP_ER_EXT_DES, SUSP_RRIP_ER_EXT_SRC);
388 } 388 }
389 if (parent != NULL && parent->node != NULL && 389 if (parent != NULL && parent->node != NULL &&
390 parent->node->inode != NULL) { 390 parent->node->inode != NULL) {
391 /* PX - POSIX attributes */ 391 /* PX - POSIX attributes */
392 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP, 392 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
393 SUSP_ENTRY_RRIP_PX, "PX", SUSP_LOC_ENTRY); 393 SUSP_ENTRY_RRIP_PX, "PX", SUSP_LOC_ENTRY);
394 cd9660node_rrip_px(current, parent->node); 394 cd9660node_rrip_px(current, parent->node);
395 TAILQ_INSERT_TAIL(&node->head, current, rr_ll); 395 TAILQ_INSERT_TAIL(&node->head, current, rr_ll);
396 } 396 }
397 } else if (node->type & CD9660_TYPE_DOTDOT) { 397 } else if (node->type & CD9660_TYPE_DOTDOT) {
398 if (grandparent != NULL && grandparent->node != NULL && 398 if (grandparent != NULL && grandparent->node != NULL &&
399 grandparent->node->inode != NULL) { 399 grandparent->node->inode != NULL) {
400 /* PX - POSIX attributes */ 400 /* PX - POSIX attributes */
401 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP, 401 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
402 SUSP_ENTRY_RRIP_PX, "PX", SUSP_LOC_ENTRY); 402 SUSP_ENTRY_RRIP_PX, "PX", SUSP_LOC_ENTRY);
403 cd9660node_rrip_px(current, grandparent->node); 403 cd9660node_rrip_px(current, grandparent->node);
404 TAILQ_INSERT_TAIL(&node->head, current, rr_ll); 404 TAILQ_INSERT_TAIL(&node->head, current, rr_ll);
405 } 405 }
406 /* Handle PL */ 406 /* Handle PL */
407 if (parent != NULL && parent->rr_real_parent != NULL) { 407 if (parent != NULL && parent->rr_real_parent != NULL) {
408 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP, 408 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
409 SUSP_ENTRY_RRIP_PL, "PL", SUSP_LOC_DOTDOT); 409 SUSP_ENTRY_RRIP_PL, "PL", SUSP_LOC_DOTDOT);
410 cd9660_rrip_PL(current,node); 410 cd9660_rrip_PL(current,node);
411 TAILQ_INSERT_TAIL(&node->head, current, rr_ll); 411 TAILQ_INSERT_TAIL(&node->head, current, rr_ll);
412 } 412 }
413 } else { 413 } else {
414 cd9660_rrip_initialize_inode(node); 414 cd9660_rrip_initialize_inode(node);
415 415
416 /* 416 /*
417 * Not every node needs a NM set - only if the name is 417 * Not every node needs a NM set - only if the name is
418 * actually different. IE: If a file is TEST -> TEST, 418 * actually different. IE: If a file is TEST -> TEST,
419 * no NM. test -> TEST, need a NM 419 * no NM. test -> TEST, need a NM
420 * 420 *
421 * The rr_moved_dir needs to be assigned a NM record as well. 421 * The rr_moved_dir needs to be assigned a NM record as well.
422 */ 422 */
423 if (node == diskStructure->rr_moved_dir) { 423 if (node == diskStructure->rr_moved_dir) {
424 cd9660_rrip_add_NM(node, RRIP_DEFAULT_MOVE_DIR_NAME); 424 cd9660_rrip_add_NM(node, RRIP_DEFAULT_MOVE_DIR_NAME);
425 } 425 }
426 else if ((node->node != NULL) && 426 else if ((node->node != NULL) &&
427 ((strlen(node->node->name) != 427 ((strlen(node->node->name) !=
428 (uint8_t)node->isoDirRecord->name_len[0]) || 428 (uint8_t)node->isoDirRecord->name_len[0]) ||
429 (memcmp(node->node->name,node->isoDirRecord->name, 429 (memcmp(node->node->name,node->isoDirRecord->name,
430 (uint8_t)node->isoDirRecord->name_len[0]) != 0))) { 430 (uint8_t)node->isoDirRecord->name_len[0]) != 0))) {
431 cd9660_rrip_NM(node); 431 cd9660_rrip_NM(node);
432 } 432 }
433 433
434 434
435 435
436 /* Rock ridge directory relocation code here. */ 436 /* Rock ridge directory relocation code here. */
437 437
438 /* First handle the CL for the placeholder file. */ 438 /* First handle the CL for the placeholder file. */
439 if (node->rr_relocated != NULL) { 439 if (node->rr_relocated != NULL) {
440 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP, 440 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
441 SUSP_ENTRY_RRIP_CL, "CL", SUSP_LOC_ENTRY); 441 SUSP_ENTRY_RRIP_CL, "CL", SUSP_LOC_ENTRY);
442 cd9660_rrip_CL(current, node); 442 cd9660_rrip_CL(current, node);
443 TAILQ_INSERT_TAIL(&node->head, current, rr_ll); 443 TAILQ_INSERT_TAIL(&node->head, current, rr_ll);
444 } 444 }
445 445
446 /* Handle RE*/ 446 /* Handle RE*/
447 if (node->rr_real_parent != NULL) { 447 if (node->rr_real_parent != NULL) {
448 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP, 448 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
449 SUSP_ENTRY_RRIP_RE, "RE", SUSP_LOC_ENTRY); 449 SUSP_ENTRY_RRIP_RE, "RE", SUSP_LOC_ENTRY);
450 cd9660_rrip_RE(current,node); 450 cd9660_rrip_RE(current,node);
451 TAILQ_INSERT_TAIL(&node->head, current, rr_ll); 451 TAILQ_INSERT_TAIL(&node->head, current, rr_ll);
452 } 452 }
453 } 453 }
454 return 1; 454 return 1;
455} 455}
456 456
457struct ISO_SUSP_ATTRIBUTES* 457struct ISO_SUSP_ATTRIBUTES*
458cd9660node_susp_create_node(int susp_type, int entry_type, const char *type_id, 458cd9660node_susp_create_node(int susp_type, int entry_type, const char *type_id,
459 int write_loc) 459 int write_loc)
460{ 460{
461 struct ISO_SUSP_ATTRIBUTES* temp; 461 struct ISO_SUSP_ATTRIBUTES* temp;
462 462
463 temp = emalloc(sizeof(*temp)); 463 temp = emalloc(sizeof(*temp));
464 temp->susp_type = susp_type; 464 temp->susp_type = susp_type;
465 temp->entry_type = entry_type; 465 temp->entry_type = entry_type;
466 temp->last_in_suf = 0; 466 temp->last_in_suf = 0;
467 /* Phase this out */ 467 /* Phase this out */
468 temp->type_of[0] = type_id[0]; 468 temp->type_of[0] = type_id[0];
469 temp->type_of[1] = type_id[1]; 469 temp->type_of[1] = type_id[1];
470 temp->write_location = write_loc; 470 temp->write_location = write_loc;
471 471
472 /* 472 /*
473 * Since the first four bytes is common, lets go ahead and 473 * Since the first four bytes is common, lets go ahead and
474 * set the type identifier, since we are passing that to this 474 * set the type identifier, since we are passing that to this
475 * function anyhow. 475 * function anyhow.
476 */ 476 */
477 temp->attr.su_entry.SP.h.type[0] = type_id[0]; 477 temp->attr.su_entry.SP.h.type[0] = type_id[0];
478 temp->attr.su_entry.SP.h.type[1] = type_id[1]; 478 temp->attr.su_entry.SP.h.type[1] = type_id[1];
479 return temp; 479 return temp;
480} 480}
481 481
482int 482int
483cd9660_rrip_PL(struct ISO_SUSP_ATTRIBUTES* p, cd9660node *node __unused) 483cd9660_rrip_PL(struct ISO_SUSP_ATTRIBUTES* p, cd9660node *node __unused)
484{ 484{
485 p->attr.rr_entry.PL.h.length[0] = 12; 485 p->attr.rr_entry.PL.h.length[0] = 12;
486 p->attr.rr_entry.PL.h.version[0] = 1; 486 p->attr.rr_entry.PL.h.version[0] = 1;
487 return 1; 487 return 1;
488} 488}
489 489
490int 490int
491cd9660_rrip_CL(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *node __unused) 491cd9660_rrip_CL(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *node __unused)
492{ 492{
493 p->attr.rr_entry.CL.h.length[0] = 12; 493 p->attr.rr_entry.CL.h.length[0] = 12;
494 p->attr.rr_entry.CL.h.version[0] = 1; 494 p->attr.rr_entry.CL.h.version[0] = 1;
495 return 1; 495 return 1;
496} 496}
497 497
498int 498int
499cd9660_rrip_RE(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *node __unused) 499cd9660_rrip_RE(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *node __unused)
500{ 500{
501 p->attr.rr_entry.RE.h.length[0] = 4; 501 p->attr.rr_entry.RE.h.length[0] = 4;
502 p->attr.rr_entry.RE.h.version[0] = 1; 502 p->attr.rr_entry.RE.h.version[0] = 1;
503 return 1; 503 return 1;
504} 504}
505 505
506void 506void
507cd9660_createSL(cd9660node *node) 507cd9660_createSL(cd9660node *node)
508{ 508{
509 struct ISO_SUSP_ATTRIBUTES* current; 509 struct ISO_SUSP_ATTRIBUTES* current;
510 int path_count, dir_count, done, i, j, dir_copied; 510 int path_count, dir_count, done, i, j, dir_copied;
511 char temp_cr[255]; 511 char temp_cr[255];
512 char temp_sl[255]; /* used in copying continuation entry*/ 512 char temp_sl[255]; /* used in copying continuation entry*/
513 char* sl_ptr; 513 char* sl_ptr;
514 514
515 sl_ptr = node->node->symlink; 515 sl_ptr = node->node->symlink;
516 516
517 done = 0; 517 done = 0;
518 path_count = 0; 518 path_count = 0;
519 dir_count = 0; 519 dir_count = 0;
520 dir_copied = 0; 520 dir_copied = 0;
521 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP, 521 current = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
522 SUSP_ENTRY_RRIP_SL, "SL", SUSP_LOC_ENTRY); 522 SUSP_ENTRY_RRIP_SL, "SL", SUSP_LOC_ENTRY);
523 523
524 current->attr.rr_entry.SL.h.version[0] = 1; 524 current->attr.rr_entry.SL.h.version[0] = 1;
525 current->attr.rr_entry.SL.flags[0] = SL_FLAGS_NONE; 525 current->attr.rr_entry.SL.flags[0] = SL_FLAGS_NONE;
526 526
527 if (*sl_ptr == '/') { 527 if (*sl_ptr == '/') {
528 temp_cr[0] = SL_FLAGS_ROOT; 528 temp_cr[0] = SL_FLAGS_ROOT;
529 temp_cr[1] = 0; 529 temp_cr[1] = 0;
530 memcpy(current->attr.rr_entry.SL.component + path_count, 530 memcpy(current->attr.rr_entry.SL.component + path_count,
531 temp_cr, 2); 531 temp_cr, 2);
532 path_count += 2; 532 path_count += 2;
533 sl_ptr++; 533 sl_ptr++;
534 } 534 }
535 535
536 for (i = 0; i < (dir_count + 2); i++) 536 for (i = 0; i < (dir_count + 2); i++)
537 temp_cr[i] = '\0'; 537 temp_cr[i] = '\0';
538 538
539 while (!done) { 539 while (!done) {
540 while ((*sl_ptr != '/') && (*sl_ptr != '\0')) { 540 while ((*sl_ptr != '/') && (*sl_ptr != '\0')) {
541 dir_copied = 1; 541 dir_copied = 1;
542 if (*sl_ptr == '.') { 542 if (*sl_ptr == '.') {
543 if ((*(sl_ptr + 1) == '/') || (*(sl_ptr + 1) 543 if ((*(sl_ptr + 1) == '/') || (*(sl_ptr + 1)
544 == '\0')) { 544 == '\0')) {
545 temp_cr[0] = SL_FLAGS_CURRENT; 545 temp_cr[0] = SL_FLAGS_CURRENT;
546 sl_ptr++; 546 sl_ptr++;
547 } else if(*(sl_ptr + 1) == '.') { 547 } else if(*(sl_ptr + 1) == '.') {
548 if ((*(sl_ptr + 2) == '/') || 548 if ((*(sl_ptr + 2) == '/') ||
549 (*(sl_ptr + 2) == '\0')) { 549 (*(sl_ptr + 2) == '\0')) {
550 temp_cr[0] = SL_FLAGS_PARENT; 550 temp_cr[0] = SL_FLAGS_PARENT;
551 sl_ptr += 2; 551 sl_ptr += 2;
552 } 552 }
553 } else { 553 } else {
554 temp_cr[dir_count+2] = *sl_ptr; 554 temp_cr[dir_count+2] = *sl_ptr;
555 sl_ptr++; 555 sl_ptr++;
556 dir_count++; 556 dir_count++;
557 } 557 }
558 } else { 558 } else {
559 temp_cr[dir_count + 2] = *sl_ptr; 559 temp_cr[dir_count + 2] = *sl_ptr;
560 sl_ptr++; 560 sl_ptr++;
561 dir_count++; 561 dir_count++;
562 } 562 }
563 } 563 }
564 564
565 if ((path_count + dir_count) >= 249) { 565 if ((path_count + dir_count) >= 249) {
566 current->attr.rr_entry.SL.flags[0] |= SL_FLAGS_CONTINUE; 566 current->attr.rr_entry.SL.flags[0] |= SL_FLAGS_CONTINUE;
567 567
568 j = 0; 568 j = 0;
569 569
570 if (path_count <= 249) { 570 if (path_count <= 249) {
571 while(j != (249 - path_count)) { 571 while(j != (249 - path_count)) {
572 temp_sl[j] = temp_cr[j]; 572 temp_sl[j] = temp_cr[j];
573 j++; 573 j++;
574 } 574 }
575 temp_sl[0] = SL_FLAGS_CONTINUE; 575 temp_sl[0] = SL_FLAGS_CONTINUE;
576 temp_sl[1] = j - 2; 576 temp_sl[1] = j - 2;
577 memcpy( 577 memcpy(
578 current->attr.rr_entry.SL.component + 578 current->attr.rr_entry.SL.component +
579 path_count, 579 path_count,
580 temp_sl, j); 580 temp_sl, j);
581 } 581 }
582 582
583 path_count += j; 583 path_count += j;
584 current->attr.rr_entry.SL.h.length[0] = path_count + 5; 584 current->attr.rr_entry.SL.h.length[0] = path_count + 5;
585 TAILQ_INSERT_TAIL(&node->head, current, rr_ll); 585 TAILQ_INSERT_TAIL(&node->head, current, rr_ll);
586 current= cd9660node_susp_create_node(SUSP_TYPE_RRIP, 586 current= cd9660node_susp_create_node(SUSP_TYPE_RRIP,
587 SUSP_ENTRY_RRIP_SL, "SL", SUSP_LOC_ENTRY); 587 SUSP_ENTRY_RRIP_SL, "SL", SUSP_LOC_ENTRY);
588 current->attr.rr_entry.SL.h.version[0] = 1; 588 current->attr.rr_entry.SL.h.version[0] = 1;
589 current->attr.rr_entry.SL.flags[0] = SL_FLAGS_NONE; 589 current->attr.rr_entry.SL.flags[0] = SL_FLAGS_NONE;
590 590
591 path_count = 0; 591 path_count = 0;
592 592
593 if (dir_count > 2) { 593 if (dir_count > 2) {
594 while (j != dir_count + 2) { 594 while (j != dir_count + 2) {
595 current->attr.rr_entry.SL.component[ 595 current->attr.rr_entry.SL.component[
596 path_count + 2] = temp_cr[j]; 596 path_count + 2] = temp_cr[j];
597 j++; 597 j++;
598 path_count++; 598 path_count++;
599 } 599 }
600 current->attr.rr_entry.SL.component[1] 600 current->attr.rr_entry.SL.component[1]
601 = path_count; 601 = path_count;
602 path_count+= 2; 602 path_count+= 2;
603 } else { 603 } else {
604 while(j != dir_count) { 604 while(j != dir_count) {
605 current->attr.rr_entry.SL.component[ 605 current->attr.rr_entry.SL.component[
606 path_count+2] = temp_cr[j]; 606 path_count+2] = temp_cr[j];
607 j++; 607 j++;
608 path_count++; 608 path_count++;
609 } 609 }
610 } 610 }
611 } else { 611 } else {
612 if (dir_copied == 1) { 612 if (dir_copied == 1) {
613 temp_cr[1] = dir_count; 613 temp_cr[1] = dir_count;
614 memcpy(current->attr.rr_entry.SL.component + 614 memcpy(current->attr.rr_entry.SL.component +
615 path_count, 615 path_count,
616 temp_cr, dir_count + 2); 616 temp_cr, dir_count + 2);
617 path_count += dir_count + 2; 617 path_count += dir_count + 2;
618 } 618 }
619 } 619 }
620 620
621 if (*sl_ptr == '\0') { 621 if (*sl_ptr == '\0') {
622 done = 1; 622 done = 1;
623 current->attr.rr_entry.SL.h.length[0] = path_count + 5; 623 current->attr.rr_entry.SL.h.length[0] = path_count + 5;
624 TAILQ_INSERT_TAIL(&node->head, current, rr_ll); 624 TAILQ_INSERT_TAIL(&node->head, current, rr_ll);
625 } else { 625 } else {
626 sl_ptr++; 626 sl_ptr++;
627 dir_count = 0; 627 dir_count = 0;
628 dir_copied = 0; 628 dir_copied = 0;
629 for(i = 0; i < 255; i++) { 629 for(i = 0; i < 255; i++) {
630 temp_cr[i] = '\0'; 630 temp_cr[i] = '\0';
631 } 631 }
632 } 632 }
633 } 633 }
634} 634}
635 635
636int 636int
637cd9660node_rrip_px(struct ISO_SUSP_ATTRIBUTES *v, fsnode *pxinfo) 637cd9660node_rrip_px(struct ISO_SUSP_ATTRIBUTES *v, fsnode *pxinfo)
638{ 638{
639 v->attr.rr_entry.PX.h.length[0] = 36; 639 v->attr.rr_entry.PX.h.length[0] = 36;
640 v->attr.rr_entry.PX.h.version[0] = 1; 640 v->attr.rr_entry.PX.h.version[0] = 1;
641 cd9660_bothendian_dword(pxinfo->inode->st.st_mode, 641 cd9660_bothendian_dword(pxinfo->inode->st.st_mode,
642 v->attr.rr_entry.PX.mode); 642 v->attr.rr_entry.PX.mode);
643 cd9660_bothendian_dword(pxinfo->inode->st.st_nlink, 643 cd9660_bothendian_dword(pxinfo->inode->st.st_nlink,
644 v->attr.rr_entry.PX.links); 644 v->attr.rr_entry.PX.links);
645 cd9660_bothendian_dword(pxinfo->inode->st.st_uid, 645 cd9660_bothendian_dword(pxinfo->inode->st.st_uid,
646 v->attr.rr_entry.PX.uid); 646 v->attr.rr_entry.PX.uid);
647 cd9660_bothendian_dword(pxinfo->inode->st.st_gid, 647 cd9660_bothendian_dword(pxinfo->inode->st.st_gid,
648 v->attr.rr_entry.PX.gid); 648 v->attr.rr_entry.PX.gid);
649 649
650 /* Ignoring the serial number for now */ 650 /* Ignoring the serial number for now */
651 return 1; 651 return 1;
652} 652}
653 653
654int 654int
655cd9660node_rrip_pn(struct ISO_SUSP_ATTRIBUTES *pn_field, fsnode *fnode) 655cd9660node_rrip_pn(struct ISO_SUSP_ATTRIBUTES *pn_field, fsnode *fnode)
656{ 656{
657 pn_field->attr.rr_entry.PN.h.length[0] = 20; 657 pn_field->attr.rr_entry.PN.h.length[0] = 20;
658 pn_field->attr.rr_entry.PN.h.version[0] = 1; 658 pn_field->attr.rr_entry.PN.h.version[0] = 1;
659 659
660 if (sizeof (fnode->inode->st.st_rdev) > 4) 660 if (sizeof (fnode->inode->st.st_rdev) > 4)
661 cd9660_bothendian_dword( 661 cd9660_bothendian_dword(
662 (uint64_t)fnode->inode->st.st_rdev >> 32, 662 (uint64_t)fnode->inode->st.st_rdev >> 32,
663 pn_field->attr.rr_entry.PN.high); 663 pn_field->attr.rr_entry.PN.high);
664 else 664 else
665 cd9660_bothendian_dword(0, pn_field->attr.rr_entry.PN.high); 665 cd9660_bothendian_dword(0, pn_field->attr.rr_entry.PN.high);
666 666
667 cd9660_bothendian_dword(fnode->inode->st.st_rdev & 0xffffffff, 667 cd9660_bothendian_dword(fnode->inode->st.st_rdev & 0xffffffff,
668 pn_field->attr.rr_entry.PN.low); 668 pn_field->attr.rr_entry.PN.low);
669 return 1; 669 return 1;
670} 670}
671 671
672#if 0 672#if 0
673int 673int
674cd9660node_rrip_nm(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *file_node) 674cd9660node_rrip_nm(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *file_node)
675{ 675{
676 int nm_length = strlen(file_node->isoDirRecord->name) + 5; 676 int nm_length = strlen(file_node->isoDirRecord->name) + 5;
677 p->attr.rr_entry.NM.h.type[0] = 'N'; 677 p->attr.rr_entry.NM.h.type[0] = 'N';
678 p->attr.rr_entry.NM.h.type[1] = 'M'; 678 p->attr.rr_entry.NM.h.type[1] = 'M';
679 sprintf(p->attr.rr_entry.NM.altname, "%s", file_node->isoDirRecord->name); 679 sprintf(p->attr.rr_entry.NM.altname, "%s", file_node->isoDirRecord->name);
680 p->attr.rr_entry.NM.h.length[0] = (unsigned char)nm_length; 680 p->attr.rr_entry.NM.h.length[0] = (unsigned char)nm_length;
681 p->attr.rr_entry.NM.h.version[0] = (unsigned char)1; 681 p->attr.rr_entry.NM.h.version[0] = (unsigned char)1;
682 p->attr.rr_entry.NM.flags[0] = (unsigned char) NM_PARENT; 682 p->attr.rr_entry.NM.flags[0] = (unsigned char) NM_PARENT;
683 return 1; 683 return 1;
684} 684}
685#endif 685#endif
686 686
687int 687int
688cd9660node_rrip_tf(struct ISO_SUSP_ATTRIBUTES *p, fsnode *_node) 688cd9660node_rrip_tf(struct ISO_SUSP_ATTRIBUTES *p, fsnode *_node)
689{ 689{
690 p->attr.rr_entry.TF.flags[0] = TF_MODIFY | TF_ACCESS | TF_ATTRIBUTES; 690 p->attr.rr_entry.TF.flags[0] = TF_MODIFY | TF_ACCESS | TF_ATTRIBUTES;
691 p->attr.rr_entry.TF.h.length[0] = 5; 691 p->attr.rr_entry.TF.h.length[0] = 5;
692 p->attr.rr_entry.TF.h.version[0] = 1; 692 p->attr.rr_entry.TF.h.version[0] = 1;
693 693
694 /* 694 /*
695 * Need to add creation time, backup time, 695 * Need to add creation time, backup time,
696 * expiration time, and effective time. 696 * expiration time, and effective time.
697 */ 697 */
698 698
699 cd9660_time_915(p->attr.rr_entry.TF.timestamp, 699 cd9660_time_915(p->attr.rr_entry.TF.timestamp,
700 _node->inode->st.st_atime); 700 _node->inode->st.st_mtime);
701 p->attr.rr_entry.TF.h.length[0] += 7; 701 p->attr.rr_entry.TF.h.length[0] += 7;
702 702
703 cd9660_time_915(p->attr.rr_entry.TF.timestamp + 7, 703 cd9660_time_915(p->attr.rr_entry.TF.timestamp + 7,
704 _node->inode->st.st_mtime); 704 _node->inode->st.st_atime);
705 p->attr.rr_entry.TF.h.length[0] += 7; 705 p->attr.rr_entry.TF.h.length[0] += 7;
706 706
707 cd9660_time_915(p->attr.rr_entry.TF.timestamp + 14, 707 cd9660_time_915(p->attr.rr_entry.TF.timestamp + 14,
708 _node->inode->st.st_ctime); 708 _node->inode->st.st_ctime);
709 p->attr.rr_entry.TF.h.length[0] += 7; 709 p->attr.rr_entry.TF.h.length[0] += 7;
710 return 1; 710 return 1;
711} 711}
712 712
713int 713int
714cd9660_susp_sp(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *spinfo __unused) 714cd9660_susp_sp(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *spinfo __unused)
715{ 715{
716 p->attr.su_entry.SP.h.length[0] = 7; 716 p->attr.su_entry.SP.h.length[0] = 7;
717 p->attr.su_entry.SP.h.version[0] = 1; 717 p->attr.su_entry.SP.h.version[0] = 1;
718 p->attr.su_entry.SP.check[0] = 0xBE; 718 p->attr.su_entry.SP.check[0] = 0xBE;
719 p->attr.su_entry.SP.check[1] = 0xEF; 719 p->attr.su_entry.SP.check[1] = 0xEF;
720 p->attr.su_entry.SP.len_skp[0] = 0; 720 p->attr.su_entry.SP.len_skp[0] = 0;
721 return 1; 721 return 1;
722} 722}
723 723
724int 724int
725cd9660_susp_st(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *stinfo __unused) 725cd9660_susp_st(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *stinfo __unused)
726{ 726{
727 p->attr.su_entry.ST.h.type[0] = 'S'; 727 p->attr.su_entry.ST.h.type[0] = 'S';
728 p->attr.su_entry.ST.h.type[1] = 'T'; 728 p->attr.su_entry.ST.h.type[1] = 'T';
729 p->attr.su_entry.ST.h.length[0] = 4; 729 p->attr.su_entry.ST.h.length[0] = 4;
730 p->attr.su_entry.ST.h.version[0] = 1; 730 p->attr.su_entry.ST.h.version[0] = 1;
731 return 1; 731 return 1;
732} 732}
733 733
734int 734int
735cd9660_susp_ce(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *spinfo __unused) 735cd9660_susp_ce(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *spinfo __unused)
736{ 736{
737 p->attr.su_entry.CE.h.length[0] = 28; 737 p->attr.su_entry.CE.h.length[0] = 28;
738 p->attr.su_entry.CE.h.version[0] = 1; 738 p->attr.su_entry.CE.h.version[0] = 1;
739 /* Other attributes dont matter right now, will be updated later */ 739 /* Other attributes dont matter right now, will be updated later */
740 return 1; 740 return 1;
741} 741}
742 742
743int 743int
744cd9660_susp_pd(struct ISO_SUSP_ATTRIBUTES *p __unused, int length __unused) 744cd9660_susp_pd(struct ISO_SUSP_ATTRIBUTES *p __unused, int length __unused)
745{ 745{
746 return 1; 746 return 1;
747} 747}
748 748
749void 749void
750cd9660_rrip_add_NM(cd9660node *node, const char *name) 750cd9660_rrip_add_NM(cd9660node *node, const char *name)
751{ 751{
752 int working,len; 752 int working,len;
753 const char *p; 753 const char *p;
754 struct ISO_SUSP_ATTRIBUTES *r; 754 struct ISO_SUSP_ATTRIBUTES *r;
755 755
756 /* 756 /*
757 * Each NM record has 254 byes to work with. This means that 757 * Each NM record has 254 byes to work with. This means that
758 * the name data itself only has 249 bytes to work with. So, a 758 * the name data itself only has 249 bytes to work with. So, a
759 * name with 251 characters would require two nm records. 759 * name with 251 characters would require two nm records.
760 */ 760 */
761 p = name; 761 p = name;
762 working = 1; 762 working = 1;
763 while (working) { 763 while (working) {
764 r = cd9660node_susp_create_node(SUSP_TYPE_RRIP, 764 r = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
765 SUSP_ENTRY_RRIP_NM, "NM", SUSP_LOC_ENTRY); 765 SUSP_ENTRY_RRIP_NM, "NM", SUSP_LOC_ENTRY);
766 r->attr.rr_entry.NM.h.version[0] = 1; 766 r->attr.rr_entry.NM.h.version[0] = 1;
767 r->attr.rr_entry.NM.flags[0] = RRIP_NM_FLAGS_NONE; 767 r->attr.rr_entry.NM.flags[0] = RRIP_NM_FLAGS_NONE;
768 len = strlen(p); 768 len = strlen(p);
769 769
770 if (len > 249) { 770 if (len > 249) {
771 len = 249; 771 len = 249;
772 r->attr.rr_entry.NM.flags[0] = RRIP_NM_FLAGS_CONTINUE; 772 r->attr.rr_entry.NM.flags[0] = RRIP_NM_FLAGS_CONTINUE;
773 } else { 773 } else {
774 working = 0; 774 working = 0;
775 } 775 }
776 memcpy(r->attr.rr_entry.NM.altname, p, len); 776 memcpy(r->attr.rr_entry.NM.altname, p, len);
777 r->attr.rr_entry.NM.h.length[0] = 5 + len; 777 r->attr.rr_entry.NM.h.length[0] = 5 + len;
778 778
779 TAILQ_INSERT_TAIL(&node->head, r, rr_ll); 779 TAILQ_INSERT_TAIL(&node->head, r, rr_ll);
780 780
781 p += len; 781 p += len;
782 } 782 }
783} 783}
784 784
785void 785void
786cd9660_rrip_NM(cd9660node *node) 786cd9660_rrip_NM(cd9660node *node)
787{ 787{
788 cd9660_rrip_add_NM(node, node->node->name); 788 cd9660_rrip_add_NM(node, node->node->name);
789} 789}
790 790
791struct ISO_SUSP_ATTRIBUTES* 791struct ISO_SUSP_ATTRIBUTES*
792cd9660_susp_ER(cd9660node *node, 792cd9660_susp_ER(cd9660node *node,
793 u_char ext_version, const char* ext_id, const char* ext_des, 793 u_char ext_version, const char* ext_id, const char* ext_des,
794 const char* ext_src) 794 const char* ext_src)
795{ 795{
796 int l; 796 int l;
797 struct ISO_SUSP_ATTRIBUTES *r; 797 struct ISO_SUSP_ATTRIBUTES *r;
798 798
799 r = cd9660node_susp_create_node(SUSP_TYPE_SUSP, 799 r = cd9660node_susp_create_node(SUSP_TYPE_SUSP,
800 SUSP_ENTRY_SUSP_ER, "ER", SUSP_LOC_DOT); 800 SUSP_ENTRY_SUSP_ER, "ER", SUSP_LOC_DOT);
801 801
802 /* Fixed data is 8 bytes */ 802 /* Fixed data is 8 bytes */
803 r->attr.su_entry.ER.h.length[0] = 8; 803 r->attr.su_entry.ER.h.length[0] = 8;
804 r->attr.su_entry.ER.h.version[0] = 1; 804 r->attr.su_entry.ER.h.version[0] = 1;
805 805
806 r->attr.su_entry.ER.len_id[0] = (u_char)strlen(ext_id); 806 r->attr.su_entry.ER.len_id[0] = (u_char)strlen(ext_id);
807 r->attr.su_entry.ER.len_des[0] = (u_char)strlen(ext_des); 807 r->attr.su_entry.ER.len_des[0] = (u_char)strlen(ext_des);
808 r->attr.su_entry.ER.len_src[0] = (u_char)strlen(ext_src); 808 r->attr.su_entry.ER.len_src[0] = (u_char)strlen(ext_src);
809 809
810 l = r->attr.su_entry.ER.len_id[0] + 810 l = r->attr.su_entry.ER.len_id[0] +
811 r->attr.su_entry.ER.len_src[0] + 811 r->attr.su_entry.ER.len_src[0] +
812 r->attr.su_entry.ER.len_des[0]; 812 r->attr.su_entry.ER.len_des[0];
813 813
814 /* Everything must fit. */ 814 /* Everything must fit. */
815 assert(l + r->attr.su_entry.ER.h.length[0] <= 254); 815 assert(l + r->attr.su_entry.ER.h.length[0] <= 254);
816 816
817 r->attr.su_entry.ER.h.length[0] += (u_char)l; 817 r->attr.su_entry.ER.h.length[0] += (u_char)l;
818 818
819 819
820 r->attr.su_entry.ER.ext_ver[0] = ext_version; 820 r->attr.su_entry.ER.ext_ver[0] = ext_version;
821 memcpy(r->attr.su_entry.ER.ext_data, ext_id, 821 memcpy(r->attr.su_entry.ER.ext_data, ext_id,
822 (int)r->attr.su_entry.ER.len_id[0]); 822 (int)r->attr.su_entry.ER.len_id[0]);
823 l = (int) r->attr.su_entry.ER.len_id[0]; 823 l = (int) r->attr.su_entry.ER.len_id[0];
824 memcpy(r->attr.su_entry.ER.ext_data + l,ext_des, 824 memcpy(r->attr.su_entry.ER.ext_data + l,ext_des,
825 (int)r->attr.su_entry.ER.len_des[0]); 825 (int)r->attr.su_entry.ER.len_des[0]);
826 826
827 l += (int)r->attr.su_entry.ER.len_des[0]; 827 l += (int)r->attr.su_entry.ER.len_des[0];
828 memcpy(r->attr.su_entry.ER.ext_data + l,ext_src, 828 memcpy(r->attr.su_entry.ER.ext_data + l,ext_src,
829 (int)r->attr.su_entry.ER.len_src[0]); 829 (int)r->attr.su_entry.ER.len_src[0]);
830 830
831 TAILQ_INSERT_TAIL(&node->head, r, rr_ll); 831 TAILQ_INSERT_TAIL(&node->head, r, rr_ll);
832 return r; 832 return r;
833} 833}
834 834
835struct ISO_SUSP_ATTRIBUTES* 835struct ISO_SUSP_ATTRIBUTES*
836cd9660_susp_ES(struct ISO_SUSP_ATTRIBUTES *last __unused, cd9660node *node __unused) 836cd9660_susp_ES(struct ISO_SUSP_ATTRIBUTES *last __unused, cd9660node *node __unused)
837{ 837{
838 return NULL; 838 return NULL;
839} 839}

cvs diff -r1.6 -r1.7 src/usr.sbin/makefs/cd9660/iso9660_rrip.h (switch to unified diff)

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