diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2012-06-29 13:57:42 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2012-06-29 13:57:42 -0700 |
commit | 8804b0e5eb2b64c6e49025f5599552e8f00d9c33 (patch) | |
tree | 404b1c737b4cae36666d41f40a40a4a52d6c0e77 | |
parent | 6c24333f79ce4c5a894edc9b2e7b7dc78f081f63 (diff) | |
download | syslinux-8804b0e5eb2b64c6e49025f5599552e8f00d9c33.tar.gz |
fat: Make mangle behavior similar to the standard one
Handle mangle in FAT the same as in the generic version, except for \
-> / conversion.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | core/fs/fat/fat.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/core/fs/fat/fat.c b/core/fs/fat/fat.c index d3079269..b08923cf 100644 --- a/core/fs/fat/fat.c +++ b/core/fs/fat/fat.c @@ -220,24 +220,30 @@ static sector_t next_sector(struct file *file) return sector; } -/* - * Mangle a filename pointed to by src into a buffer pointed to by dst; - * ends on encountering any whitespace. +/** + * mangle_name: + * + * Mangle a filename pointed to by src into a buffer pointed + * to by dst; ends on encountering any whitespace. + * dst is preserved. + * + * This verifies that a filename is < FILENAME_MAX characters, + * doesn't contain whitespace, zero-pads the output buffer, + * and removes redundant slashes. + * + * Unlike the generic version, this also converts backslashes to + * forward slashes. * */ static void vfat_mangle_name(char *dst, const char *src) { char *p = dst; + int i = FILENAME_MAX-1; char c; - int i = FILENAME_MAX -1; - /* - * Copy the filename, converting backslash to slash and - * collapsing duplicate separators. - */ while (not_whitespace(c = *src)) { - if (c == '\\') - c = '/'; + if (c == '\\') + c = '/'; if (c == '/') { if (src[1] == '/' || src[1] == '\\') { @@ -250,16 +256,13 @@ static void vfat_mangle_name(char *dst, const char *src) *dst++ = *src++; } - /* Strip terminal slashes or whitespace */ while (1) { if (dst == p) break; - if (*(dst-1) == '/' && dst-1 == p) /* it's the '/' case */ - break; - if (dst-2 == p && *(dst-2) == '.' && *(dst-1) == '.' ) /* the '..' case */ - break; - if ((*(dst-1) != '/') && (*(dst-1) != '.')) + if (dst[-1] != '/') break; + if ((dst[-1] == '/') && ((dst - 1) == p)) + break; dst--; i++; |