Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Mar 1998 21:09:56 +0100 (CET)
From:      Joachim Kuebart <joki@kuebart.stuttgart.netsurf.de>
To:        current@FreeBSD.ORG
Subject:   Joliet FS Support in CD9660
Message-ID:  <199803142009.VAA01248@yacht.domestic.de>

next in thread | raw e-mail | index | archive | help

--ELM889906196-1194-0_
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Hi,

attached is a patch to support Joliet extensions to CD9660. The file
cd9660_joliet.c is also needed in /sys/isofs/cd9660.

The patch applies to the source as of March 6. I do not have time to update
now and just hope not too much has changed.

It does NOT YET run with rrip extensions, since I do not know how
these are to be intermixed. I am also not sure about High Sierra (if
this can be intermixed at all).

Note that you need to add the file cd9660_joliet.c and the line

	isofs/cd9660/cd9660_joliet.c		optional	cd9660

to conf/files or to lkm/cd9660/Makefile in order for this to work.

I would be glad to hear feedback. Note that I am not currently
subscribed to -current, so please answer personally as well.

cu Jo

---------------------------------------------------------------------
FreeBSD: The Power to Serve                  <http://www.freebsd.org>;
Joachim Kuebart
Tel: +49 711 653706          Replicants are like any other machine --
Germany                      they're either a benefit or a hazard.

--ELM889906196-1194-0_
Content-Type: text/plain; charset=ISO-8859-1
Content-Disposition: attachment; filename=joliet.diff
Content-Description: joliet.diff
Content-Transfer-Encoding: 7bit

Index: cd9660_lookup.c
===================================================================
RCS file: /usr/CVS-Repository/src/sys/isofs/cd9660/cd9660_lookup.c,v
retrieving revision 1.20
diff -u -r1.20 cd9660_lookup.c
--- cd9660_lookup.c	1997/11/07 08:52:50	1.20
+++ cd9660_lookup.c	1998/03/14 17:43:48
@@ -237,8 +237,9 @@
 					if (namelen != 1
 					    || ep->name[0] != 0)
 						goto notfound;
-				} else if (!(res = isofncmp(name,len,
-							    ep->name,namelen))) {
+				} else if (!(res = (imp->joliet_level == 0?
+					isofncmp(name,len,ep->name,namelen):
+					jolietfncmp(name,len,ep->name,namelen)))) {
 					if (isoflags & 2)
 						ino = isodirino(ep, imp);
 					else
Index: cd9660_vfsops.c
===================================================================
RCS file: /usr/CVS-Repository/src/sys/isofs/cd9660/cd9660_vfsops.c,v
retrieving revision 1.34
diff -u -r1.34 cd9660_vfsops.c
--- cd9660_vfsops.c	1998/03/01 22:46:00	1.34
+++ cd9660_vfsops.c	1998/03/14 20:45:32
@@ -271,9 +271,12 @@
 	int ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
 	int iso_bsize;
 	int iso_blknum;
+	int pri_blknum;
+	int joliet_level;
 	struct iso_volume_descriptor *vdp = 0;
 	struct iso_primary_descriptor *pri;
 	struct iso_sierra_primary_descriptor *pri_sierra;
+	struct iso_supplementary_descriptor *supp;
 	struct iso_directory_record *rootp;
 	int logical_block_size;
 
@@ -303,6 +306,8 @@
 	 */
 	iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
 
+	joliet_level = 0;
+	pri_blknum = -1;
 	for (iso_blknum = 16 + argp->ssector;
 	     iso_blknum < 100 + argp->ssector;
 	     iso_blknum++) {
@@ -320,19 +325,40 @@
 				high_sierra = 1;
 		}
 
-		if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) == ISO_VD_END) {
-			error = EINVAL;
-			goto out;
-		}
+		if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) == ISO_VD_END)
+			break;
 
 		if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) == ISO_VD_PRIMARY)
