summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-02-04 18:07:37 -0800
committerH. Peter Anvin <hpa@zytor.com>2010-02-04 18:07:37 -0800
commit09fc871d0b691fffb846b4c49869a949fa776108 (patch)
tree25f23b9668fd6865253ab27301bab715a430f4d1
parent117a72aa41edea84a734db09c89d09ca2efb5bf7 (diff)
downloadsyslinux-09fc871d0b691fffb846b4c49869a949fa776108.tar.gz
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@zytor.com>
-rw-r--r--core/fs/fat/fat.c23
-rw-r--r--core/fs/fat/fat_fs.h5
2 files changed, 17 insertions, 11 deletions
diff --git a/core/fs/fat/fat.c b/core/fs/fat/fat.c
index 2ec23e0d..13cf674d 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 db366d6d..60b5aee1 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;