diff options
Diffstat (limited to 'sys/isofs')
-rw-r--r-- | sys/isofs/cd9660/cd9660_extern.h | 9 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_lookup.c | 6 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_mount.h | 3 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_rrip.c | 14 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_util.c | 102 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_vfsops.c | 98 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_vnops.c | 16 | ||||
-rw-r--r-- | sys/isofs/cd9660/iso.h | 44 |
8 files changed, 214 insertions, 78 deletions
diff --git a/sys/isofs/cd9660/cd9660_extern.h b/sys/isofs/cd9660/cd9660_extern.h index c53d6c53e33..ebca4414354 100644 --- a/sys/isofs/cd9660/cd9660_extern.h +++ b/sys/isofs/cd9660/cd9660_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_extern.h,v 1.2 1998/02/08 22:41:32 tholo Exp $ */ +/* $OpenBSD: cd9660_extern.h,v 1.3 1999/07/01 02:20:20 d Exp $ */ /* $NetBSD: cd9660_extern.h,v 1.1 1997/01/24 00:24:53 cgd Exp $ */ /*- @@ -73,6 +73,8 @@ struct iso_mnt { int rr_skip; int rr_skip0; + + int joliet_level; }; #define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data)) @@ -106,6 +108,7 @@ extern int (**cd9660_specop_p) __P((void *)); extern int (**cd9660_fifoop_p) __P((void *)); #endif -int isofncmp __P((const u_char *, int, const u_char *, int)); -void isofntrans __P((u_char *, int, u_char *, u_short *, int, int)); +int isochar __P((const u_char *, const u_char *, int, u_char *)); +int isofncmp __P((const u_char *, int, const u_char *, int, int)); +void isofntrans __P((u_char *, int, u_char *, u_short *, int, int, int)); ino_t isodirino __P((struct iso_directory_record *, struct iso_mnt *)); diff --git a/sys/isofs/cd9660/cd9660_lookup.c b/sys/isofs/cd9660/cd9660_lookup.c index 1bc86e0781a..c542115c77f 100644 --- a/sys/isofs/cd9660/cd9660_lookup.c +++ b/sys/isofs/cd9660/cd9660_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_lookup.c,v 1.7 1997/12/02 17:47:38 csapuntz Exp $ */ +/* $OpenBSD: cd9660_lookup.c,v 1.8 1999/07/01 02:20:21 d Exp $ */ /* $NetBSD: cd9660_lookup.c,v 1.18 1997/05/08 16:19:59 mycroft Exp $ */ /*- @@ -310,8 +310,8 @@ searchloop: if (namelen != 1 || ep->name[0] != 0) goto notfound; - } else if (!(res = isofncmp(name,len, - ep->name,namelen))) { + } else if (!(res = isofncmp(name, len, + ep->name, namelen, imp->joliet_level))) { if (isonum_711(ep->flags)&2) ino = isodirino(ep, imp); else diff --git a/sys/isofs/cd9660/cd9660_mount.h b/sys/isofs/cd9660/cd9660_mount.h index 6f2e1d39d9e..40c836cc729 100644 --- a/sys/isofs/cd9660/cd9660_mount.h +++ b/sys/isofs/cd9660/cd9660_mount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_mount.h,v 1.2 1997/11/07 10:29:40 niklas Exp $ */ +/* $OpenBSD: cd9660_mount.h,v 1.3 1999/07/01 02:20:21 d Exp $ */ /* * Copyright (c) 1995 @@ -46,3 +46,4 @@ #define ISOFSMNT_NORRIP 0x00000001 /* disable Rock Ridge Ext.*/ #define ISOFSMNT_GENS 0x00000002 /* enable generation numbers */ #define ISOFSMNT_EXTATT 0x00000004 /* enable extended attributes */ +#define ISOFSMNT_NOJOLIET 0x00000008 /* disable Joliet Ext.*/ diff --git a/sys/isofs/cd9660/cd9660_rrip.c b/sys/isofs/cd9660/cd9660_rrip.c index 9bd8eb89094..2b050435eb3 100644 --- a/sys/isofs/cd9660/cd9660_rrip.c +++ b/sys/isofs/cd9660/cd9660_rrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_rrip.c,v 1.4 1997/11/08 17:21:07 niklas Exp $ */ +/* $OpenBSD: cd9660_rrip.c,v 1.5 1999/07/01 02:20:21 d Exp $ */ /* $NetBSD: cd9660_rrip.c,v 1.17 1997/01/24 00:27:32 cgd Exp $ */ /*- @@ -303,7 +303,7 @@ cd9660_rrip_defname(v, ana) default: isofntrans(isodir->name, isonum_711(isodir->name_len), ana->outbuf, ana->outlen, 1, - isonum_711(isodir->flags) & 4); + isonum_711(isodir->flags) & 4, ana->imp->joliet_level); break; case 0: *ana->outlen = 1; @@ -531,6 +531,7 @@ cd9660_rrip_loop(isodir, ana, table) register ISO_SUSP_HEADER *pend; struct buf *bp = NULL; char *pwhead; + u_char c; int result; /* @@ -540,10 +541,10 @@ cd9660_rrip_loop(isodir, ana, table) pwhead = isodir->name + isonum_711(isodir->name_len); if (!(isonum_711(isodir->name_len) & 1)) pwhead++; + isochar(isodir->name, pwhead, ana->imp->joliet_level, &c); /* If it's not the '.' entry of the root dir obey SP field */ - if (*isodir->name != 0 || - isonum_733(isodir->extent) != ana->imp->root_extent) + if (c != 0 || isonum_733(isodir->extent) != ana->imp->root_extent) pwhead += ana->imp->rr_skip; else pwhead += ana->imp->rr_skip0; @@ -683,6 +684,7 @@ cd9660_rrip_getname(isodir, outbuf, outlen, inump, imp) { ISO_RRIP_ANALYZE analyze; RRIP_TABLE *tab; + u_char c; analyze.outbuf = outbuf; analyze.outlen = outlen; @@ -693,8 +695,10 @@ cd9660_rrip_getname(isodir, outbuf, outlen, inump, imp) ISO_SUSP_PLINK; *outlen = 0; + isochar(isodir->name, isodir->name + isonum_711(isodir->name_len), + imp->joliet_level, &c); tab = rrip_table_getname; - if (*isodir->name == 0 || *isodir->name == 1) { + if (c == 0 || c == 1) { cd9660_rrip_defname(isodir, &analyze); analyze.fields &= ~ISO_SUSP_ALTNAME; diff --git a/sys/isofs/cd9660/cd9660_util.c b/sys/isofs/cd9660/cd9660_util.c index aa29e2edd54..248013dfc6a 100644 --- a/sys/isofs/cd9660/cd9660_util.c +++ b/sys/isofs/cd9660/cd9660_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_util.c,v 1.4 1997/11/08 17:21:07 niklas Exp $ */ +/* $OpenBSD: cd9660_util.c,v 1.5 1999/07/01 02:20:22 d Exp $ */ /* $NetBSD: cd9660_util.c,v 1.12 1997/01/24 00:27:33 cgd Exp $ */ /*- @@ -8,7 +8,8 @@ * 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). + * by Atsushi Murai (amurai@spec.co.jp). Joliet support was added by + * Joachim Kuebart (joki@kuebart.stuttgart.netsurf.de). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -60,35 +61,63 @@ #include <isofs/cd9660/cd9660_extern.h> /* + * Get one character out of an iso filename + * Obey joliet_level + * Return number of bytes consumed + */ +int +isochar(isofn, isoend, joliet_level, c) + const u_char *isofn; + const u_char *isoend; + int joliet_level; + u_char *c; +{ + *c = *isofn++; + if (joliet_level == 0 || isofn == isoend) + /* (00) and (01) are one byte in Joliet, too */ + return 1; + + /* No Unicode support yet :-( */ + switch (*c) { + default: + *c = '?'; + break; + case '\0': + *c = *isofn; + break; + } + return 2; +} + +/* * translate and compare a filename + * returns (fn - isofn) * Note: Version number plus ';' may be omitted. */ int -isofncmp(fn, fnlen, isofn, isolen) +isofncmp(fn, fnlen, isofn, isolen, joliet_level) const u_char *fn, *isofn; - int fnlen, isolen; + int fnlen, isolen, joliet_level; { int i, j; - char c; + u_char c; + const u_char *fnend = fn + fnlen, *isoend = isofn + isolen; - while (--fnlen >= 0) { - if (--isolen < 0) + for (; fn != fnend; fn++) { + if (isofn == isoend) return *fn; - if ((c = *isofn++) == ';') { - switch (*fn++) { - default: - return *--fn; - case 0: - return 0; - case ';': - break; - } - for (i = 0; --fnlen >= 0; i = i * 10 + *fn++ - '0') { + isofn += isochar(isofn, isoend, joliet_level, &c); + if (c == ';') { + if (*fn++ != ';') + return fn[-1]; + for (i = 0; fn != fnend; i = i * 10 + *fn++ - '0') { if (*fn < '0' || *fn > '9') { return -1; } } - for (j = 0; --isolen >= 0; j = j * 10 + *isofn++ - '0'); + for (j = 0; isofn != isoend; j = j * 10 + c - '0') + isofn += isochar(isofn, isoend, + joliet_level, &c); return i - j; } if (((u_char) c) != *fn) { @@ -102,15 +131,19 @@ isofncmp(fn, fnlen, isofn, isolen) } else return *fn - c; } - fn++; } - if (isolen > 0) { - switch (*isofn) { + if (isofn != isoend) { + isofn += isochar(isofn, isoend, joliet_level, &c); + switch (c) { default: - return -1; + return -c; case '.': - if (isofn[1] != ';') - return -1; + if (isofn != isoend) { + isochar(isofn, isoend, joliet_level, &c); + if (c == ';') + return 0; + } + return -1; case ';': return 0; } @@ -119,34 +152,33 @@ isofncmp(fn, fnlen, isofn, isolen) } /* - * translate a filename + * translate a filename of length > 0 */ void -isofntrans(infn, infnlen, outfn, outfnlen, original, assoc) +isofntrans(infn, infnlen, outfn, outfnlen, original, assoc, joliet_level) u_char *infn, *outfn; int infnlen; u_short *outfnlen; int original; int assoc; + int joliet_level; { int fnidx = 0; + u_char c, d = '\0', *infnend = infn + infnlen; if (assoc) { *outfn++ = ASSOCCHAR; fnidx++; - infnlen++; } - for (; fnidx < infnlen; fnidx++) { - char c = *infn++; + for (; infn != infnend; fnidx++) { + infn += isochar(infn, infnend, joliet_level, &c); - if (!original && c >= 'A' && c <= 'Z') - *outfn++ = c + ('a' - 'A'); - else if (!original && c == '.' && *infn == ';') - break; - else if (!original && c == ';') + if (!original && c == ';') { + fnidx -= (d == '.'); break; - else + } else *outfn++ = c; + d = c; } *outfnlen = fnidx; } diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index a8a00c2ffd5..06a4885237b 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_vfsops.c,v 1.16 1999/05/31 17:34:46 millert Exp $ */ +/* $OpenBSD: cd9660_vfsops.c,v 1.17 1999/07/01 02:20:22 d Exp $ */ /* $NetBSD: cd9660_vfsops.c,v 1.26 1997/06/13 15:38:58 pk Exp $ */ /*- @@ -63,6 +63,7 @@ #include <isofs/cd9660/cd9660_extern.h> #include <isofs/cd9660/iso_rrip.h> #include <isofs/cd9660/cd9660_node.h> +#include <isofs/cd9660/cd9660_mount.h> struct vfsops cd9660_vfsops = { cd9660_mount, @@ -223,6 +224,7 @@ iso_mountfs(devvp, mp, p, argp) { register struct iso_mnt *isomp = (struct iso_mnt *)0; struct buf *bp = NULL; + struct buf *pribp = NULL, *supbp = NULL; dev_t dev = devvp->v_rdev; int error = EINVAL; int needclose = 0; @@ -230,8 +232,10 @@ iso_mountfs(devvp, mp, p, argp) extern struct vnode *rootvp; int iso_bsize; int iso_blknum; + int joliet_level; struct iso_volume_descriptor *vdp; struct iso_primary_descriptor *pri; + struct iso_supplementary_descriptor *sup = NULL; struct iso_directory_record *rootp; int logical_block_size; @@ -262,6 +266,7 @@ iso_mountfs(devvp, mp, p, argp) */ iso_bsize = ISO_DEFAULT_BLOCK_SIZE; + joliet_level = 0; for (iso_blknum = 16; iso_blknum < 100; iso_blknum++) { if ((error = bread(devvp, iso_blknum * btodb(iso_bsize), iso_bsize, NOCRED, &bp)) != 0) @@ -273,23 +278,56 @@ iso_mountfs(devvp, mp, p, argp) goto out; } - if (isonum_711 (vdp->type) == ISO_VD_END) { - error = EINVAL; - goto out; - } - - if (isonum_711 (vdp->type) == ISO_VD_PRIMARY) + switch (isonum_711 (vdp->type)){ + case ISO_VD_PRIMARY: + if (pribp == NULL) { + pribp = bp; + bp = NULL; + pri = (struct iso_primary_descriptor *)vdp; + } + break; + case ISO_VD_SUPPLEMENTARY: + if (supbp == NULL) { + supbp = bp; + bp = NULL; + sup = (struct iso_supplementary_descriptor *)vdp; + + if (!(argp->flags & ISOFSMNT_NOJOLIET)) { + if (bcmp(sup->escape, "%/@", 3) == 0) + joliet_level = 1; + if (bcmp(sup->escape, "%/C", 3) == 0) + joliet_level = 2; + if (bcmp(sup->escape, "%/E", 3) == 0) + joliet_level = 3; + + if (isonum_711 (sup->flags) & 1) + joliet_level = 0; + } + } break; + + case ISO_VD_END: + goto vd_end; + + default: + break; + } + if (bp) { + brelse(bp); + bp = NULL; + } + } + vd_end: + if (bp) { brelse(bp); + bp = NULL; } - - if (isonum_711 (vdp->type) != ISO_VD_PRIMARY) { + + if (pri == NULL) { error = EINVAL; goto out; } - - pri = (struct iso_primary_descriptor *)vdp; - + logical_block_size = isonum_723 (pri->logical_block_size); if (logical_block_size < DEV_BSIZE || logical_block_size > MAXBSIZE @@ -307,15 +345,14 @@ iso_mountfs(devvp, mp, p, argp) bcopy (rootp, isomp->root, sizeof isomp->root); isomp->root_extent = isonum_733 (rootp->extent); isomp->root_size = isonum_733 (rootp->size); + isomp->joliet_level = 0; isomp->im_bmask = logical_block_size - 1; - isomp->im_bshift = 0; - while ((1 << isomp->im_bshift) < isomp->logical_block_size) - isomp->im_bshift++; - - bp->b_flags |= B_AGE; - brelse(bp); - bp = NULL; + isomp->im_bshift = ffs(logical_block_size) - 1; + + pribp->b_flags |= B_AGE; + brelse(pribp); + pribp = NULL; mp->mnt_data = (qaddr_t)isomp; mp->mnt_stat.f_fsid.val[0] = (long)dev; @@ -353,7 +390,7 @@ iso_mountfs(devvp, mp, p, argp) bp = NULL; } isomp->im_flags = argp->flags & (ISOFSMNT_NORRIP | ISOFSMNT_GENS | - ISOFSMNT_EXTATT); + ISOFSMNT_EXTATT | ISOFSMNT_NOJOLIET); switch (isomp->im_flags & (ISOFSMNT_NORRIP | ISOFSMNT_GENS)) { default: isomp->iso_ftype = ISO_FTYPE_DEFAULT; @@ -365,11 +402,30 @@ iso_mountfs(devvp, mp, p, argp) isomp->iso_ftype = ISO_FTYPE_RRIP; break; } - + + /* Decide whether to use the Joliet descriptor */ + + if (isomp->iso_ftype != ISO_FTYPE_RRIP && joliet_level) { + rootp = (struct iso_directory_record *) + sup->root_directory_record; + bcopy(rootp, isomp->root, sizeof isomp->root); + isomp->root_extent = isonum_733(rootp->extent); + isomp->root_size = isonum_733(rootp->size); + isomp->joliet_level = joliet_level; + supbp->b_flags |= B_AGE; + } + + if (supbp) { + brelse(supbp); + supbp = NULL; + } + return (0); out: if (bp) brelse(bp); + if (supbp) + brelse(supbp); if (needclose) (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p); diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index c8e9ee08298..b634f9ced9c 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_vnops.c,v 1.10 1998/08/06 19:34:22 csapuntz Exp $ */ +/* $OpenBSD: cd9660_vnops.c,v 1.11 1999/07/01 02:20:22 d Exp $ */ /* $NetBSD: cd9660_vnops.c,v 1.42 1997/10/16 23:56:57 christos Exp $ */ /*- @@ -636,26 +636,24 @@ cd9660_readdir(v) break; default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 */ 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: + } else { isofntrans(ep->name,idp->current.d_namlen, idp->current.d_name, &namelen, imp->iso_ftype == ISO_FTYPE_9660, - isonum_711(ep->flags)&4); + isonum_711(ep->flags) & 4, + imp->joliet_level); 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) diff --git a/sys/isofs/cd9660/iso.h b/sys/isofs/cd9660/iso.h index 19c47c153dd..13ab6416620 100644 --- a/sys/isofs/cd9660/iso.h +++ b/sys/isofs/cd9660/iso.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iso.h,v 1.8 1998/05/30 02:28:38 mickey Exp $ */ +/* $OpenBSD: iso.h,v 1.9 1999/07/01 02:20:22 d Exp $ */ /* $NetBSD: iso.h,v 1.20 1997/07/07 22:45:34 cgd Exp $ */ /*- @@ -58,6 +58,7 @@ struct iso_volume_descriptor { /* volume descriptor types */ #define ISO_VD_PRIMARY 1 +#define ISO_VD_SUPPLEMENTARY 2 #define ISO_VD_END 255 #define ISO_STANDARD_ID "CD001" @@ -101,6 +102,47 @@ struct iso_primary_descriptor { #define ISO_DEFAULT_BLOCK_SHIFT 11 #define ISO_DEFAULT_BLOCK_SIZE (1<<ISO_DEFAULT_BLOCK_SHIFT) +/* + * Used by Microsoft Joliet extension to ISO9660. Almost the same + * as PVD, but byte position 8 is a flag, and 89-120 is for escape. + */ + +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)]; + 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 */ |