Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/isofs/cd9660 From patch supplied in PR-7951 by Joachim K...



details:   https://anonhg.NetBSD.org/src/rev/7792e9b7f3af
branches:  trunk
changeset: 474635:7792e9b7f3af
user:      scw <scw%NetBSD.org@localhost>
date:      Tue Jul 13 11:12:05 1999 +0000

description:
>From patch supplied in PR-7951 by Joachim Kuebart:

Add support for Microsoft Joliet long filename extensions to the
cd9660 filesystem.

diffstat:

 sys/isofs/cd9660/cd9660_extern.h |   8 ++-
 sys/isofs/cd9660/cd9660_lookup.c |   5 +-
 sys/isofs/cd9660/cd9660_mount.h  |   3 +-
 sys/isofs/cd9660/cd9660_rrip.c   |  25 ++++++----
 sys/isofs/cd9660/cd9660_util.c   |  82 +++++++++++++++++++++++++++---------
 sys/isofs/cd9660/cd9660_vfsops.c |  89 ++++++++++++++++++++++++++++++++-------
 sys/isofs/cd9660/cd9660_vnops.c  |  16 ++++---
 sys/isofs/cd9660/iso.h           |  39 +++++++++++++++++-
 8 files changed, 205 insertions(+), 62 deletions(-)

diffs (truncated from 531 to 300 lines):

diff -r 3b555b3f58b2 -r 7792e9b7f3af sys/isofs/cd9660/cd9660_extern.h
--- a/sys/isofs/cd9660/cd9660_extern.h  Tue Jul 13 10:26:05 1999 +0000
+++ b/sys/isofs/cd9660/cd9660_extern.h  Tue Jul 13 11:12:05 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_extern.h,v 1.6 1999/02/26 23:44:44 wrstuden Exp $       */
+/*     $NetBSD: cd9660_extern.h,v 1.7 1999/07/13 11:12:05 scw Exp $    */
 
 /*-
  * Copyright (c) 1994
@@ -53,6 +53,7 @@
 
 struct iso_mnt {
        int im_flags;
+       int im_joliet_level;
 
        struct mount *im_mountp;
        dev_t im_dev;
@@ -106,6 +107,7 @@
 extern int (**cd9660_specop_p) __P((void *));
 extern int (**cd9660_fifoop_p) __P((void *));
 
-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 -r 3b555b3f58b2 -r 7792e9b7f3af sys/isofs/cd9660/cd9660_lookup.c
--- a/sys/isofs/cd9660/cd9660_lookup.c  Tue Jul 13 10:26:05 1999 +0000
+++ b/sys/isofs/cd9660/cd9660_lookup.c  Tue Jul 13 11:12:05 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_lookup.c,v 1.22 1999/07/08 01:06:00 wrstuden Exp $      */
+/*     $NetBSD: cd9660_lookup.c,v 1.23 1999/07/13 11:12:05 scw Exp $   */
 
 /*-
  * Copyright (c) 1989, 1993, 1994
@@ -321,7 +321,8 @@
                                            || ep->name[0] != 0)
                                                goto notfound;
                                } else if (!(res = isofncmp(name,len,
-                                                           ep->name,namelen))) {
+                                                  ep->name,namelen,
+                                                  imp->im_joliet_level))) {
                                        if (isonum_711(ep->flags)&2)
                                                ino = isodirino(ep, imp);
                                        else
diff -r 3b555b3f58b2 -r 7792e9b7f3af sys/isofs/cd9660/cd9660_mount.h
--- a/sys/isofs/cd9660/cd9660_mount.h   Tue Jul 13 10:26:05 1999 +0000
+++ b/sys/isofs/cd9660/cd9660_mount.h   Tue Jul 13 11:12:05 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_mount.h,v 1.2 1998/03/01 02:27:49 fvdl Exp $    */
+/*     $NetBSD: cd9660_mount.h,v 1.3 1999/07/13 11:12:05 scw Exp $     */
 /*
  * Copyright (c) 1995
  *     The Regents of the University of California.  All rights reserved.
@@ -50,3 +50,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 extensions */
diff -r 3b555b3f58b2 -r 7792e9b7f3af sys/isofs/cd9660/cd9660_rrip.c
--- a/sys/isofs/cd9660/cd9660_rrip.c    Tue Jul 13 10:26:05 1999 +0000
+++ b/sys/isofs/cd9660/cd9660_rrip.c    Tue Jul 13 11:12:05 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_rrip.c,v 1.18 1998/08/09 20:42:54 perry Exp $   */
+/*     $NetBSD: cd9660_rrip.c,v 1.19 1999/07/13 11:12:06 scw Exp $     */
 
 /*-
  * Copyright (c) 1993, 1994
@@ -298,17 +298,19 @@
 {
        struct iso_directory_record *isodir = v;
 
-       strcpy(ana->outbuf, "..");
-       switch (*isodir->name) {
+       isofntrans(isodir->name, isonum_711(isodir->name_len),
+                  ana->outbuf, ana->outlen,
+                  1, isonum_711(isodir->flags) & 4,
+                  ana->imp->im_joliet_level);
+       switch (ana->outbuf[0]) {
        default:
-               isofntrans(isodir->name, isonum_711(isodir->name_len),
-                          ana->outbuf, ana->outlen,
-                          1, isonum_711(isodir->flags) & 4);
                break;
        case 0:
+               ana->outbuf[0] = '.';
                *ana->outlen = 1;
                break;
        case 1:
+               strcpy(ana->outbuf, "..");
                *ana->outlen = 2;
                break;
        }
@@ -518,6 +520,7 @@
        register ISO_SUSP_HEADER *pend;
        struct buf *bp = NULL;
        char *pwhead;
+       u_char c;
        int result;
        
        /*
@@ -527,10 +530,10 @@
        pwhead = isodir->name + isonum_711(isodir->name_len);
        if (!(isonum_711(isodir->name_len) & 1))
                pwhead++;
+       isochar(isodir->name, pwhead, ana->imp->im_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;
@@ -648,6 +651,7 @@
 {
        ISO_RRIP_ANALYZE analyze;
        RRIP_TABLE *tab;
+       u_char c;
        
        analyze.outbuf = outbuf;
        analyze.outlen = outlen;
@@ -657,9 +661,10 @@
        analyze.fields = ISO_SUSP_ALTNAME | ISO_SUSP_RELDIR | ISO_SUSP_CLINK | ISO_SUSP_PLINK;
        *outlen = 0;
        
+       isochar(isodir->name, isodir->name + isonum_711(isodir->name_len),
+               imp->im_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 -r 3b555b3f58b2 -r 7792e9b7f3af sys/isofs/cd9660/cd9660_util.c
--- a/sys/isofs/cd9660/cd9660_util.c    Tue Jul 13 10:26:05 1999 +0000
+++ b/sys/isofs/cd9660/cd9660_util.c    Tue Jul 13 11:12:05 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_util.c,v 1.12 1997/01/24 00:27:33 cgd Exp $     */
+/*     $NetBSD: cd9660_util.c,v 1.13 1999/07/13 11:12:06 scw Exp $     */
 
 /*-
  * Copyright (c) 1994
@@ -59,21 +59,51 @@
 #include <isofs/cd9660/cd9660_extern.h>
 
 /*
+ * Get one character out of an iso filename
+ * 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
  * 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;
-       
+       const u_char *isoend = isofn + isolen;
+
        while (--fnlen >= 0) {
-               if (--isolen < 0)
+               if (isofn == isoend)
                        return *fn;
-               if ((c = *isofn++) == ';') {
+               isofn += isochar(isofn, isoend, joliet_level, &c);
+               if (c == ';') {
                        switch (*fn++) {
                        default:
                                return *--fn;
@@ -87,7 +117,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) {
@@ -103,13 +135,18 @@
                }
                fn++;
        }
-       if (isolen > 0) {
-               switch (*isofn) {
+       if (isofn != isoend) {
+               isofn += isochar(isofn, isoend, joliet_level, &c);
+               switch (c) {
                default:
                        return -1;
                case '.':
-                       if (isofn[1] != ';')
-                               return -1;
+                       if (isofn != isoend) {
+                               isochar(isofn, isoend, joliet_level, &c);
+                               if (c == ';')
+                                       return 0;
+                       }
+                       return -1;
                case ';':
                        return 0;
                }
@@ -121,30 +158,33 @@
  * translate a filename
  */
 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 *infnend = infn + infnlen;
        
        if (assoc) {
                *outfn++ = ASSOCCHAR;
                fnidx++;
-               infnlen++;
        }
