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;
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 {
#define _FS_H
#include <common.h>
+#include <rtc.h>
struct cmd_tbl;
#define FS_DT_REG 8 /* regular file */
#define FS_DT_LNK 10 /* symbolic link */
-/*
- * A directory entry, returned by fs_readdir(). Returns information
+/**
+ * struct fs_dirent - directory entry
+ *
+ * A directory entry, returned by fs_readdir(). Returns information
* about the file/directory at the current directory entry position.
*/
struct fs_dirent {
- unsigned type; /* one of FS_DT_x (not a mask) */
- loff_t size; /* size in bytes */
+ /** @type: one of FS_DT_x (not a mask) */
+ unsigned int type;
+ /** @size: file size */
+ loff_t size;
+ /** @flags: attribute flags (FS_ATTR_*) */
+ u32 attr;
+ /** create_time: time of creation */
+ struct rtc_time create_time;
+ /** access_time: time of last access */
+ struct rtc_time access_time;
+ /** change_time: time of last modification */
+ struct rtc_time change_time;
+ /** name: file name */
char name[256];
};