1*0a6a1f1dSLionel Sambuc /* $NetBSD: cd9660_rrip.c,v 1.18 2015/03/28 19:24:05 maxv Exp $ */
284d9c625SLionel Sambuc
384d9c625SLionel Sambuc /*-
484d9c625SLionel Sambuc * Copyright (c) 1993, 1994
584d9c625SLionel Sambuc * The Regents of the University of California. All rights reserved.
684d9c625SLionel Sambuc *
784d9c625SLionel Sambuc * This code is derived from software contributed to Berkeley
884d9c625SLionel Sambuc * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
984d9c625SLionel Sambuc * Support code is derived from software contributed to Berkeley
1084d9c625SLionel Sambuc * by Atsushi Murai (amurai@spec.co.jp).
1184d9c625SLionel Sambuc *
1284d9c625SLionel Sambuc * Redistribution and use in source and binary forms, with or without
1384d9c625SLionel Sambuc * modification, are permitted provided that the following conditions
1484d9c625SLionel Sambuc * are met:
1584d9c625SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
1684d9c625SLionel Sambuc * notice, this list of conditions and the following disclaimer.
1784d9c625SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
1884d9c625SLionel Sambuc * notice, this list of conditions and the following disclaimer in the
1984d9c625SLionel Sambuc * documentation and/or other materials provided with the distribution.
2084d9c625SLionel Sambuc * 3. Neither the name of the University nor the names of its contributors
2184d9c625SLionel Sambuc * may be used to endorse or promote products derived from this software
2284d9c625SLionel Sambuc * without specific prior written permission.
2384d9c625SLionel Sambuc *
2484d9c625SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2584d9c625SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2684d9c625SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2784d9c625SLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2884d9c625SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2984d9c625SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3084d9c625SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3184d9c625SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3284d9c625SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3384d9c625SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3484d9c625SLionel Sambuc * SUCH DAMAGE.
3584d9c625SLionel Sambuc *
3684d9c625SLionel Sambuc * @(#)cd9660_rrip.c 8.6 (Berkeley) 12/5/94
3784d9c625SLionel Sambuc */
3884d9c625SLionel Sambuc
3984d9c625SLionel Sambuc #include <sys/cdefs.h>
40*0a6a1f1dSLionel Sambuc __KERNEL_RCSID(0, "$NetBSD: cd9660_rrip.c,v 1.18 2015/03/28 19:24:05 maxv Exp $");
4184d9c625SLionel Sambuc
4284d9c625SLionel Sambuc #include <sys/param.h>
4384d9c625SLionel Sambuc #include <sys/systm.h>
4484d9c625SLionel Sambuc #include <sys/namei.h>
4584d9c625SLionel Sambuc #include <sys/buf.h>
4684d9c625SLionel Sambuc #include <sys/file.h>
4784d9c625SLionel Sambuc #include <sys/vnode.h>
4884d9c625SLionel Sambuc #include <sys/mount.h>
4984d9c625SLionel Sambuc #include <sys/kernel.h>
5084d9c625SLionel Sambuc #include <sys/stat.h>
5184d9c625SLionel Sambuc #include <sys/kauth.h>
5284d9c625SLionel Sambuc
5384d9c625SLionel Sambuc #include <sys/time.h>
5484d9c625SLionel Sambuc
5584d9c625SLionel Sambuc #include <fs/cd9660/iso.h>
5684d9c625SLionel Sambuc #include <fs/cd9660/cd9660_extern.h>
5784d9c625SLionel Sambuc #include <fs/cd9660/cd9660_node.h>
5884d9c625SLionel Sambuc #include <fs/cd9660/cd9660_rrip.h>
5984d9c625SLionel Sambuc #include <fs/cd9660/iso_rrip.h>
6084d9c625SLionel Sambuc
6184d9c625SLionel Sambuc typedef struct {
6284d9c625SLionel Sambuc char type[2];
6384d9c625SLionel Sambuc int (*func)(void *, ISO_RRIP_ANALYZE *);
6484d9c625SLionel Sambuc void (*func2)(void *, ISO_RRIP_ANALYZE *);
6584d9c625SLionel Sambuc int result;
6684d9c625SLionel Sambuc } RRIP_TABLE;
6784d9c625SLionel Sambuc
6884d9c625SLionel Sambuc static int cd9660_rrip_attr(void *, ISO_RRIP_ANALYZE *);
6984d9c625SLionel Sambuc static void cd9660_rrip_defattr(void *, ISO_RRIP_ANALYZE *);
7084d9c625SLionel Sambuc static int cd9660_rrip_slink(void *, ISO_RRIP_ANALYZE *);
7184d9c625SLionel Sambuc static int cd9660_rrip_altname(void *, ISO_RRIP_ANALYZE *);
7284d9c625SLionel Sambuc static void cd9660_rrip_defname(void *, ISO_RRIP_ANALYZE *);
7384d9c625SLionel Sambuc static int cd9660_rrip_pclink(void *, ISO_RRIP_ANALYZE *);
7484d9c625SLionel Sambuc static int cd9660_rrip_reldir(void *, ISO_RRIP_ANALYZE *);
7584d9c625SLionel Sambuc static int cd9660_rrip_tstamp(void *, ISO_RRIP_ANALYZE *);
7684d9c625SLionel Sambuc static void cd9660_rrip_deftstamp(void *, ISO_RRIP_ANALYZE *);
7784d9c625SLionel Sambuc static int cd9660_rrip_device(void *, ISO_RRIP_ANALYZE *);
7884d9c625SLionel Sambuc static int cd9660_rrip_idflag(void *, ISO_RRIP_ANALYZE *);
7984d9c625SLionel Sambuc static int cd9660_rrip_cont(void *, ISO_RRIP_ANALYZE *);
8084d9c625SLionel Sambuc static int cd9660_rrip_stop(void *, ISO_RRIP_ANALYZE *);
8184d9c625SLionel Sambuc static int cd9660_rrip_extref(void *, ISO_RRIP_ANALYZE *);
8284d9c625SLionel Sambuc static int cd9660_rrip_loop(struct iso_directory_record *,
8384d9c625SLionel Sambuc ISO_RRIP_ANALYZE *, const RRIP_TABLE *);
8484d9c625SLionel Sambuc /*
8584d9c625SLionel Sambuc * POSIX file attribute
8684d9c625SLionel Sambuc */
8784d9c625SLionel Sambuc static int
cd9660_rrip_attr(void * v,ISO_RRIP_ANALYZE * ana)8884d9c625SLionel Sambuc cd9660_rrip_attr(void *v, ISO_RRIP_ANALYZE *ana)
8984d9c625SLionel Sambuc {
9084d9c625SLionel Sambuc ISO_RRIP_ATTR *p = v;
9184d9c625SLionel Sambuc
9284d9c625SLionel Sambuc ana->inop->inode.iso_mode = isonum_733(p->mode);
9384d9c625SLionel Sambuc ana->inop->inode.iso_uid = isonum_733(p->uid);
9484d9c625SLionel Sambuc ana->inop->inode.iso_gid = isonum_733(p->gid);
9584d9c625SLionel Sambuc ana->inop->inode.iso_links = isonum_733(p->links);
9684d9c625SLionel Sambuc ana->fields &= ~ISO_SUSP_ATTR;
9784d9c625SLionel Sambuc return ISO_SUSP_ATTR;
9884d9c625SLionel Sambuc }
9984d9c625SLionel Sambuc
10084d9c625SLionel Sambuc static void
cd9660_rrip_defattr(void * v,ISO_RRIP_ANALYZE * ana)10184d9c625SLionel Sambuc cd9660_rrip_defattr(void *v, ISO_RRIP_ANALYZE *ana)
10284d9c625SLionel Sambuc {
10384d9c625SLionel Sambuc struct iso_directory_record *isodir = v;
10484d9c625SLionel Sambuc
10584d9c625SLionel Sambuc /* But this is a required field! */
10684d9c625SLionel Sambuc printf("RRIP without PX field?\n");
10784d9c625SLionel Sambuc cd9660_defattr(isodir, ana->inop, NULL);
10884d9c625SLionel Sambuc }
10984d9c625SLionel Sambuc
11084d9c625SLionel Sambuc /*
11184d9c625SLionel Sambuc * Symbolic Links
11284d9c625SLionel Sambuc */
11384d9c625SLionel Sambuc static int
cd9660_rrip_slink(void * v,ISO_RRIP_ANALYZE * ana)11484d9c625SLionel Sambuc cd9660_rrip_slink(void *v, ISO_RRIP_ANALYZE *ana)
11584d9c625SLionel Sambuc {
11684d9c625SLionel Sambuc ISO_RRIP_SLINK *p = v;
11784d9c625SLionel Sambuc ISO_RRIP_SLINK_COMPONENT *pcomp;
11884d9c625SLionel Sambuc ISO_RRIP_SLINK_COMPONENT *pcompe;
11984d9c625SLionel Sambuc int len, wlen, cont;
12084d9c625SLionel Sambuc char *outbuf;
12184d9c625SLionel Sambuc const char *inbuf;
12284d9c625SLionel Sambuc
12384d9c625SLionel Sambuc pcomp = (ISO_RRIP_SLINK_COMPONENT *)p->component;
12484d9c625SLionel Sambuc pcompe = (ISO_RRIP_SLINK_COMPONENT *)
12584d9c625SLionel Sambuc ((char *)p + isonum_711(p->h.length));
12684d9c625SLionel Sambuc len = *ana->outlen;
12784d9c625SLionel Sambuc outbuf = ana->outbuf;
12884d9c625SLionel Sambuc cont = ana->cont;
12984d9c625SLionel Sambuc
13084d9c625SLionel Sambuc /*
13184d9c625SLionel Sambuc * Gathering a Symbolic name from each component with path
13284d9c625SLionel Sambuc */
13384d9c625SLionel Sambuc for (;
13484d9c625SLionel Sambuc pcomp < pcompe;
13584d9c625SLionel Sambuc pcomp = (ISO_RRIP_SLINK_COMPONENT *)((char *)pcomp + ISO_RRIP_SLSIZ
13684d9c625SLionel Sambuc + isonum_711(pcomp->clen))) {
13784d9c625SLionel Sambuc
13884d9c625SLionel Sambuc if (!cont) {
13984d9c625SLionel Sambuc if (len < ana->maxlen) {
14084d9c625SLionel Sambuc len++;
14184d9c625SLionel Sambuc *outbuf++ = '/';
14284d9c625SLionel Sambuc }
14384d9c625SLionel Sambuc }
14484d9c625SLionel Sambuc cont = 0;
14584d9c625SLionel Sambuc
14684d9c625SLionel Sambuc inbuf = "..";
14784d9c625SLionel Sambuc wlen = 0;
14884d9c625SLionel Sambuc
14984d9c625SLionel Sambuc switch (*pcomp->cflag) {
15084d9c625SLionel Sambuc
15184d9c625SLionel Sambuc case ISO_SUSP_CFLAG_CURRENT:
15284d9c625SLionel Sambuc /* Inserting Current */
15384d9c625SLionel Sambuc wlen = 1;
15484d9c625SLionel Sambuc break;
15584d9c625SLionel Sambuc
15684d9c625SLionel Sambuc case ISO_SUSP_CFLAG_PARENT:
15784d9c625SLionel Sambuc /* Inserting Parent */
15884d9c625SLionel Sambuc wlen = 2;
15984d9c625SLionel Sambuc break;
16084d9c625SLionel Sambuc
16184d9c625SLionel Sambuc case ISO_SUSP_CFLAG_ROOT:
16284d9c625SLionel Sambuc /* Inserting slash for ROOT */
16384d9c625SLionel Sambuc /* start over from beginning(?) */
16484d9c625SLionel Sambuc outbuf -= len;
16584d9c625SLionel Sambuc len = 0;
16684d9c625SLionel Sambuc break;
16784d9c625SLionel Sambuc
16884d9c625SLionel Sambuc case ISO_SUSP_CFLAG_VOLROOT:
16984d9c625SLionel Sambuc /* Inserting a mount point i.e. "/cdrom" */
17084d9c625SLionel Sambuc /* same as above */
17184d9c625SLionel Sambuc outbuf -= len;
17284d9c625SLionel Sambuc len = 0;
17384d9c625SLionel Sambuc inbuf = ana->imp->im_mountp->mnt_stat.f_mntonname;
17484d9c625SLionel Sambuc wlen = strlen(inbuf);
17584d9c625SLionel Sambuc break;
17684d9c625SLionel Sambuc
17784d9c625SLionel Sambuc case ISO_SUSP_CFLAG_HOST:
17884d9c625SLionel Sambuc /* Inserting hostname i.e. "kurt.tools.de" */
17984d9c625SLionel Sambuc inbuf = hostname;
18084d9c625SLionel Sambuc wlen = hostnamelen;
18184d9c625SLionel Sambuc break;
18284d9c625SLionel Sambuc
18384d9c625SLionel Sambuc case ISO_SUSP_CFLAG_CONTINUE:
18484d9c625SLionel Sambuc cont = 1;
18584d9c625SLionel Sambuc /* fall thru */
18684d9c625SLionel Sambuc case 0:
18784d9c625SLionel Sambuc /* Inserting component */
18884d9c625SLionel Sambuc wlen = isonum_711(pcomp->clen);
18984d9c625SLionel Sambuc inbuf = pcomp->name;
19084d9c625SLionel Sambuc break;
19184d9c625SLionel Sambuc default:
19284d9c625SLionel Sambuc printf("RRIP with incorrect flags?");
19384d9c625SLionel Sambuc wlen = ana->maxlen + 1;
19484d9c625SLionel Sambuc break;
19584d9c625SLionel Sambuc }
19684d9c625SLionel Sambuc
19784d9c625SLionel Sambuc if (len + wlen > ana->maxlen) {
19884d9c625SLionel Sambuc /* indicate error to caller */
19984d9c625SLionel Sambuc ana->cont = 1;
20084d9c625SLionel Sambuc ana->fields = 0;
20184d9c625SLionel Sambuc ana->outbuf -= *ana->outlen;
20284d9c625SLionel Sambuc *ana->outlen = 0;
20384d9c625SLionel Sambuc return 0;
20484d9c625SLionel Sambuc }
20584d9c625SLionel Sambuc
20684d9c625SLionel Sambuc memcpy(outbuf, inbuf, wlen);
20784d9c625SLionel Sambuc outbuf += wlen;
20884d9c625SLionel Sambuc len += wlen;
20984d9c625SLionel Sambuc }
21084d9c625SLionel Sambuc ana->outbuf = outbuf;
21184d9c625SLionel Sambuc *ana->outlen = len;
21284d9c625SLionel Sambuc ana->cont = cont;
21384d9c625SLionel Sambuc
21484d9c625SLionel Sambuc if (!isonum_711(p->flags)) {
21584d9c625SLionel Sambuc ana->fields &= ~ISO_SUSP_SLINK;
21684d9c625SLionel Sambuc return ISO_SUSP_SLINK;
21784d9c625SLionel Sambuc }
21884d9c625SLionel Sambuc return 0;
21984d9c625SLionel Sambuc }
22084d9c625SLionel Sambuc
22184d9c625SLionel Sambuc /*
22284d9c625SLionel Sambuc * Alternate name
22384d9c625SLionel Sambuc */
22484d9c625SLionel Sambuc static int
cd9660_rrip_altname(void * v,ISO_RRIP_ANALYZE * ana)22584d9c625SLionel Sambuc cd9660_rrip_altname(void *v, ISO_RRIP_ANALYZE *ana)
22684d9c625SLionel Sambuc {
22784d9c625SLionel Sambuc ISO_RRIP_ALTNAME *p = v;
22884d9c625SLionel Sambuc const char *inbuf;
22984d9c625SLionel Sambuc int wlen;
23084d9c625SLionel Sambuc int cont;
23184d9c625SLionel Sambuc
23284d9c625SLionel Sambuc inbuf = "..";
23384d9c625SLionel Sambuc wlen = 0;
23484d9c625SLionel Sambuc cont = 0;
23584d9c625SLionel Sambuc
23684d9c625SLionel Sambuc switch (*p->flags) {
23784d9c625SLionel Sambuc case ISO_SUSP_CFLAG_CURRENT:
23884d9c625SLionel Sambuc /* Inserting Current */
23984d9c625SLionel Sambuc wlen = 1;
24084d9c625SLionel Sambuc break;
24184d9c625SLionel Sambuc
24284d9c625SLionel Sambuc case ISO_SUSP_CFLAG_PARENT:
24384d9c625SLionel Sambuc /* Inserting Parent */
24484d9c625SLionel Sambuc wlen = 2;
24584d9c625SLionel Sambuc break;
24684d9c625SLionel Sambuc
24784d9c625SLionel Sambuc case ISO_SUSP_CFLAG_HOST:
24884d9c625SLionel Sambuc /* Inserting hostname i.e. "kurt.tools.de" */
24984d9c625SLionel Sambuc inbuf = hostname;
25084d9c625SLionel Sambuc wlen = hostnamelen;
25184d9c625SLionel Sambuc break;
25284d9c625SLionel Sambuc
25384d9c625SLionel Sambuc case ISO_SUSP_CFLAG_CONTINUE:
25484d9c625SLionel Sambuc cont = 1;
25584d9c625SLionel Sambuc /* fall thru */
25684d9c625SLionel Sambuc case 0:
25784d9c625SLionel Sambuc /* Inserting component */
25884d9c625SLionel Sambuc wlen = isonum_711(p->h.length) - 5;
25984d9c625SLionel Sambuc inbuf = (char *)p + 5;
26084d9c625SLionel Sambuc break;
26184d9c625SLionel Sambuc
26284d9c625SLionel Sambuc default:
26384d9c625SLionel Sambuc printf("RRIP with incorrect NM flags?\n");
26484d9c625SLionel Sambuc wlen = ana->maxlen + 1;
26584d9c625SLionel Sambuc break;
26684d9c625SLionel Sambuc }
26784d9c625SLionel Sambuc
26884d9c625SLionel Sambuc if ((*ana->outlen += wlen) > ana->maxlen) {
26984d9c625SLionel Sambuc /* treat as no name field */
27084d9c625SLionel Sambuc ana->fields &= ~ISO_SUSP_ALTNAME;
27184d9c625SLionel Sambuc ana->outbuf -= *ana->outlen - wlen;
27284d9c625SLionel Sambuc *ana->outlen = 0;
27384d9c625SLionel Sambuc return 0;
27484d9c625SLionel Sambuc }
27584d9c625SLionel Sambuc
27684d9c625SLionel Sambuc memcpy(ana->outbuf, inbuf, wlen);
27784d9c625SLionel Sambuc ana->outbuf += wlen;
27884d9c625SLionel Sambuc
27984d9c625SLionel Sambuc if (!cont) {
28084d9c625SLionel Sambuc ana->fields &= ~ISO_SUSP_ALTNAME;
28184d9c625SLionel Sambuc return ISO_SUSP_ALTNAME;
28284d9c625SLionel Sambuc }
28384d9c625SLionel Sambuc return 0;
28484d9c625SLionel Sambuc }
28584d9c625SLionel Sambuc
28684d9c625SLionel Sambuc static void
cd9660_rrip_defname(void * v,ISO_RRIP_ANALYZE * ana)28784d9c625SLionel Sambuc cd9660_rrip_defname(void *v, ISO_RRIP_ANALYZE *ana)
28884d9c625SLionel Sambuc {
28984d9c625SLionel Sambuc struct iso_directory_record *isodir = v;
29084d9c625SLionel Sambuc
29184d9c625SLionel Sambuc isofntrans(isodir->name, isonum_711(isodir->name_len),
29284d9c625SLionel Sambuc ana->outbuf, ana->outlen,
29384d9c625SLionel Sambuc 1, 0, isonum_711(isodir->flags) & 4,
29484d9c625SLionel Sambuc ana->imp->im_joliet_level);
29584d9c625SLionel Sambuc switch (ana->outbuf[0]) {
29684d9c625SLionel Sambuc default:
29784d9c625SLionel Sambuc break;
29884d9c625SLionel Sambuc case 0:
29984d9c625SLionel Sambuc ana->outbuf[0] = '.';
30084d9c625SLionel Sambuc *ana->outlen = 1;
30184d9c625SLionel Sambuc break;
30284d9c625SLionel Sambuc case 1:
30384d9c625SLionel Sambuc strlcpy(ana->outbuf, "..", ana->maxlen - *ana->outlen);
30484d9c625SLionel Sambuc *ana->outlen = 2;
30584d9c625SLionel Sambuc break;
30684d9c625SLionel Sambuc }
30784d9c625SLionel Sambuc }
30884d9c625SLionel Sambuc
30984d9c625SLionel Sambuc /*
31084d9c625SLionel Sambuc * Parent or Child Link
31184d9c625SLionel Sambuc */
31284d9c625SLionel Sambuc static int
cd9660_rrip_pclink(void * v,ISO_RRIP_ANALYZE * ana)31384d9c625SLionel Sambuc cd9660_rrip_pclink(void *v, ISO_RRIP_ANALYZE *ana)
31484d9c625SLionel Sambuc {
31584d9c625SLionel Sambuc ISO_RRIP_CLINK *p = v;
31684d9c625SLionel Sambuc
31784d9c625SLionel Sambuc *ana->inump = isonum_733(p->dir_loc) << ana->imp->im_bshift;
31884d9c625SLionel Sambuc ana->fields &= ~(ISO_SUSP_CLINK | ISO_SUSP_PLINK);
31984d9c625SLionel Sambuc return *p->h.type == 'C' ? ISO_SUSP_CLINK : ISO_SUSP_PLINK;
32084d9c625SLionel Sambuc }
32184d9c625SLionel Sambuc
32284d9c625SLionel Sambuc /*
32384d9c625SLionel Sambuc * Relocated directory
32484d9c625SLionel Sambuc */
32584d9c625SLionel Sambuc /*ARGSUSED*/
32684d9c625SLionel Sambuc static int
cd9660_rrip_reldir(void * v,ISO_RRIP_ANALYZE * ana)32784d9c625SLionel Sambuc cd9660_rrip_reldir(void *v, ISO_RRIP_ANALYZE *ana)
32884d9c625SLionel Sambuc {
32984d9c625SLionel Sambuc /* special hack to make caller aware of RE field */
33084d9c625SLionel Sambuc *ana->outlen = 0;
33184d9c625SLionel Sambuc ana->fields = 0;
33284d9c625SLionel Sambuc return ISO_SUSP_RELDIR | ISO_SUSP_ALTNAME
33384d9c625SLionel Sambuc | ISO_SUSP_CLINK | ISO_SUSP_PLINK;
33484d9c625SLionel Sambuc }
33584d9c625SLionel Sambuc
33684d9c625SLionel Sambuc static int
cd9660_rrip_tstamp(void * v,ISO_RRIP_ANALYZE * ana)33784d9c625SLionel Sambuc cd9660_rrip_tstamp(void *v, ISO_RRIP_ANALYZE *ana)
33884d9c625SLionel Sambuc {
33984d9c625SLionel Sambuc ISO_RRIP_TSTAMP *p = v;
34084d9c625SLionel Sambuc u_char *ptime;
34184d9c625SLionel Sambuc
34284d9c625SLionel Sambuc ptime = p->time;
34384d9c625SLionel Sambuc
34484d9c625SLionel Sambuc /* Check a format of time stamp (7bytes/17bytes) */
34584d9c625SLionel Sambuc if (!(*p->flags & ISO_SUSP_TSTAMP_FORM17)) {
34684d9c625SLionel Sambuc if (*p->flags & ISO_SUSP_TSTAMP_CREAT)
34784d9c625SLionel Sambuc ptime += 7;
34884d9c625SLionel Sambuc
34984d9c625SLionel Sambuc if (*p->flags & ISO_SUSP_TSTAMP_MODIFY) {
35084d9c625SLionel Sambuc cd9660_tstamp_conv7(ptime, &ana->inop->inode.iso_mtime);
35184d9c625SLionel Sambuc ptime += 7;
35284d9c625SLionel Sambuc } else
35384d9c625SLionel Sambuc memset(&ana->inop->inode.iso_mtime, 0, sizeof(struct timespec));
35484d9c625SLionel Sambuc
35584d9c625SLionel Sambuc if (*p->flags & ISO_SUSP_TSTAMP_ACCESS) {
35684d9c625SLionel Sambuc cd9660_tstamp_conv7(ptime, &ana->inop->inode.iso_atime);
35784d9c625SLionel Sambuc ptime += 7;
35884d9c625SLionel Sambuc } else
35984d9c625SLionel Sambuc ana->inop->inode.iso_atime = ana->inop->inode.iso_mtime;
36084d9c625SLionel Sambuc
36184d9c625SLionel Sambuc if (*p->flags & ISO_SUSP_TSTAMP_ATTR)
36284d9c625SLionel Sambuc cd9660_tstamp_conv7(ptime, &ana->inop->inode.iso_ctime);
36384d9c625SLionel Sambuc else
36484d9c625SLionel Sambuc ana->inop->inode.iso_ctime = ana->inop->inode.iso_mtime;
36584d9c625SLionel Sambuc
36684d9c625SLionel Sambuc } else {
36784d9c625SLionel Sambuc if (*p->flags & ISO_SUSP_TSTAMP_CREAT)
36884d9c625SLionel Sambuc ptime += 17;
36984d9c625SLionel Sambuc
37084d9c625SLionel Sambuc if (*p->flags & ISO_SUSP_TSTAMP_MODIFY) {
37184d9c625SLionel Sambuc cd9660_tstamp_conv17(ptime, &ana->inop->inode.iso_mtime);
37284d9c625SLionel Sambuc ptime += 17;
37384d9c625SLionel Sambuc } else
37484d9c625SLionel Sambuc memset(&ana->inop->inode.iso_mtime, 0, sizeof(struct timespec));
37584d9c625SLionel Sambuc
37684d9c625SLionel Sambuc if (*p->flags & ISO_SUSP_TSTAMP_ACCESS) {
37784d9c625SLionel Sambuc cd9660_tstamp_conv17(ptime, &ana->inop->inode.iso_atime);
37884d9c625SLionel Sambuc ptime += 17;
37984d9c625SLionel Sambuc } else
38084d9c625SLionel Sambuc ana->inop->inode.iso_atime = ana->inop->inode.iso_mtime;
38184d9c625SLionel Sambuc
38284d9c625SLionel Sambuc if (*p->flags & ISO_SUSP_TSTAMP_ATTR)
38384d9c625SLionel Sambuc cd9660_tstamp_conv17(ptime, &ana->inop->inode.iso_ctime);
38484d9c625SLionel Sambuc else
38584d9c625SLionel Sambuc ana->inop->inode.iso_ctime = ana->inop->inode.iso_mtime;
38684d9c625SLionel Sambuc
38784d9c625SLionel Sambuc }
38884d9c625SLionel Sambuc ana->fields &= ~ISO_SUSP_TSTAMP;
38984d9c625SLionel Sambuc return ISO_SUSP_TSTAMP;
39084d9c625SLionel Sambuc }
39184d9c625SLionel Sambuc
39284d9c625SLionel Sambuc static void
cd9660_rrip_deftstamp(void * v,ISO_RRIP_ANALYZE * ana)39384d9c625SLionel Sambuc cd9660_rrip_deftstamp(void *v, ISO_RRIP_ANALYZE *ana)
39484d9c625SLionel Sambuc {
39584d9c625SLionel Sambuc struct iso_directory_record *isodir = v;
39684d9c625SLionel Sambuc
39784d9c625SLionel Sambuc cd9660_deftstamp(isodir, ana->inop, NULL);
39884d9c625SLionel Sambuc }
39984d9c625SLionel Sambuc
40084d9c625SLionel Sambuc /*
40184d9c625SLionel Sambuc * POSIX device modes
40284d9c625SLionel Sambuc */
40384d9c625SLionel Sambuc static int
cd9660_rrip_device(void * v,ISO_RRIP_ANALYZE * ana)40484d9c625SLionel Sambuc cd9660_rrip_device(void *v, ISO_RRIP_ANALYZE *ana)
40584d9c625SLionel Sambuc {
40684d9c625SLionel Sambuc ISO_RRIP_DEVICE *p = v;
40784d9c625SLionel Sambuc u_int high, low;
40884d9c625SLionel Sambuc
40984d9c625SLionel Sambuc high = isonum_733(p->dev_t_high);
41084d9c625SLionel Sambuc low = isonum_733(p->dev_t_low);
41184d9c625SLionel Sambuc
41284d9c625SLionel Sambuc if (high == 0)
41384d9c625SLionel Sambuc ana->inop->inode.iso_rdev = makedev(major(low), minor(low));
41484d9c625SLionel Sambuc else
41584d9c625SLionel Sambuc ana->inop->inode.iso_rdev = makedev(high, minor(low));
41684d9c625SLionel Sambuc ana->fields &= ~ISO_SUSP_DEVICE;
41784d9c625SLionel Sambuc return ISO_SUSP_DEVICE;
41884d9c625SLionel Sambuc }
41984d9c625SLionel Sambuc
42084d9c625SLionel Sambuc /*
42184d9c625SLionel Sambuc * Flag indicating
42284d9c625SLionel Sambuc */
42384d9c625SLionel Sambuc static int
cd9660_rrip_idflag(void * v,ISO_RRIP_ANALYZE * ana)42484d9c625SLionel Sambuc cd9660_rrip_idflag(void *v, ISO_RRIP_ANALYZE *ana)
42584d9c625SLionel Sambuc {
42684d9c625SLionel Sambuc ISO_RRIP_IDFLAG *p = v;
42784d9c625SLionel Sambuc
42884d9c625SLionel Sambuc ana->fields &= isonum_711(p->flags) | ~0xff; /* don't touch high bits */
42984d9c625SLionel Sambuc /* special handling of RE field */
43084d9c625SLionel Sambuc if (ana->fields & ISO_SUSP_RELDIR)
43184d9c625SLionel Sambuc return cd9660_rrip_reldir(p, ana);
43284d9c625SLionel Sambuc
43384d9c625SLionel Sambuc return ISO_SUSP_IDFLAG;
43484d9c625SLionel Sambuc }
43584d9c625SLionel Sambuc
43684d9c625SLionel Sambuc /*
43784d9c625SLionel Sambuc * Continuation pointer
43884d9c625SLionel Sambuc */
43984d9c625SLionel Sambuc static int
cd9660_rrip_cont(void * v,ISO_RRIP_ANALYZE * ana)44084d9c625SLionel Sambuc cd9660_rrip_cont(void *v, ISO_RRIP_ANALYZE *ana)
44184d9c625SLionel Sambuc {
44284d9c625SLionel Sambuc ISO_RRIP_CONT *p = v;
44384d9c625SLionel Sambuc
44484d9c625SLionel Sambuc ana->iso_ce_blk = isonum_733(p->location);
44584d9c625SLionel Sambuc ana->iso_ce_off = isonum_733(p->offset);
44684d9c625SLionel Sambuc ana->iso_ce_len = isonum_733(p->length);
44784d9c625SLionel Sambuc return ISO_SUSP_CONT;
44884d9c625SLionel Sambuc }
44984d9c625SLionel Sambuc
45084d9c625SLionel Sambuc /*
45184d9c625SLionel Sambuc * System Use end
45284d9c625SLionel Sambuc */
45384d9c625SLionel Sambuc static int
cd9660_rrip_stop(void * v,ISO_RRIP_ANALYZE * ana)45484d9c625SLionel Sambuc cd9660_rrip_stop(void *v, ISO_RRIP_ANALYZE *ana)
45584d9c625SLionel Sambuc {
45684d9c625SLionel Sambuc return ISO_SUSP_STOP;
45784d9c625SLionel Sambuc }
45884d9c625SLionel Sambuc
45984d9c625SLionel Sambuc /*
46084d9c625SLionel Sambuc * Extension reference
46184d9c625SLionel Sambuc */
46284d9c625SLionel Sambuc static int
cd9660_rrip_extref(void * v,ISO_RRIP_ANALYZE * ana)46384d9c625SLionel Sambuc cd9660_rrip_extref(void *v, ISO_RRIP_ANALYZE *ana)
46484d9c625SLionel Sambuc {
46584d9c625SLionel Sambuc ISO_RRIP_EXTREF *p = v;
46684d9c625SLionel Sambuc
46784d9c625SLionel Sambuc if (isonum_711(p->version) != 1)
46884d9c625SLionel Sambuc return 0;
46984d9c625SLionel Sambuc if (isonum_711(p->len_id) != 9
47084d9c625SLionel Sambuc && isonum_711(p->len_id) != 10)
47184d9c625SLionel Sambuc return 0;
47284d9c625SLionel Sambuc if (isonum_711(p->len_id) == 9
47384d9c625SLionel Sambuc && memcmp((char *)p + 8, "IEEE_1282", 9))
47484d9c625SLionel Sambuc return 0;
47584d9c625SLionel Sambuc if (isonum_711(p->len_id) == 10
47684d9c625SLionel Sambuc && memcmp((char *)p + 8, "IEEE_P1282", 10)
47784d9c625SLionel Sambuc && memcmp((char *)p + 8, "RRIP_1991A", 10))
47884d9c625SLionel Sambuc return 0;
47984d9c625SLionel Sambuc ana->fields &= ~ISO_SUSP_EXTREF;
48084d9c625SLionel Sambuc return ISO_SUSP_EXTREF;
48184d9c625SLionel Sambuc }
48284d9c625SLionel Sambuc
48384d9c625SLionel Sambuc
48484d9c625SLionel Sambuc static int
cd9660_rrip_loop(struct iso_directory_record * isodir,ISO_RRIP_ANALYZE * ana,const RRIP_TABLE * table)48584d9c625SLionel Sambuc cd9660_rrip_loop(struct iso_directory_record *isodir, ISO_RRIP_ANALYZE *ana,
48684d9c625SLionel Sambuc const RRIP_TABLE *table)
48784d9c625SLionel Sambuc {
48884d9c625SLionel Sambuc const RRIP_TABLE *ptable;
48984d9c625SLionel Sambuc ISO_SUSP_HEADER *phead;
49084d9c625SLionel Sambuc ISO_SUSP_HEADER *pend;
49184d9c625SLionel Sambuc struct buf *bp = NULL;
49284d9c625SLionel Sambuc char *pwhead;
49384d9c625SLionel Sambuc u_int16_t c;
49484d9c625SLionel Sambuc int result;
49584d9c625SLionel Sambuc
49684d9c625SLionel Sambuc /*
49784d9c625SLionel Sambuc * Note: If name length is odd,
49884d9c625SLionel Sambuc * it will be padded by 1 byte after the name
49984d9c625SLionel Sambuc */
50084d9c625SLionel Sambuc pwhead = isodir->name + isonum_711(isodir->name_len);
50184d9c625SLionel Sambuc if (!(isonum_711(isodir->name_len) & 1))
50284d9c625SLionel Sambuc pwhead++;
50384d9c625SLionel Sambuc isochar(isodir->name, pwhead, ana->imp->im_joliet_level, &c);
50484d9c625SLionel Sambuc
50584d9c625SLionel Sambuc /* If it's not the '.' entry of the root dir obey SP field */
50684d9c625SLionel Sambuc if (c != 0 || isonum_733(isodir->extent) != ana->imp->root_extent)
50784d9c625SLionel Sambuc pwhead += ana->imp->rr_skip;
50884d9c625SLionel Sambuc else
50984d9c625SLionel Sambuc pwhead += ana->imp->rr_skip0;
51084d9c625SLionel Sambuc
51184d9c625SLionel Sambuc phead = (ISO_SUSP_HEADER *)pwhead;
51284d9c625SLionel Sambuc pend = (ISO_SUSP_HEADER *)((char *)isodir + isonum_711(isodir->length));
51384d9c625SLionel Sambuc
51484d9c625SLionel Sambuc result = 0;
51584d9c625SLionel Sambuc while (1) {
51684d9c625SLionel Sambuc ana->iso_ce_len = 0;
51784d9c625SLionel Sambuc /*
51884d9c625SLionel Sambuc * Note: "pend" should be more than one SUSP header
51984d9c625SLionel Sambuc */
52084d9c625SLionel Sambuc while (pend >= phead + 1) {
52184d9c625SLionel Sambuc if (isonum_711(phead->version) == 1) {
52284d9c625SLionel Sambuc for (ptable = table; ptable->func; ptable++) {
52384d9c625SLionel Sambuc if (*phead->type == *ptable->type
52484d9c625SLionel Sambuc && phead->type[1] == ptable->type[1]) {
52584d9c625SLionel Sambuc result |= ptable->func(phead, ana);
52684d9c625SLionel Sambuc break;
52784d9c625SLionel Sambuc }
52884d9c625SLionel Sambuc }
52984d9c625SLionel Sambuc if (!ana->fields)
53084d9c625SLionel Sambuc break;
53184d9c625SLionel Sambuc }
53284d9c625SLionel Sambuc if (result & ISO_SUSP_STOP) {
53384d9c625SLionel Sambuc result &= ~ISO_SUSP_STOP;
53484d9c625SLionel Sambuc break;
53584d9c625SLionel Sambuc }
53684d9c625SLionel Sambuc /* plausibility check */
53784d9c625SLionel Sambuc if (isonum_711(phead->length) < sizeof(*phead))
53884d9c625SLionel Sambuc break;
53984d9c625SLionel Sambuc /*
54084d9c625SLionel Sambuc * move to next SUSP
54184d9c625SLionel Sambuc * Hopefully this works with newer versions, too
54284d9c625SLionel Sambuc */
54384d9c625SLionel Sambuc phead = (ISO_SUSP_HEADER *)((char *)phead + isonum_711(phead->length));
54484d9c625SLionel Sambuc }
54584d9c625SLionel Sambuc
54684d9c625SLionel Sambuc if (ana->fields && ana->iso_ce_len) {
54784d9c625SLionel Sambuc if (ana->iso_ce_blk >= ana->imp->volume_space_size
54884d9c625SLionel Sambuc || ana->iso_ce_off + ana->iso_ce_len > ana->imp->logical_block_size
54984d9c625SLionel Sambuc || bread(ana->imp->im_devvp,
55084d9c625SLionel Sambuc ana->iso_ce_blk << (ana->imp->im_bshift - DEV_BSHIFT),
551*0a6a1f1dSLionel Sambuc ana->imp->logical_block_size,
55284d9c625SLionel Sambuc 0, &bp))
55384d9c625SLionel Sambuc /* what to do now? */
55484d9c625SLionel Sambuc break;
55584d9c625SLionel Sambuc phead = (ISO_SUSP_HEADER *)((char *)bp->b_data + ana->iso_ce_off);
55684d9c625SLionel Sambuc pend = (ISO_SUSP_HEADER *)((char *)phead + ana->iso_ce_len);
55784d9c625SLionel Sambuc } else
55884d9c625SLionel Sambuc break;
55984d9c625SLionel Sambuc }
56084d9c625SLionel Sambuc if (bp)
56184d9c625SLionel Sambuc brelse(bp, 0);
56284d9c625SLionel Sambuc /*
56384d9c625SLionel Sambuc * If we don't find the Basic SUSP stuffs, just set default value
56484d9c625SLionel Sambuc * (attribute/time stamp)
56584d9c625SLionel Sambuc */
56684d9c625SLionel Sambuc for (ptable = table; ptable->func2; ptable++)
56784d9c625SLionel Sambuc if (!(ptable->result & result))
56884d9c625SLionel Sambuc ptable->func2(isodir, ana);
56984d9c625SLionel Sambuc
57084d9c625SLionel Sambuc return result;
57184d9c625SLionel Sambuc }
57284d9c625SLionel Sambuc
57384d9c625SLionel Sambuc /*
57484d9c625SLionel Sambuc * Get Attributes.
57584d9c625SLionel Sambuc */
57684d9c625SLionel Sambuc static const RRIP_TABLE rrip_table_analyze[] = {
57784d9c625SLionel Sambuc { "PX", cd9660_rrip_attr, cd9660_rrip_defattr, ISO_SUSP_ATTR },
57884d9c625SLionel Sambuc { "TF", cd9660_rrip_tstamp, cd9660_rrip_deftstamp, ISO_SUSP_TSTAMP },
57984d9c625SLionel Sambuc { "PN", cd9660_rrip_device, 0, ISO_SUSP_DEVICE },
58084d9c625SLionel Sambuc { "RR", cd9660_rrip_idflag, 0, ISO_SUSP_IDFLAG },
58184d9c625SLionel Sambuc { "CE", cd9660_rrip_cont, 0, ISO_SUSP_CONT },
58284d9c625SLionel Sambuc { "ST", cd9660_rrip_stop, 0, ISO_SUSP_STOP },
58384d9c625SLionel Sambuc { "", 0, 0, 0 }
58484d9c625SLionel Sambuc };
58584d9c625SLionel Sambuc
58684d9c625SLionel Sambuc int
cd9660_rrip_analyze(struct iso_directory_record * isodir,struct iso_node * inop,struct iso_mnt * imp)58784d9c625SLionel Sambuc cd9660_rrip_analyze(struct iso_directory_record *isodir, struct iso_node *inop,
58884d9c625SLionel Sambuc struct iso_mnt *imp)
58984d9c625SLionel Sambuc {
59084d9c625SLionel Sambuc ISO_RRIP_ANALYZE analyze;
59184d9c625SLionel Sambuc
59284d9c625SLionel Sambuc analyze.inop = inop;
59384d9c625SLionel Sambuc analyze.imp = imp;
59484d9c625SLionel Sambuc analyze.fields = ISO_SUSP_ATTR | ISO_SUSP_TSTAMP | ISO_SUSP_DEVICE;
59584d9c625SLionel Sambuc
59684d9c625SLionel Sambuc return cd9660_rrip_loop(isodir, &analyze, rrip_table_analyze);
59784d9c625SLionel Sambuc }
59884d9c625SLionel Sambuc
59984d9c625SLionel Sambuc /*
60084d9c625SLionel Sambuc * Get Alternate Name.
60184d9c625SLionel Sambuc */
60284d9c625SLionel Sambuc static const RRIP_TABLE rrip_table_getname[] = {
60384d9c625SLionel Sambuc { "NM", cd9660_rrip_altname, cd9660_rrip_defname, ISO_SUSP_ALTNAME },
60484d9c625SLionel Sambuc { "CL", cd9660_rrip_pclink, 0, ISO_SUSP_CLINK|ISO_SUSP_PLINK },
60584d9c625SLionel Sambuc { "PL", cd9660_rrip_pclink, 0, ISO_SUSP_CLINK|ISO_SUSP_PLINK },
60684d9c625SLionel Sambuc { "RE", cd9660_rrip_reldir, 0, ISO_SUSP_RELDIR },
60784d9c625SLionel Sambuc { "RR", cd9660_rrip_idflag, 0, ISO_SUSP_IDFLAG },
60884d9c625SLionel Sambuc { "CE", cd9660_rrip_cont, 0, ISO_SUSP_CONT },
60984d9c625SLionel Sambuc { "ST", cd9660_rrip_stop, 0, ISO_SUSP_STOP },
61084d9c625SLionel Sambuc { "", 0, 0, 0 }
61184d9c625SLionel Sambuc };
61284d9c625SLionel Sambuc
61384d9c625SLionel Sambuc int
cd9660_rrip_getname(struct iso_directory_record * isodir,char * outbuf,u_short * outlen,ino_t * inump,struct iso_mnt * imp)61484d9c625SLionel Sambuc cd9660_rrip_getname(struct iso_directory_record *isodir, char *outbuf,
61584d9c625SLionel Sambuc u_short *outlen, ino_t *inump, struct iso_mnt *imp)
61684d9c625SLionel Sambuc {
61784d9c625SLionel Sambuc ISO_RRIP_ANALYZE analyze;
61884d9c625SLionel Sambuc const RRIP_TABLE *tab;
61984d9c625SLionel Sambuc u_int16_t c;
62084d9c625SLionel Sambuc
62184d9c625SLionel Sambuc analyze.outbuf = outbuf;
62284d9c625SLionel Sambuc analyze.outlen = outlen;
62384d9c625SLionel Sambuc analyze.maxlen = ISO_MAXNAMLEN;
62484d9c625SLionel Sambuc analyze.inump = inump;
62584d9c625SLionel Sambuc analyze.imp = imp;
62684d9c625SLionel Sambuc analyze.fields = ISO_SUSP_ALTNAME | ISO_SUSP_RELDIR | ISO_SUSP_CLINK | ISO_SUSP_PLINK;
62784d9c625SLionel Sambuc *outlen = 0;
62884d9c625SLionel Sambuc
62984d9c625SLionel Sambuc isochar(isodir->name, isodir->name + isonum_711(isodir->name_len),
63084d9c625SLionel Sambuc imp->im_joliet_level, &c);
63184d9c625SLionel Sambuc tab = rrip_table_getname;
63284d9c625SLionel Sambuc if (c == 0 || c == 1) {
63384d9c625SLionel Sambuc cd9660_rrip_defname(isodir, &analyze);
63484d9c625SLionel Sambuc
63584d9c625SLionel Sambuc analyze.fields &= ~ISO_SUSP_ALTNAME;
63684d9c625SLionel Sambuc tab++;
63784d9c625SLionel Sambuc }
63884d9c625SLionel Sambuc
63984d9c625SLionel Sambuc return cd9660_rrip_loop(isodir, &analyze, tab);
64084d9c625SLionel Sambuc }
64184d9c625SLionel Sambuc
64284d9c625SLionel Sambuc /*
64384d9c625SLionel Sambuc * Get Symbolic Link.
64484d9c625SLionel Sambuc */
64584d9c625SLionel Sambuc static const RRIP_TABLE rrip_table_getsymname[] = {
64684d9c625SLionel Sambuc { "SL", cd9660_rrip_slink, 0, ISO_SUSP_SLINK },
64784d9c625SLionel Sambuc { "RR", cd9660_rrip_idflag, 0, ISO_SUSP_IDFLAG },
64884d9c625SLionel Sambuc { "CE", cd9660_rrip_cont, 0, ISO_SUSP_CONT },
64984d9c625SLionel Sambuc { "ST", cd9660_rrip_stop, 0, ISO_SUSP_STOP },
65084d9c625SLionel Sambuc { "", 0, 0, 0 }
65184d9c625SLionel Sambuc };
65284d9c625SLionel Sambuc
65384d9c625SLionel Sambuc int
cd9660_rrip_getsymname(struct iso_directory_record * isodir,char * outbuf,u_short * outlen,struct iso_mnt * imp)65484d9c625SLionel Sambuc cd9660_rrip_getsymname(struct iso_directory_record *isodir, char *outbuf,
65584d9c625SLionel Sambuc u_short *outlen, struct iso_mnt *imp)
65684d9c625SLionel Sambuc {
65784d9c625SLionel Sambuc ISO_RRIP_ANALYZE analyze;
65884d9c625SLionel Sambuc
65984d9c625SLionel Sambuc analyze.outbuf = outbuf;
66084d9c625SLionel Sambuc analyze.outlen = outlen;
66184d9c625SLionel Sambuc *outlen = 0;
66284d9c625SLionel Sambuc analyze.maxlen = MAXPATHLEN;
66384d9c625SLionel Sambuc analyze.cont = 1; /* don't start with a slash */
66484d9c625SLionel Sambuc analyze.imp = imp;
66584d9c625SLionel Sambuc analyze.fields = ISO_SUSP_SLINK;
66684d9c625SLionel Sambuc
66784d9c625SLionel Sambuc return cd9660_rrip_loop(isodir, &analyze, rrip_table_getsymname) & ISO_SUSP_SLINK;
66884d9c625SLionel Sambuc }
66984d9c625SLionel Sambuc
67084d9c625SLionel Sambuc static const RRIP_TABLE rrip_table_extref[] = {
67184d9c625SLionel Sambuc { "ER", cd9660_rrip_extref, 0, ISO_SUSP_EXTREF },
67284d9c625SLionel Sambuc { "CE", cd9660_rrip_cont, 0, ISO_SUSP_CONT },
67384d9c625SLionel Sambuc { "ST", cd9660_rrip_stop, 0, ISO_SUSP_STOP },
67484d9c625SLionel Sambuc { "", 0, 0, 0 }
67584d9c625SLionel Sambuc };
67684d9c625SLionel Sambuc
67784d9c625SLionel Sambuc /*
67884d9c625SLionel Sambuc * Check for Rock Ridge Extension and return offset of its fields.
67984d9c625SLionel Sambuc * Note: We insist on the ER field.
68084d9c625SLionel Sambuc */
68184d9c625SLionel Sambuc int
cd9660_rrip_offset(struct iso_directory_record * isodir,struct iso_mnt * imp)68284d9c625SLionel Sambuc cd9660_rrip_offset(struct iso_directory_record *isodir, struct iso_mnt *imp)
68384d9c625SLionel Sambuc {
68484d9c625SLionel Sambuc ISO_RRIP_OFFSET *p;
68584d9c625SLionel Sambuc ISO_RRIP_ANALYZE analyze;
68684d9c625SLionel Sambuc
68784d9c625SLionel Sambuc imp->rr_skip0 = 0;
68884d9c625SLionel Sambuc p = (ISO_RRIP_OFFSET *)(isodir->name + 1);
68984d9c625SLionel Sambuc if (memcmp(p, "SP\7\1\276\357", 6)) {
69084d9c625SLionel Sambuc /* Maybe, it's a CDROM XA disc? */
69184d9c625SLionel Sambuc imp->rr_skip0 = 15;
69284d9c625SLionel Sambuc p = (ISO_RRIP_OFFSET *)((char *)p + 15);
69384d9c625SLionel Sambuc if (memcmp(p, "SP\7\1\276\357", 6))
69484d9c625SLionel Sambuc return -1;
69584d9c625SLionel Sambuc }
69684d9c625SLionel Sambuc
69784d9c625SLionel Sambuc analyze.imp = imp;
69884d9c625SLionel Sambuc analyze.fields = ISO_SUSP_EXTREF;
69984d9c625SLionel Sambuc if (!(cd9660_rrip_loop(isodir, &analyze, rrip_table_extref) & ISO_SUSP_EXTREF))
70084d9c625SLionel Sambuc return -1;
70184d9c625SLionel Sambuc
70284d9c625SLionel Sambuc return isonum_711(p->skip);
70384d9c625SLionel Sambuc }
704