-			break;
+			pri_blknum = iso_blknum;
+
+		if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) == ISO_VD_SUPPLEMENTARY) {
+			supp = (struct iso_supplementary_descriptor *)vdp;
+			if (bcmp(supp->escape, "%/@", 3) == 0)
+				joliet_level = 1;
+			if (bcmp(supp->escape, "%/C", 3) == 0)
+				joliet_level = 2;
+			if (bcmp(supp->escape, "%/E", 3) == 0)
+				joliet_level = 3;
+			if (isonum_711 (supp->flags) & 1)
+				joliet_level = 0;
+			if (joliet_level)
+				break;
+		}
+			
 		brelse(bp);
 	}
 
-	if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) != ISO_VD_PRIMARY) {
-		error = EINVAL;
-		goto out;
+	if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) != ISO_VD_SUPPLEMENTARY) {
+		if (pri_blknum == -1) {
+			error = EINVAL;
+			goto out;
+		}
+
+		brelse(bp);
+		if (error = bread(devvp, pri_blknum * btodb(iso_bsize),
+				  iso_bsize, NOCRED, &bp))
+			goto out;
+		vdp = (struct iso_volume_descriptor *)bp->b_data;
 	}
 
 	pri = (struct iso_primary_descriptor *)vdp;
@@ -361,6 +387,7 @@
 		isonum_733 (high_sierra?
 			    pri_sierra->volume_space_size:
 			    pri->volume_space_size);
+	isomp->joliet_level = joliet_level;
 	/*
 	 * Since an ISO9660 multi-session CD can also access previous
 	 * sessions, we have to include them into the space consider-
@@ -375,9 +402,12 @@
 	isomp->root_size = isonum_733 (rootp->size);
 
 	isomp->im_bmask = logical_block_size - 1;
+/*
 	isomp->im_bshift = 0;
 	while ((1 << isomp->im_bshift) < isomp->logical_block_size)
 		isomp->im_bshift++;
+*/
+	isomp->im_bshift = ffs(logical_block_size) - 1;
 
 	bp->b_flags |= B_AGE;
 	brelse(bp);
Index: cd9660_vnops.c
===================================================================
RCS file: /usr/CVS-Repository/src/sys/isofs/cd9660/cd9660_vnops.c,v
retrieving revision 1.52
diff -u -r1.52 cd9660_vnops.c
--- cd9660_vnops.c	1998/03/06 09:46:14	1.52
+++ cd9660_vnops.c	1998/03/14 19:55:51
@@ -549,26 +549,28 @@
 			break;
 		default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 || ISO_FTYPE_HIGH_SIERRA*/
 			strcpy(idp->current.d_name,"..");
-			switch (ep->name[0]) {
-			case 0:
+			if (idp->current.d_namlen == 1 && ep->name[0] == 0) {
 				idp->current.d_namlen = 1;
 				error = iso_uiodir(idp,&idp->current,idp->curroff);
-				break;
-			case 1:
+			} else if (idp->current.d_namlen == 1 && ep->name[0] == 1) {
 				idp->current.d_namlen = 2;
 				error = iso_uiodir(idp,&idp->current,idp->curroff);
-				break;
-			default:
-				isofntrans(ep->name,idp->current.d_namlen,
-					   idp->current.d_name, &namelen,
-					   imp->iso_ftype == ISO_FTYPE_9660,
-					   isonum_711(ep->flags)&4);
+			} else {
+				if (imp->joliet_level)
+					jolietfntrans(ep->name,idp->current.d_namlen,
+						   idp->current.d_name, &namelen,
+						   imp->iso_ftype == ISO_FTYPE_9660,
+						   isonum_711(ep->flags)&4);
+				else
+					isofntrans(ep->name,idp->current.d_namlen,
+						   idp->current.d_name, &namelen,
+						   imp->iso_ftype == ISO_FTYPE_9660,
+						   isonum_711(ep->flags)&4);
 				idp->current.d_namlen = (u_char)namelen;
 				if (imp->iso_ftype == ISO_FTYPE_DEFAULT)
 					error = iso_shipdir(idp);
 				else
 					error = iso_uiodir(idp,&idp->current,idp->curroff);
-				break;
 			}
 		}
 		if (error)
