aboutsummaryrefslogtreecommitdiff
path: root/fs/fat/fat.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt2021-05-15 22:06:16 +0200
committerHeinrich Schuchardt2021-07-12 20:30:48 +0200
commit13c11c665320beff22ea94674da42719b6281501 (patch)
tree309a2b4e7c9c4481f1aa594b746669622e58a76f /fs/fat/fat.c
parent41a4a3085591b8e837f6eec27821218b0be31036 (diff)
fs: fat: add file attributes to struct fs_dirent
When reading a directory in the UEFI file system we have to return file attributes and timestamps. Copy this data to the directory entry structure. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'fs/fat/fat.c')
-rw-r--r--fs/fat/fat.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index c561d82b351..7021138b987 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1187,6 +1187,28 @@ out:
return ret == 0;
}
+/**
+ * fat2rtc() - convert FAT time stamp to RTC file stamp
+ *
+ * @date: FAT date
+ * @time: FAT time
+ * @tm: RTC time stamp
+ */
+static void __maybe_unused fat2rtc(u16 date, u16 time, struct rtc_time *tm)
+{
+ tm->tm_mday = date & 0x1f;
+ tm->tm_mon = (date & 0x1e0) >> 4;
+ tm->tm_year = (date >> 9) + 1980;
+
+ tm->tm_sec = (time & 0x1f) << 1;
+ tm->tm_min = (time & 0x7e0) >> 5;
+ tm->tm_hour = time >> 11;
+
+ rtc_calc_weekday(tm);
+ tm->tm_yday = 0;
+ tm->tm_isdst = 0;
+}
+
int fat_size(const char *filename, loff_t *size)
{
fsdata fsdata;
@@ -1325,7 +1347,15 @@ int fat_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp)
memset(dent, 0, sizeof(*dent));
strcpy(dent->name, dir->itr.name);
-
+ if (CONFIG_IS_ENABLED(EFI_LOADER)) {
+ dent->attr = dir->itr.dent->attr;
+ fat2rtc(le16_to_cpu(dir->itr.dent->cdate),
+ le16_to_cpu(dir->itr.dent->ctime), &dent->create_time);
+ fat2rtc(le16_to_cpu(dir->itr.dent->date),
+ le16_to_cpu(dir->itr.dent->time), &dent->change_time);
+ fat2rtc(le16_to_cpu(dir->itr.dent->adate),
+ 0, &dent->access_time);
+ }
if (fat_itr_isdir(&dir->itr)) {
dent->type = FS_DT_DIR;
} else {