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