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