[syslinux:fsc] FAT: handle WinNT filename case flags
syslinux-bot for H. Peter Anvin
hpa at zytor.com
Thu Feb 4 18:09:03 PST 2010
Commit-ID: 09fc871d0b691fffb846b4c49869a949fa776108
Gitweb: http://syslinux.zytor.com/commit/09fc871d0b691fffb846b4c49869a949fa776108
Author: H. Peter Anvin <hpa at zytor.com>
AuthorDate: Thu, 4 Feb 2010 18:07:37 -0800
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Thu, 4 Feb 2010 18:07:37 -0800
FAT: handle WinNT filename case flags
Handle WinNT-style filename case flags (where it uses a shortname only
but with flags to indicate the filename case.)
Signed-off-by: H. Peter Anvin <hpa at zytor.com>
---
core/fs/fat/fat.c | 23 ++++++++++++++---------
core/fs/fat/fat_fs.h | 5 +++--
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/core/fs/fat/fat.c b/core/fs/fat/fat.c
index 2ec23e0..13cf674 100644
--- a/core/fs/fat/fat.c
+++ b/core/fs/fat/fat.c
@@ -680,24 +680,29 @@ static struct dirent * vfat_readdir(struct file *file)
} else {
/* Use the shortname */
int i;
+ uint8_t c;
char *p = filename;
for (i = 0; i < 8; i++) {
- if (de->name[i] == ' ')
+ c = de->name[i];
+ if (c == ' ')
break;
- *p++ = de->name[i];
+ if (de->lcase & LCASE_BASE)
+ c = codepage.lower[c];
+ *p++ = c;
}
- *p++ = '.';
- if (de->name[8] == ' ') {
- *--p = '\0';
- } else {
+ if (de->name[8] != ' ') {
+ *p++ = '.';
for (i = 8; i < 11; i++) {
- if (de->name[i] == ' ')
+ c = de->name[i];
+ if (c == ' ')
break;
- *p++ = de->name[i];
+ if (de->lcase & LCASE_EXT)
+ c = codepage.lower[c];
+ *p++ = c;
}
- *p = '\0';
}
+ *p = '\0';
goto got;
}
diff --git a/core/fs/fat/fat_fs.h b/core/fs/fat/fat_fs.h
index db366d6..60b5aee 100644
--- a/core/fs/fat/fat_fs.h
+++ b/core/fs/fat/fat_fs.h
@@ -102,7 +102,7 @@ struct fat_sb_info {
struct fat_dir_entry {
char name[11];
uint8_t attr;
- uint8_t nt_reserved;
+ uint8_t lcase;
uint8_t c_time_tenth;
uint16_t c_time;
uint16_t c_date;
@@ -114,7 +114,8 @@ struct fat_dir_entry {
uint32_t file_size;
} __attribute__ ((packed));
-
+#define LCASE_BASE 8 /* basename is lower case */
+#define LCASE_EXT 16 /* extension is lower case */
struct fat_long_name_entry {
uint8_t id;
More information about the Syslinux-commits
mailing list