Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/udf Fix the case in where a file with a latin1 file n...



details:   https://anonhg.NetBSD.org/src/rev/3920619268fb
branches:  trunk
changeset: 760811:3920619268fb
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Thu Jan 13 13:13:31 2011 +0000

description:
Fix the case in where a file with a latin1 file name was created. It was then
erronously entered as thelatin1 file name in the dirhash whereas the matching
routing assumes both UTF-8. This would result in a file being created but not
stat-able since the dirhash couldn't find the entry unless it was remounted.

diffstat:

 sys/fs/udf/udf_subr.c |  20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diffs (48 lines):

diff -r 3a4e41f8e10f -r 3920619268fb sys/fs/udf/udf_subr.c
--- a/sys/fs/udf/udf_subr.c     Thu Jan 13 13:05:13 2011 +0000
+++ b/sys/fs/udf/udf_subr.c     Thu Jan 13 13:13:31 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.109 2010/12/22 12:38:42 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.110 2011/01/13 13:13:31 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.109 2010/12/22 12:38:42 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.110 2011/01/13 13:13:31 reinoud Exp $");
 #endif /* not lint */
 
 
@@ -4568,7 +4568,15 @@
                        dirent->d_namlen, dirent->d_namlen, dirent->d_name));
 
                /* see if its our entry */
-               KASSERT(dirent->d_namlen == namelen);
+#ifdef DIAGNOSTIC
+               if (dirent->d_namlen != namelen) {
+                       printf("WARNING: dirhash_lookup() returned wrong "
+                               "d_namelen: %d and ought to be %d\n",
+                               dirent->d_namlen, namelen);
+                       printf("\tlooked for `%s' and got `%s'\n",
+                               name, dirent->d_name);
+               }
+#endif
                if (strncmp(dirent->d_name, name, namelen) == 0) {
                        *found = 1;
                        *icb_loc = fid->icb;
@@ -5227,8 +5235,10 @@
        }
 
        /* append to the dirhash */
-       dirent.d_namlen = cnp->cn_namelen;
-       memcpy(dirent.d_name, cnp->cn_nameptr, cnp->cn_namelen);
+       /* NOTE do not use dirent anymore or it won't match later! */
+       udf_to_unix_name(dirent.d_name, MAXNAMLEN,
+               (char *) fid->data + udf_rw16(fid->l_iu), fid->l_fi, &osta_charspec);
+       dirent.d_namlen = strlen(dirent.d_name);
        dirhash_enter(dirh, &dirent, chosen_fid_pos,
                udf_fidsize(fid), 1);
 



Home | Main Index | Thread Index | Old Index