Index: iso.h
===================================================================
RCS file: /usr/CVS-Repository/src/sys/isofs/cd9660/iso.h,v
retrieving revision 1.16
diff -u -r1.16 iso.h
--- iso.h	1997/05/07 13:23:04	1.16
+++ iso.h	1998/03/12 12:52:17
@@ -54,6 +54,7 @@
 
 /* volume descriptor types */
 #define ISO_VD_PRIMARY 1
+#define ISO_VD_SUPPLEMENTARY 2
 #define ISO_VD_END 255
 
 #define ISO_STANDARD_ID "CD001"
@@ -135,6 +136,42 @@
 	char unused4			[ISODCL (856, 2048)];
 };
 
+struct iso_supplementary_descriptor {
+	char type			[ISODCL (  1,	1)]; /* 711 */
+	char id				[ISODCL (  2,	6)];
+	char version			[ISODCL (  7,	7)]; /* 711 */
+	char flags			[ISODCL (  8,	8)]; /* 711? */
+	char system_id			[ISODCL (  9,  40)]; /* achars */
+	char volume_id			[ISODCL ( 41,  72)]; /* dchars */
+	char unused2			[ISODCL ( 73,  80)];
+	char volume_space_size		[ISODCL ( 81,  88)]; /* 733 */
+	char escape			[ISODCL ( 89, 120)];
+	char volume_set_size		[ISODCL (121, 124)]; /* 723 */
+	char volume_sequence_number	[ISODCL (125, 128)]; /* 723 */
+	char logical_block_size		[ISODCL (129, 132)]; /* 723 */
+	char path_table_size		[ISODCL (133, 140)]; /* 733 */
+	char type_l_path_table		[ISODCL (141, 144)]; /* 731 */
+	char opt_type_l_path_table	[ISODCL (145, 148)]; /* 731 */
+	char type_m_path_table		[ISODCL (149, 152)]; /* 732 */
+	char opt_type_m_path_table	[ISODCL (153, 156)]; /* 732 */
+	char root_directory_record	[ISODCL (157, 190)]; /* 9.1 */
+	char volume_set_id		[ISODCL (191, 318)]; /* dchars */
+	char publisher_id		[ISODCL (319, 446)]; /* achars */
+	char preparer_id		[ISODCL (447, 574)]; /* achars */
+	char application_id		[ISODCL (575, 702)]; /* achars */
+	char copyright_file_id		[ISODCL (703, 739)]; /* 7.5 dchars */
+	char abstract_file_id		[ISODCL (740, 776)]; /* 7.5 dchars */
+	char bibliographic_file_id	[ISODCL (777, 813)]; /* 7.5 dchars */
+	char creation_date		[ISODCL (814, 830)]; /* 8.4.26.1 */
+	char modification_date		[ISODCL (831, 847)]; /* 8.4.26.1 */
+	char expiration_date		[ISODCL (848, 864)]; /* 8.4.26.1 */
+	char effective_date		[ISODCL (865, 881)]; /* 8.4.26.1 */
+	char file_structure_version	[ISODCL (882, 882)]; /* 711 */
+	char unused4			[ISODCL (883, 883)];
+	char application_data		[ISODCL (884, 1395)];
+	char unused5			[ISODCL (1396, 2048)];
+};
+
 struct iso_directory_record {
 	char length			[ISODCL (1, 1)]; /* 711 */
 	char ext_attr_length		[ISODCL (2, 2)]; /* 711 */
@@ -202,6 +239,8 @@
 
 	int rr_skip;
 	int rr_skip0;
+
+	int joliet_level;
 };
 
 #define VFSTOISOFS(mp)	((struct iso_mnt *)((mp)->mnt_data))