-       for (; fnidx < infnlen; fnidx++) {
-               char c = *infn++;
-               
-               if (!original && c >= 'A' && c <= 'Z')
+       for (; infn != infnend; fnidx++) {
+               char c;
+
+               infn += isochar(infn, infnend, joliet_level, &c);
+
+               if (!original && joliet_level == 0 && c >= 'A' && c <= 'Z')
                        *outfn++ = c + ('a' - 'A');
-               else if (!original && c == '.' && *infn == ';')
+               else if (!original && c == ';') {
+                       if (fnidx > 0 && outfn[-1] == '.')
+                               fnidx--;
                        break;
-               else if (!original && c == ';')
-                       break;
-               else
+               } else
                        *outfn++ = c;
        }
        *outfnlen = fnidx;
diff -r 3b555b3f58b2 -r 7792e9b7f3af sys/isofs/cd9660/cd9660_vfsops.c
--- a/sys/isofs/cd9660/cd9660_vfsops.c  Tue Jul 13 10:26:05 1999 +0000
+++ b/sys/isofs/cd9660/cd9660_vfsops.c  Tue Jul 13 11:12:05 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_vfsops.c,v 1.37 1999/07/08 01:06:01 wrstuden Exp $      */
+/*     $NetBSD: cd9660_vfsops.c,v 1.38 1999/07/13 11:12:06 scw Exp $   */
 
 /*-
  * Copyright (c) 1994
@@ -242,7 +242,7 @@
        struct iso_args *argp;
 {
        register struct iso_mnt *isomp = (struct iso_mnt *)0;
-       struct buf *bp = NULL;
+       struct buf *bp = NULL, *pribp = NULL, *supbp = NULL;
        dev_t dev = devvp->v_rdev;
        int error = EINVAL;
        int needclose = 0;
@@ -250,8 +250,10 @@
        extern struct vnode *rootvp;



Home | Main Index | Thread Index | Old Index