* [PATCH 1/1] fat: fix listing the root directory
@ 2022-01-21 19:31 Heinrich Schuchardt
2022-01-22 9:07 ` Vladimir 'phcoder' Serbinenko
0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2022-01-21 19:31 UTC (permalink / raw)
To: Daniel Kiper; +Cc: GRUB development, Heinrich Schuchardt
ls / for a FAT partition leads to
error: invalid modification timestamp for /.
Not all entries of the directory are displayed.
Linux never updates the modification timestamp of the /. directory entry.
The FAT specification allows the access and creation date fields to be
zero.
We should follow Linux and render initial FAT timestamps as start of
the epoch.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
grub-core/fs/fat.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c
index dd82e4ee3..35ff0b27c 100644
--- a/grub-core/fs/fat.c
+++ b/grub-core/fs/fat.c
@@ -901,6 +901,18 @@ grub_fat_timestamp (grub_uint16_t time, grub_uint16_t date, grub_int64_t *nix) {
.second = (time & 0x001F) * 2,
};
+ /*
+ * The modification time of the root directory is never set by Linux.
+ * Creation and access time are optional and can be zero.
+ * Follow Linux and render FAT initial timestamps as the start of the epoch.
+ */
+ if (date == 0 && time == 0)
+ {
+ datetime.year = 1970;
+ datetime.month = 1;
+ datetime.day = 1;
+ }
+
/* The conversion below allows seconds=60, so don't trust its validation. */
if ((time & 0x1F) > 29)
return 0;
--
2.33.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] fat: fix listing the root directory
2022-01-21 19:31 [PATCH 1/1] fat: fix listing the root directory Heinrich Schuchardt
@ 2022-01-22 9:07 ` Vladimir 'phcoder' Serbinenko
2022-01-22 20:59 ` Heinrich Schuchardt
0 siblings, 1 reply; 3+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2022-01-22 9:07 UTC (permalink / raw)
To: The development of GNU GRUB
Inserting dummy date of 1970-1-1 is a bad idea. Can we rather allow
timestamp to be missing instead of throwing error?
On Fri, Jan 21, 2022 at 8:33 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> ls / for a FAT partition leads to
>
> error: invalid modification timestamp for /.
>
> Not all entries of the directory are displayed.
>
> Linux never updates the modification timestamp of the /. directory entry.
> The FAT specification allows the access and creation date fields to be
> zero.
>
> We should follow Linux and render initial FAT timestamps as start of
> the epoch.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> grub-core/fs/fat.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c
> index dd82e4ee3..35ff0b27c 100644
> --- a/grub-core/fs/fat.c
> +++ b/grub-core/fs/fat.c
> @@ -901,6 +901,18 @@ grub_fat_timestamp (grub_uint16_t time, grub_uint16_t date, grub_int64_t *nix) {
> .second = (time & 0x001F) * 2,
> };
>
> + /*
> + * The modification time of the root directory is never set by Linux.
> + * Creation and access time are optional and can be zero.
> + * Follow Linux and render FAT initial timestamps as the start of the epoch.
> + */
> + if (date == 0 && time == 0)
> + {
> + datetime.year = 1970;
> + datetime.month = 1;
> + datetime.day = 1;
> + }
> +
> /* The conversion below allows seconds=60, so don't trust its validation. */
> if ((time & 0x1F) > 29)
> return 0;
> --
> 2.33.1
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
--
Regards
Vladimir 'phcoder' Serbinenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] fat: fix listing the root directory
2022-01-22 9:07 ` Vladimir 'phcoder' Serbinenko
@ 2022-01-22 20:59 ` Heinrich Schuchardt
0 siblings, 0 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2022-01-22 20:59 UTC (permalink / raw)
To: Vladimir 'phcoder' Serbinenko
Cc: The development of GNU GRUB, Daniel Kiper
On 1/22/22 10:07, Vladimir 'phcoder' Serbinenko wrote:
> Inserting dummy date of 1970-1-1 is a bad idea. Can we rather allow
> timestamp to be missing instead of throwing error?
This function seems only to be used for validation of the timestamp.
I never have seen the ls command in GRUB actually display a timestamp.
If you use ls -la in Linux it will display 1970-01-01. Wouldn't this be
what a user would expect to see in GRUB too?
Anyway the filtering would have to be done in a different function than
the one corrected here.
Best regards
Heinrich
>
> On Fri, Jan 21, 2022 at 8:33 PM Heinrich Schuchardt
> <heinrich.schuchardt@canonical.com> wrote:
>>
>> ls / for a FAT partition leads to
>>
>> error: invalid modification timestamp for /.
>>
>> Not all entries of the directory are displayed.
>>
>> Linux never updates the modification timestamp of the /. directory entry.
>> The FAT specification allows the access and creation date fields to be
>> zero.
>>
>> We should follow Linux and render initial FAT timestamps as start of
>> the epoch.
>>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>> ---
>> grub-core/fs/fat.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c
>> index dd82e4ee3..35ff0b27c 100644
>> --- a/grub-core/fs/fat.c
>> +++ b/grub-core/fs/fat.c
>> @@ -901,6 +901,18 @@ grub_fat_timestamp (grub_uint16_t time, grub_uint16_t date, grub_int64_t *nix) {
>> .second = (time & 0x001F) * 2,
>> };
>>
>> + /*
>> + * The modification time of the root directory is never set by Linux.
>> + * Creation and access time are optional and can be zero.
>> + * Follow Linux and render FAT initial timestamps as the start of the epoch.
>> + */
>> + if (date == 0 && time == 0)
>> + {
>> + datetime.year = 1970;
>> + datetime.month = 1;
>> + datetime.day = 1;
>> + }
>> +
>> /* The conversion below allows seconds=60, so don't trust its validation. */
>> if ((time & 0x1F) > 29)
>> return 0;
>> --
>> 2.33.1
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-22 20:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-21 19:31 [PATCH 1/1] fat: fix listing the root directory Heinrich Schuchardt
2022-01-22 9:07 ` Vladimir 'phcoder' Serbinenko
2022-01-22 20:59 ` Heinrich Schuchardt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.