Commit 0939e16d authored by Dave Jones's avatar Dave Jones Committed by Linus Torvalds

[PATCH] MSDOS fs option parser cleanup

Original from Rene Scharfe
This fixes a problem where MSDOS fs's ignore their 'check' mount option.
parent 76065a80
...@@ -34,9 +34,10 @@ static char bad_if_strict_atari[] = " "; /* GEMDOS is less restrictive */ ...@@ -34,9 +34,10 @@ static char bad_if_strict_atari[] = " "; /* GEMDOS is less restrictive */
/***** Formats an MS-DOS file name. Rejects invalid names. */ /***** Formats an MS-DOS file name. Rejects invalid names. */
static int msdos_format_name(const char *name,int len, static int msdos_format_name(const char *name,int len,
char *res,struct fat_mount_options *opts) char *res,struct fat_mount_options *opts)
/* conv is relaxed/normal/strict, name is proposed name, /* name is the proposed name, len is its length, res is
* len is the length of the proposed name, res is the result name, * the resulting name, opts->name_check is either (r)elaxed,
* dotsOK is if hidden files get dots. * (n)ormal or (s)trict, opts->dotsOK allows dots at the
* beginning of name (for hidden files)
*/ */
{ {
char *walk; char *walk;
...@@ -58,11 +59,11 @@ static int msdos_format_name(const char *name,int len, ...@@ -58,11 +59,11 @@ static int msdos_format_name(const char *name,int len,
for (walk = res; len && walk-res < 8; walk++) { for (walk = res; len && walk-res < 8; walk++) {
c = *name++; c = *name++;
len--; len--;
if (opts->conversion != 'r' && strchr(bad_chars,c)) if (opts->name_check != 'r' && strchr(bad_chars,c))
return -EINVAL; return -EINVAL;
if (opts->conversion == 's' && strchr(bad_if_strict(opts),c)) if (opts->name_check == 's' && strchr(bad_if_strict(opts),c))
return -EINVAL; return -EINVAL;
if (c >= 'A' && c <= 'Z' && opts->conversion == 's') if (c >= 'A' && c <= 'Z' && opts->name_check == 's')
return -EINVAL; return -EINVAL;
if (c < ' ' || c == ':' || c == '\\') return -EINVAL; if (c < ' ' || c == ':' || c == '\\') return -EINVAL;
/* 0xE5 is legal as a first character, but we must substitute 0x05 */ /* 0xE5 is legal as a first character, but we must substitute 0x05 */
...@@ -75,7 +76,7 @@ static int msdos_format_name(const char *name,int len, ...@@ -75,7 +76,7 @@ static int msdos_format_name(const char *name,int len,
*walk = (!opts->nocase && c >= 'a' && c <= 'z') ? c-32 : c; *walk = (!opts->nocase && c >= 'a' && c <= 'z') ? c-32 : c;
} }
if (space) return -EINVAL; if (space) return -EINVAL;
if (opts->conversion == 's' && len && c != '.') { if (opts->name_check == 's' && len && c != '.') {
c = *name++; c = *name++;
len--; len--;
if (c != '.') return -EINVAL; if (c != '.') return -EINVAL;
...@@ -86,25 +87,25 @@ static int msdos_format_name(const char *name,int len, ...@@ -86,25 +87,25 @@ static int msdos_format_name(const char *name,int len,
while (len > 0 && walk-res < MSDOS_NAME) { while (len > 0 && walk-res < MSDOS_NAME) {
c = *name++; c = *name++;
len--; len--;
if (opts->conversion != 'r' && strchr(bad_chars,c)) if (opts->name_check != 'r' && strchr(bad_chars,c))
return -EINVAL; return -EINVAL;
if (opts->conversion == 's' && if (opts->name_check == 's' &&
strchr(bad_if_strict(opts),c)) strchr(bad_if_strict(opts),c))
return -EINVAL; return -EINVAL;
if (c < ' ' || c == ':' || c == '\\') if (c < ' ' || c == ':' || c == '\\')
return -EINVAL; return -EINVAL;
if (c == '.') { if (c == '.') {
if (opts->conversion == 's') if (opts->name_check == 's')
return -EINVAL; return -EINVAL;
break; break;
} }
if (c >= 'A' && c <= 'Z' && opts->conversion == 's') if (c >= 'A' && c <= 'Z' && opts->name_check == 's')
return -EINVAL; return -EINVAL;
space = c == ' '; space = c == ' ';
*walk++ = (!opts->nocase && c >= 'a' && c <= 'z') ? c-32 : c; *walk++ = (!opts->nocase && c >= 'a' && c <= 'z') ? c-32 : c;
} }
if (space) return -EINVAL; if (space) return -EINVAL;
if (opts->conversion == 's' && len) return -EINVAL; if (opts->name_check == 's' && len) return -EINVAL;
} }
while (walk-res < MSDOS_NAME) *walk++ = ' '; while (walk-res < MSDOS_NAME) *walk++ = ' ';
if (!opts->atari) if (!opts->atari)
......
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