Commit e2423dc0 authored by Dave Kleikamp's avatar Dave Kleikamp

JFS: warn users of inaccessible file names

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.
parent 06e89f5e
...@@ -34,6 +34,8 @@ int jfs_strfromUCS_le(char *to, const wchar_t * from, /* LITTLE ENDIAN */ ...@@ -34,6 +34,8 @@ int jfs_strfromUCS_le(char *to, const wchar_t * from, /* LITTLE ENDIAN */
{ {
int i; int i;
int outlen = 0; int outlen = 0;
static int warn_again = 5; /* Only warn up to 5 times total */
int warn = !!warn_again; /* once per string */
if (codepage) { if (codepage) {
for (i = 0; (i < len) && from[i]; i++) { for (i = 0; (i < len) && from[i]; i++) {
...@@ -48,8 +50,22 @@ int jfs_strfromUCS_le(char *to, const wchar_t * from, /* LITTLE ENDIAN */ ...@@ -48,8 +50,22 @@ int jfs_strfromUCS_le(char *to, const wchar_t * from, /* LITTLE ENDIAN */
to[outlen++] = '?'; to[outlen++] = '?';
} }
} else { } else {
for (i = 0; (i < len) && from[i]; i++) for (i = 0; (i < len) && from[i]; i++) {
to[i] = (char) (le16_to_cpu(from[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; outlen = i;
} }
to[outlen] = 0; to[outlen] = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment