]> git.hungrycats.org Git - linux/commitdiff
JFS: warn users of inaccessible file names
authorDave Kleikamp <shaggy@austin.ibm.com>
Mon, 8 Mar 2004 07:24:03 +0000 (01:24 -0600)
committerDave Kleikamp <shaggy@austin.ibm.com>
Mon, 8 Mar 2004 07:24:03 +0000 (01:24 -0600)
When no iocharset is specified, the default action is to trivially
map each byte into the low order of the 16-bit unicode character.
If an existing name exists that has a non-zero high order byte, the
file will be inaccessible without remounting with iocharset set to
a charset that supports the character.

This patch will cause a warning to be issued to the syslog (no more
than five times) suggesting that the volume be mounted with
iocharset=utf8 in order to access the file.

fs/jfs/jfs_unicode.c

index 0cf384c5de1438b3488f4f784024c3b01f51ad5b..c44ce40f506ae68323e705afd072258b994ca06e 100644 (file)
@@ -34,6 +34,8 @@ int jfs_strfromUCS_le(char *to, const wchar_t * from, /* LITTLE ENDIAN */
 {
        int i;
        int outlen = 0;
+       static int warn_again = 5;      /* Only warn up to 5 times total */
+       int warn = !!warn_again;        /* once per string */
 
        if (codepage) {
                for (i = 0; (i < len) && from[i]; i++) {
@@ -48,8 +50,22 @@ int jfs_strfromUCS_le(char *to, const wchar_t * from,        /* LITTLE ENDIAN */
                                to[outlen++] = '?';
                }
        } else {
-               for (i = 0; (i < len) && from[i]; i++)
-                       to[i] = (char) (le16_to_cpu(from[i]));
+               for (i = 0; (i < len) && from[i]; i++) {
+                       if (le16_to_cpu(from[i]) & 0xff00) {
+                               if (warn) {
+                                       warn--;
+                                       warn_again--;
+                                       printk(KERN_ERR
+                       "non-latin1 character 0x%x found in JFS file name\n", 
+                                              le16_to_cpu(from[i]));
+                                       printk(KERN_ERR
+                               "mount with iocharset=utf8 to access\n");
+                               }
+                               to[i] = '?';
+                       }
+                       else
+                               to[i] = (char) (le16_to_cpu(from[i]));
+               }
                outlen = i;
        }
        to[outlen] = 0;