]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* $NetBSD: cd9660_rrip.c,v 1.11 1994/12/24 15:30:10 cgd Exp $ */ | |
26 | ||
27 | /*- | |
28 | * Copyright (c) 1993, 1994 | |
29 | * The Regents of the University of California. All rights reserved. | |
30 | * | |
31 | * This code is derived from software contributed to Berkeley | |
32 | * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension | |
33 | * Support code is derived from software contributed to Berkeley | |
34 | * by Atsushi Murai (amurai@spec.co.jp). | |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * 1. Redistributions of source code must retain the above copyright | |
40 | * notice, this list of conditions and the following disclaimer. | |
41 | * 2. Redistributions in binary form must reproduce the above copyright | |
42 | * notice, this list of conditions and the following disclaimer in the | |
43 | * documentation and/or other materials provided with the distribution. | |
44 | * 3. All advertising materials mentioning features or use of this software | |
45 | * must display the following acknowledgement: | |
46 | * This product includes software developed by the University of | |
47 | * California, Berkeley and its contributors. | |
48 | * 4. Neither the name of the University nor the names of its contributors | |
49 | * may be used to endorse or promote products derived from this software | |
50 | * without specific prior written permission. | |
51 | * | |
52 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
53 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
54 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
62 | * SUCH DAMAGE. | |
63 | * | |
64 | * @(#)cd9660_rrip.c 8.6 (Berkeley) 12/5/94 | |
65 | ||
66 | ||
67 | ||
68 | * HISTORY | |
69 | * 22-Jan-98 radar 1669467 - ISO 9660 CD support - jwc | |
70 | ||
71 | */ | |
72 | ||
73 | #include <sys/param.h> | |
74 | #include <sys/systm.h> | |
75 | #include <sys/vnode.h> | |
76 | #include <sys/mount.h> | |
77 | #include <sys/namei.h> | |
78 | #include <sys/buf.h> | |
79 | #include <sys/file.h> | |
80 | #include <sys/kernel.h> | |
81 | #include <sys/stat.h> | |
82 | #include <sys/types.h> | |
83 | ||
84 | #include <sys/time.h> | |
85 | ||
86 | #include <isofs/cd9660/iso.h> | |
87 | #include <isofs/cd9660/cd9660_node.h> | |
88 | #include <isofs/cd9660/cd9660_rrip.h> | |
89 | #include <isofs/cd9660/iso_rrip.h> | |
90 | ||
91 | /* | |
92 | * POSIX file attribute | |
93 | */ | |
94 | static int | |
95 | cd9660_rrip_attr(p,ana) | |
96 | ISO_RRIP_ATTR *p; | |
97 | ISO_RRIP_ANALYZE *ana; | |
98 | { | |
99 | ana->inop->inode.iso_mode = isonum_733(p->mode); | |
100 | ana->inop->inode.iso_uid = isonum_733(p->uid); | |
101 | ana->inop->inode.iso_gid = isonum_733(p->gid); | |
102 | ana->inop->inode.iso_links = isonum_733(p->links); | |
103 | ana->fields &= ~ISO_SUSP_ATTR; | |
104 | return ISO_SUSP_ATTR; | |
105 | } | |
106 | ||
107 | static void | |
108 | cd9660_rrip_defattr(isodir,ana) | |
109 | struct iso_directory_record *isodir; | |
110 | ISO_RRIP_ANALYZE *ana; | |
111 | { | |
112 | /* But this is a required field! */ | |
113 | printf("RRIP without PX field?\n"); | |
114 | cd9660_defattr(isodir,ana->inop,NULL); | |
115 | } | |
116 | ||
117 | /* | |
118 | * Symbolic Links | |
119 | */ | |
120 | static int | |
121 | cd9660_rrip_slink(p,ana) | |
122 | ISO_RRIP_SLINK *p; | |
123 | ISO_RRIP_ANALYZE *ana; | |
124 | { | |
125 | register ISO_RRIP_SLINK_COMPONENT *pcomp; | |
126 | register ISO_RRIP_SLINK_COMPONENT *pcompe; | |
127 | int len, wlen, cont; | |
128 | char *outbuf, *inbuf; | |
129 | ||
130 | pcomp = (ISO_RRIP_SLINK_COMPONENT *)p->component; | |
131 | pcompe = (ISO_RRIP_SLINK_COMPONENT *)((char *)p + isonum_711(p->h.length)); | |
132 | len = *ana->outlen; | |
133 | outbuf = ana->outbuf; | |
134 | cont = ana->cont; | |
135 | ||
136 | /* | |
137 | * Gathering a Symbolic name from each component with path | |
138 | */ | |
139 | for (; | |
140 | pcomp < pcompe; | |
141 | pcomp = (ISO_RRIP_SLINK_COMPONENT *)((char *)pcomp + ISO_RRIP_SLSIZ | |
142 | + isonum_711(pcomp->clen))) { | |
143 | ||
144 | if (!cont) { | |
145 | if (len < ana->maxlen) { | |
146 | len++; | |
147 | *outbuf++ = '/'; | |
148 | } | |
149 | } | |
150 | cont = 0; | |
151 | ||
152 | inbuf = ".."; | |
153 | wlen = 0; | |
154 | ||
155 | switch (*pcomp->cflag) { | |
156 | ||
157 | case ISO_SUSP_CFLAG_CURRENT: | |
158 | /* Inserting Current */ | |
159 | wlen = 1; | |
160 | break; | |
161 | ||
162 | case ISO_SUSP_CFLAG_PARENT: | |
163 | /* Inserting Parent */ | |
164 | wlen = 2; | |
165 | break; | |
166 | ||
167 | case ISO_SUSP_CFLAG_ROOT: | |
168 | /* Inserting slash for ROOT */ | |
169 | /* start over from beginning(?) */ | |
170 | outbuf -= len; | |
171 | len = 0; | |
172 | break; | |
173 | ||
174 | case ISO_SUSP_CFLAG_VOLROOT: | |
175 | /* Inserting a mount point i.e. "/cdrom" */ | |
176 | /* same as above */ | |
177 | outbuf -= len; | |
178 | len = 0; | |
179 | inbuf = ana->imp->im_mountp->mnt_stat.f_mntonname; | |
180 | wlen = strlen(inbuf); | |
181 | break; | |
182 | ||
183 | case ISO_SUSP_CFLAG_HOST: | |
184 | /* Inserting hostname i.e. "kurt.tools.de" */ | |
185 | inbuf = hostname; | |
186 | wlen = hostnamelen; | |
187 | break; | |
188 | ||
189 | case ISO_SUSP_CFLAG_CONTINUE: | |
190 | cont = 1; | |
191 | /* fall thru */ | |
192 | case 0: | |
193 | /* Inserting component */ | |
194 | wlen = isonum_711(pcomp->clen); | |
195 | inbuf = pcomp->name; | |
196 | break; | |
197 | default: | |
198 | printf("RRIP with incorrect flags?"); | |
199 | wlen = ana->maxlen + 1; | |
200 | break; | |
201 | } | |
202 | ||
203 | if (len + wlen > ana->maxlen) { | |
204 | /* indicate error to caller */ | |
205 | ana->cont = 1; | |
206 | ana->fields = 0; | |
207 | ana->outbuf -= *ana->outlen; | |
208 | *ana->outlen = 0; | |
209 | return 0; | |
210 | } | |
211 | ||
212 | bcopy(inbuf,outbuf,wlen); | |
213 | outbuf += wlen; | |
214 | len += wlen; | |
215 | ||
216 | } | |
217 | ana->outbuf = outbuf; | |
218 | *ana->outlen = len; | |
219 | ana->cont = cont; | |
220 | ||
221 | if (!isonum_711(p->flags)) { | |
222 | ana->fields &= ~ISO_SUSP_SLINK; | |
223 | return ISO_SUSP_SLINK; | |
224 | } | |
225 | return 0; | |
226 | } | |
227 | ||
228 | /* | |
229 | * Alternate name | |
230 | */ | |
231 | static int | |
232 | cd9660_rrip_altname(p,ana) | |
233 | ISO_RRIP_ALTNAME *p; | |
234 | ISO_RRIP_ANALYZE *ana; | |
235 | { | |
236 | char *inbuf; | |
237 | int wlen; | |
238 | int cont; | |
239 | ||
240 | inbuf = ".."; | |
241 | wlen = 0; | |
242 | cont = 0; | |
243 | ||
244 | switch (*p->flags) { | |
245 | case ISO_SUSP_CFLAG_CURRENT: | |
246 | /* Inserting Current */ | |
247 | wlen = 1; | |
248 | break; | |
249 | ||
250 | case ISO_SUSP_CFLAG_PARENT: | |
251 | /* Inserting Parent */ | |
252 | wlen = 2; | |
253 | break; | |
254 | ||
255 | case ISO_SUSP_CFLAG_HOST: | |
256 | /* Inserting hostname i.e. "kurt.tools.de" */ | |
257 | inbuf = hostname; | |
258 | wlen = hostnamelen; | |
259 | break; | |
260 | ||
261 | case ISO_SUSP_CFLAG_CONTINUE: | |
262 | cont = 1; | |
263 | /* fall thru */ | |
264 | case 0: | |
265 | /* Inserting component */ | |
266 | wlen = isonum_711(p->h.length) - 5; | |
267 | inbuf = (char *)p + 5; | |
268 | break; | |
269 | ||
270 | default: | |
271 | printf("RRIP with incorrect NM flags?\n"); | |
272 | wlen = ana->maxlen + 1; | |
273 | break; | |
274 | } | |
275 | ||
276 | if ((*ana->outlen += wlen) > ana->maxlen) { | |
277 | /* treat as no name field */ | |
278 | ana->fields &= ~ISO_SUSP_ALTNAME; | |
279 | ana->outbuf -= *ana->outlen - wlen; | |
280 | *ana->outlen = 0; | |
281 | return 0; | |
282 | } | |
283 | ||
284 | bcopy(inbuf,ana->outbuf,wlen); | |
285 | ana->outbuf += wlen; | |
286 | ||
287 | if (!cont) { | |
288 | ana->fields &= ~ISO_SUSP_ALTNAME; | |
289 | return ISO_SUSP_ALTNAME; | |
290 | } | |
291 | return 0; | |
292 | } | |
293 | ||
294 | static void | |
295 | cd9660_rrip_defname(isodir,ana) | |
296 | struct iso_directory_record *isodir; | |
297 | ISO_RRIP_ANALYZE *ana; | |
298 | { | |
299 | strcpy(ana->outbuf,".."); | |
300 | switch (*isodir->name) { | |
301 | default: | |
302 | isofntrans(isodir->name, isonum_711(isodir->name_len), | |
303 | ana->outbuf, ana->outlen, 1); | |
304 | break; | |
305 | case 0: | |
306 | *ana->outlen = 1; | |
307 | break; | |
308 | case 1: | |
309 | *ana->outlen = 2; | |
310 | break; | |
311 | } | |
312 | } | |
313 | ||
314 | /* | |
315 | * Parent or Child Link | |
316 | */ | |
317 | static int | |
318 | cd9660_rrip_pclink(p,ana) | |
319 | ISO_RRIP_CLINK *p; | |
320 | ISO_RRIP_ANALYZE *ana; | |
321 | { | |
322 | *ana->inump = isonum_733(p->dir_loc) << ana->imp->im_bshift; | |
323 | ana->fields &= ~(ISO_SUSP_CLINK|ISO_SUSP_PLINK); | |
324 | return *p->h.type == 'C' ? ISO_SUSP_CLINK : ISO_SUSP_PLINK; | |
325 | } | |
326 | ||
327 | /* | |
328 | * Relocated directory | |
329 | */ | |
330 | static int | |
331 | cd9660_rrip_reldir(p,ana) | |
332 | ISO_RRIP_RELDIR *p; | |
333 | ISO_RRIP_ANALYZE *ana; | |
334 | { | |
335 | /* special hack to make caller aware of RE field */ | |
336 | *ana->outlen = 0; | |
337 | ana->fields = 0; | |
338 | return ISO_SUSP_RELDIR|ISO_SUSP_ALTNAME|ISO_SUSP_CLINK|ISO_SUSP_PLINK; | |
339 | } | |
340 | ||
341 | static int | |
342 | cd9660_rrip_tstamp(p,ana) | |
343 | ISO_RRIP_TSTAMP *p; | |
344 | ISO_RRIP_ANALYZE *ana; | |
345 | { | |
346 | u_char *ptime; | |
347 | ||
348 | ptime = p->time; | |
349 | ||
350 | /* Check a format of time stamp (7bytes/17bytes) */ | |
351 | if (!(*p->flags&ISO_SUSP_TSTAMP_FORM17)) { | |
352 | if (*p->flags&ISO_SUSP_TSTAMP_CREAT) | |
353 | ptime += 7; | |
354 | ||
355 | if (*p->flags&ISO_SUSP_TSTAMP_MODIFY) { | |
356 | cd9660_tstamp_conv7(ptime,&ana->inop->inode.iso_mtime); | |
357 | ptime += 7; | |
358 | } else | |
359 | bzero(&ana->inop->inode.iso_mtime,sizeof(struct timespec)); | |
360 | ||
361 | if (*p->flags&ISO_SUSP_TSTAMP_ACCESS) { | |
362 | cd9660_tstamp_conv7(ptime,&ana->inop->inode.iso_atime); | |
363 | ptime += 7; | |
364 | } else | |
365 | ana->inop->inode.iso_atime = ana->inop->inode.iso_mtime; | |
366 | ||
367 | if (*p->flags&ISO_SUSP_TSTAMP_ATTR) | |
368 | cd9660_tstamp_conv7(ptime,&ana->inop->inode.iso_ctime); | |
369 | else | |
370 | ana->inop->inode.iso_ctime = ana->inop->inode.iso_mtime; | |
371 | ||
372 | } else { | |
373 | if (*p->flags&ISO_SUSP_TSTAMP_CREAT) | |
374 | ptime += 17; | |
375 | ||
376 | if (*p->flags&ISO_SUSP_TSTAMP_MODIFY) { | |
377 | cd9660_tstamp_conv17(ptime,&ana->inop->inode.iso_mtime); | |
378 | ptime += 17; | |
379 | } else | |
380 | bzero(&ana->inop->inode.iso_mtime,sizeof(struct timespec)); | |
381 | ||
382 | if (*p->flags&ISO_SUSP_TSTAMP_ACCESS) { | |
383 | cd9660_tstamp_conv17(ptime,&ana->inop->inode.iso_atime); | |
384 | ptime += 17; | |
385 | } else | |
386 | ana->inop->inode.iso_atime = ana->inop->inode.iso_mtime; | |
387 | ||
388 | if (*p->flags&ISO_SUSP_TSTAMP_ATTR) | |
389 | cd9660_tstamp_conv17(ptime,&ana->inop->inode.iso_ctime); | |
390 | else | |
391 | ana->inop->inode.iso_ctime = ana->inop->inode.iso_mtime; | |
392 | ||
393 | } | |
394 | ana->fields &= ~ISO_SUSP_TSTAMP; | |
395 | return ISO_SUSP_TSTAMP; | |
396 | } | |
397 | ||
398 | static void | |
399 | cd9660_rrip_deftstamp(isodir,ana) | |
400 | struct iso_directory_record *isodir; | |
401 | ISO_RRIP_ANALYZE *ana; | |
402 | { | |
403 | cd9660_deftstamp(isodir,ana->inop,NULL); | |
404 | } | |
405 | ||
406 | /* | |
407 | * POSIX device modes | |
408 | */ | |
409 | static int | |
410 | cd9660_rrip_device(p,ana) | |
411 | ISO_RRIP_DEVICE *p; | |
412 | ISO_RRIP_ANALYZE *ana; | |
413 | { | |
414 | u_int high, low; | |
415 | ||
416 | high = isonum_733(p->dev_t_high); | |
417 | low = isonum_733(p->dev_t_low); | |
418 | ||
419 | if (high == 0) | |
420 | ana->inop->inode.iso_rdev = makedev(major(low), minor(low)); | |
421 | else | |
422 | ana->inop->inode.iso_rdev = makedev(high, minor(low)); | |
423 | ana->fields &= ~ISO_SUSP_DEVICE; | |
424 | return ISO_SUSP_DEVICE; | |
425 | } | |
426 | ||
427 | /* | |
428 | * Flag indicating | |
429 | */ | |
430 | static int | |
431 | cd9660_rrip_idflag(p,ana) | |
432 | ISO_RRIP_IDFLAG *p; | |
433 | ISO_RRIP_ANALYZE *ana; | |
434 | { | |
435 | ana->fields &= isonum_711(p->flags)|~0xff; /* don't touch high bits */ | |
436 | /* special handling of RE field */ | |
437 | if (ana->fields&ISO_SUSP_RELDIR) | |
438 | return cd9660_rrip_reldir(p,ana); | |
439 | ||
440 | return ISO_SUSP_IDFLAG; | |
441 | } | |
442 | ||
443 | /* | |
444 | * Continuation pointer | |
445 | */ | |
446 | static int | |
447 | cd9660_rrip_cont(p,ana) | |
448 | ISO_RRIP_CONT *p; | |
449 | ISO_RRIP_ANALYZE *ana; | |
450 | { | |
451 | ana->iso_ce_blk = isonum_733(p->location); | |
452 | ana->iso_ce_off = isonum_733(p->offset); | |
453 | ana->iso_ce_len = isonum_733(p->length); | |
454 | return ISO_SUSP_CONT; | |
455 | } | |
456 | ||
457 | /* | |
458 | * System Use end | |
459 | */ | |
460 | static int | |
461 | cd9660_rrip_stop(p,ana) | |
462 | ISO_SUSP_HEADER *p; | |
463 | ISO_RRIP_ANALYZE *ana; | |
464 | { | |
465 | return ISO_SUSP_STOP; | |
466 | } | |
467 | ||
468 | /* | |
469 | * Extension reference | |
470 | */ | |
471 | static int | |
472 | cd9660_rrip_extref(p,ana) | |
473 | ISO_RRIP_EXTREF *p; | |
474 | ISO_RRIP_ANALYZE *ana; | |
475 | { | |
476 | if (isonum_711(p->len_id) != 10 | |
477 | || bcmp((char *)p + 8,"RRIP_1991A",10) | |
478 | || isonum_711(p->version) != 1) | |
479 | return 0; | |
480 | ana->fields &= ~ISO_SUSP_EXTREF; | |
481 | return ISO_SUSP_EXTREF; | |
482 | } | |
483 | ||
484 | typedef struct { | |
485 | char type[2]; | |
486 | int (*func)(); | |
487 | void (*func2)(); | |
488 | int result; | |
489 | } RRIP_TABLE; | |
490 | ||
491 | static int | |
492 | cd9660_rrip_loop(isodir,ana,table) | |
493 | struct iso_directory_record *isodir; | |
494 | ISO_RRIP_ANALYZE *ana; | |
495 | RRIP_TABLE *table; | |
496 | { | |
497 | register RRIP_TABLE *ptable; | |
498 | register ISO_SUSP_HEADER *phead; | |
499 | register ISO_SUSP_HEADER *pend; | |
500 | struct buf *bp = NULL; | |
501 | char *pwhead; | |
502 | int result; | |
503 | ||
504 | /* | |
505 | * Note: If name length is odd, | |
506 | * it will be padding 1 byte after the name | |
507 | */ | |
508 | pwhead = isodir->name + isonum_711(isodir->name_len); | |
509 | if (!(isonum_711(isodir->name_len)&1)) | |
510 | pwhead++; | |
511 | ||
512 | /* If it's not the '.' entry of the root dir obey SP field */ | |
513 | if (*isodir->name != 0 | |
514 | || isonum_733(isodir->extent) != ana->imp->root_extent) | |
515 | pwhead += ana->imp->rr_skip; | |
516 | else | |
517 | pwhead += ana->imp->rr_skip0; | |
518 | ||
519 | phead = (ISO_SUSP_HEADER *)pwhead; | |
520 | pend = (ISO_SUSP_HEADER *)((char *)isodir + isonum_711(isodir->length)); | |
521 | ||
522 | result = 0; | |
523 | while (1) { | |
524 | ana->iso_ce_len = 0; | |
525 | /* | |
526 | * Note: "pend" should be more than one SUSP header | |
527 | */ | |
528 | while (pend >= phead + 1) { | |
529 | if (isonum_711(phead->version) == 1) { | |
530 | for (ptable = table; ptable->func; ptable++) { | |
531 | if (*phead->type == *ptable->type | |
532 | && phead->type[1] == ptable->type[1]) { | |
533 | result |= ptable->func(phead,ana); | |
534 | break; | |
535 | } | |
536 | } | |
537 | if (!ana->fields) | |
538 | break; | |
539 | } | |
540 | if (result&ISO_SUSP_STOP) { | |
541 | result &= ~ISO_SUSP_STOP; | |
542 | break; | |
543 | } | |
544 | /* plausibility check */ | |
545 | if (isonum_711(phead->length) < sizeof(*phead)) | |
546 | break; | |
547 | /* | |
548 | * move to next SUSP | |
549 | * Hopefully this works with newer versions, too | |
550 | */ | |
551 | phead = (ISO_SUSP_HEADER *)((char *)phead + isonum_711(phead->length)); | |
552 | } | |
553 | ||
554 | if (ana->fields && ana->iso_ce_len) { | |
555 | if (ana->iso_ce_blk >= ana->imp->volume_space_size | |
556 | || ana->iso_ce_off + ana->iso_ce_len > ana->imp->logical_block_size | |
557 | || bread(ana->imp->im_devvp, | |
558 | #if 1 // radar 1669467 - logical and physical blocksize are the same | |
559 | ana->iso_ce_blk, | |
560 | #else | |
561 | ana->iso_ce_blk << (ana->imp->im_bshift - DEV_BSHIFT), | |
562 | #endif // radar 1669467 | |
563 | ana->imp->logical_block_size, NOCRED, &bp)) | |
564 | /* what to do now? */ | |
565 | break; | |
566 | phead = (ISO_SUSP_HEADER *)(bp->b_data + ana->iso_ce_off); | |
567 | pend = (ISO_SUSP_HEADER *) ((char *)phead + ana->iso_ce_len); | |
568 | } else | |
569 | break; | |
570 | } | |
571 | if (bp) | |
572 | brelse(bp); | |
573 | /* | |
574 | * If we don't find the Basic SUSP stuffs, just set default value | |
575 | * (attribute/time stamp) | |
576 | */ | |
577 | for (ptable = table; ptable->func2; ptable++) | |
578 | if (!(ptable->result&result)) | |
579 | ptable->func2(isodir,ana); | |
580 | ||
581 | return result; | |
582 | } | |
583 | ||
584 | /* | |
585 | * Get Attributes. | |
586 | */ | |
587 | static RRIP_TABLE rrip_table_analyze[] = { | |
588 | { "PX", cd9660_rrip_attr, cd9660_rrip_defattr, ISO_SUSP_ATTR }, | |
589 | { "TF", cd9660_rrip_tstamp, cd9660_rrip_deftstamp, ISO_SUSP_TSTAMP }, | |
590 | { "PN", cd9660_rrip_device, 0, ISO_SUSP_DEVICE }, | |
591 | { "RR", cd9660_rrip_idflag, 0, ISO_SUSP_IDFLAG }, | |
592 | { "CE", cd9660_rrip_cont, 0, ISO_SUSP_CONT }, | |
593 | { "ST", cd9660_rrip_stop, 0, ISO_SUSP_STOP }, | |
594 | { "", 0, 0, 0 } | |
595 | }; | |
596 | ||
597 | int | |
598 | cd9660_rrip_analyze(isodir,inop,imp) | |
599 | struct iso_directory_record *isodir; | |
600 | struct iso_node *inop; | |
601 | struct iso_mnt *imp; | |
602 | { | |
603 | ISO_RRIP_ANALYZE analyze; | |
604 | ||
605 | analyze.inop = inop; | |
606 | analyze.imp = imp; | |
607 | analyze.fields = ISO_SUSP_ATTR|ISO_SUSP_TSTAMP|ISO_SUSP_DEVICE; | |
608 | ||
609 | return cd9660_rrip_loop(isodir,&analyze,rrip_table_analyze); | |
610 | } | |
611 | ||
612 | /* | |
613 | * Get Alternate Name. | |
614 | */ | |
615 | static RRIP_TABLE rrip_table_getname[] = { | |
616 | { "NM", cd9660_rrip_altname, cd9660_rrip_defname, ISO_SUSP_ALTNAME }, | |
617 | { "CL", cd9660_rrip_pclink, 0, ISO_SUSP_CLINK|ISO_SUSP_PLINK }, | |
618 | { "PL", cd9660_rrip_pclink, 0, ISO_SUSP_CLINK|ISO_SUSP_PLINK }, | |
619 | { "RE", cd9660_rrip_reldir, 0, ISO_SUSP_RELDIR }, | |
620 | { "RR", cd9660_rrip_idflag, 0, ISO_SUSP_IDFLAG }, | |
621 | { "CE", cd9660_rrip_cont, 0, ISO_SUSP_CONT }, | |
622 | { "ST", cd9660_rrip_stop, 0, ISO_SUSP_STOP }, | |
623 | { "", 0, 0, 0 } | |
624 | }; | |
625 | ||
626 | int | |
627 | cd9660_rrip_getname(isodir,outbuf,outlen,inump,imp) | |
628 | struct iso_directory_record *isodir; | |
629 | char *outbuf; | |
630 | u_short *outlen; | |
631 | ino_t *inump; | |
632 | struct iso_mnt *imp; | |
633 | { | |
634 | ISO_RRIP_ANALYZE analyze; | |
635 | RRIP_TABLE *tab; | |
636 | ||
637 | analyze.outbuf = outbuf; | |
638 | analyze.outlen = outlen; | |
639 | analyze.maxlen = ISO_RRIP_NAMEMAX; | |
640 | analyze.inump = inump; | |
641 | analyze.imp = imp; | |
642 | analyze.fields = ISO_SUSP_ALTNAME|ISO_SUSP_RELDIR|ISO_SUSP_CLINK|ISO_SUSP_PLINK; | |
643 | *outlen = 0; | |
644 | ||
645 | tab = rrip_table_getname; | |
646 | if (*isodir->name == 0 | |
647 | || *isodir->name == 1) { | |
648 | cd9660_rrip_defname(isodir,&analyze); | |
649 | ||
650 | analyze.fields &= ~ISO_SUSP_ALTNAME; | |
651 | tab++; | |
652 | } | |
653 | ||
654 | return cd9660_rrip_loop(isodir,&analyze,tab); | |
655 | } | |
656 | ||
657 | /* | |
658 | * Get Symbolic Link. | |
659 | */ | |
660 | static RRIP_TABLE rrip_table_getsymname[] = { | |
661 | { "SL", cd9660_rrip_slink, 0, ISO_SUSP_SLINK }, | |
662 | { "RR", cd9660_rrip_idflag, 0, ISO_SUSP_IDFLAG }, | |
663 | { "CE", cd9660_rrip_cont, 0, ISO_SUSP_CONT }, | |
664 | { "ST", cd9660_rrip_stop, 0, ISO_SUSP_STOP }, | |
665 | { "", 0, 0, 0 } | |
666 | }; | |
667 | ||
668 | int | |
669 | cd9660_rrip_getsymname(isodir,outbuf,outlen,imp) | |
670 | struct iso_directory_record *isodir; | |
671 | char *outbuf; | |
672 | u_short *outlen; | |
673 | struct iso_mnt *imp; | |
674 | { | |
675 | ISO_RRIP_ANALYZE analyze; | |
676 | ||
677 | analyze.outbuf = outbuf; | |
678 | analyze.outlen = outlen; | |
679 | *outlen = 0; | |
680 | analyze.maxlen = MAXPATHLEN; | |
681 | analyze.cont = 1; /* don't start with a slash */ | |
682 | analyze.imp = imp; | |
683 | analyze.fields = ISO_SUSP_SLINK; | |
684 | ||
685 | return (cd9660_rrip_loop(isodir,&analyze,rrip_table_getsymname)&ISO_SUSP_SLINK); | |
686 | } | |
687 | ||
688 | static RRIP_TABLE rrip_table_extref[] = { | |
689 | { "ER", cd9660_rrip_extref, 0, ISO_SUSP_EXTREF }, | |
690 | { "CE", cd9660_rrip_cont, 0, ISO_SUSP_CONT }, | |
691 | { "ST", cd9660_rrip_stop, 0, ISO_SUSP_STOP }, | |
692 | { "", 0, 0, 0 } | |
693 | }; | |
694 | ||
695 | /* | |
696 | * Check for Rock Ridge Extension and return offset of its fields. | |
697 | * Note: We insist on the ER field. | |
698 | */ | |
699 | int | |
700 | cd9660_rrip_offset(isodir,imp) | |
701 | struct iso_directory_record *isodir; | |
702 | struct iso_mnt *imp; | |
703 | { | |
704 | ISO_RRIP_OFFSET *p; | |
705 | ISO_RRIP_ANALYZE analyze; | |
706 | ||
707 | imp->rr_skip0 = 0; | |
708 | p = (ISO_RRIP_OFFSET *)(isodir->name + 1); | |
709 | if (bcmp(p,"SP\7\1\276\357",6)) { | |
710 | /* Maybe, it's a CDROM XA disc? */ | |
711 | imp->rr_skip0 = 15; | |
712 | p = (ISO_RRIP_OFFSET *)((char *)p + 15); | |
713 | if (bcmp(p,"SP\7\1\276\357",6)) | |
714 | return -1; | |
715 | } | |
716 | ||
717 | analyze.imp = imp; | |
718 | analyze.fields = ISO_SUSP_EXTREF; | |
719 | if (!(cd9660_rrip_loop(isodir,&analyze,rrip_table_extref)&ISO_SUSP_EXTREF)) | |
720 | return -1; | |
721 | ||
722 | return isonum_711(p->skip); | |
723 | } |