Module Name:    src
Committed By:   reinoud
Date:           Thu Jan 13 13:13:32 UTC 2011

Modified Files:
        src/sys/fs/udf: udf_subr.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/fs/udf/udf_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.109 src/sys/fs/udf/udf_subr.c:1.110
--- src/sys/fs/udf/udf_subr.c:1.109	Wed Dec 22 12:38:42 2010
+++ src/sys/fs/udf/udf_subr.c	Thu Jan 13 13:13:31 2011
@@ -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);
 

Reply via email to