@@ -224,6 +263,8 @@
 int isofncmp __P((u_char *, int, u_char *, int));
 void isofntrans __P((u_char *, int, u_char *, u_short *, int, int));
 ino_t isodirino __P((struct iso_directory_record *, struct iso_mnt *));
+int jolietfncmp __P((u_char *, int, u_char *, int));
+void jolietfntrans __P((u_char *, int, u_char *, u_short *, int, int));
 
 #endif /* KERNEL */
 

--ELM889906196-1194-0_
Content-Type: text/plain
Content-Disposition: attachment; filename=cd9660_joliet.c
Content-Description: cd9660_joliet.c
Content-Transfer-Encoding: 7bit

/*-
 * Copyright (c) 1994
 *	The Regents of the University of California.  All rights reserved.
 *
 * This code is derived from software contributed to Berkeley
 * by Pace Willisson (pace@blitz.com).  The Rock Ridge Extension
 * Support code is derived from software contributed to Berkeley
 * by Atsushi Murai (amurai@spec.co.jp).
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $Id$
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mount.h>
#include <sys/vnode.h>

#include <isofs/cd9660/iso.h>

/*
 * translate and compare a Joliet filename
 * Note: Version number plus ';' may be omitted.
 */
int
jolietfncmp(fn, fnlen, isofn, isolen)
	u_char *fn;
	int fnlen;
	u_char *isofn;
	int isolen;
{
	int i, j;
	unsigned int c;

	/* This is a special case for "." and ".." */
	if (isolen == 1) {
		return isofn[0] - fn[0];
	}
	if (isolen % 2) {
		printf("Joliet filename has odd length\n");
		return -1;
	}
	while (--fnlen >= 0) {
		if ((isolen -= 2) < 0)
			return *fn;
		c = (isofn[0] << 8) | isofn[1];
		isofn += 2;
		if (c & 0xff00)
			c = '?';
		if (c == ';') {
			switch (*fn++) {
			default:
				return fn[-1];
			case 0:
				return 0;
			case ';':
				break;
			}
			for (i = 0; --fnlen >= 0; i = i * 10 + *fn++ - '0')
				if (*fn < '0' || *fn > '9')
					return -1;
			for (j = 0; (isolen -= 2) >= 0; j = j * 10 + c - '0') {
				c = (isofn[0] << 8) | isofn[1];
				isofn += 2;
				if (c & 0xff00)
					c = '?';
			}
			return i - j;
		}
		if (c != *fn)
			return *fn - c;
		fn++;
	}

	if (isolen > 0) {
		c = (isofn[0] << 8) | isofn[1];
		isofn += 2;
		if (c & 0xff00)
			c = '?';
		switch (c) {
		default:
			return -1;
		case '.':
			if (isofn[1] != ';')
				return -1;
		case ';':
			return 0;
		}
	}
	return 0;
}

/*
 * translate a Joliet filename
 */
void
jolietfntrans(infn, infnlen, outfn, outfnlen, original, assoc)
	u_char *infn;
	int infnlen;
	u_char *outfn;
	u_short *outfnlen;
	int original;
	int assoc;
{
	int fnidx = 0;

	if (assoc) {
		*outfn++ = ASSOCCHAR;
		fnidx++;
		infnlen += 2;
	}
	if (infnlen % 2) {
		printf("Odd length in Joliet filename\n");
		*outfnlen = 0;
		return;
	}
	for (; fnidx < infnlen / 2; fnidx++) {
		int c = (infn[0] << 8) | infn[1];
		infn += 2;

		if (!original && c == '.' && infn[0] == 0 && infn[1] == ';')
			break;
		else if (!original && c == ';')
			break;
		if (c & 0xff00)
			c = '?';
		*outfn++ = c;
	}
	*outfnlen = fnidx;
}

--ELM889906196-1194-0_--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199803142009.VAA01248>