|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
On-disk timestamp field offsets, packing constants, and stampers. More...
Go to the source code of this file.
Functions | |
| void | priv_fat_entry_stamp_create (uint8_t *entry) |
| Stamp a fresh FAT directory entry's create, write, and access fields. | |
| void | priv_fat_entry_stamp_write (uint8_t *entry) |
| Advance a FAT directory entry's modification time and access date. | |
| void | priv_fat_entry_stamp_access (uint8_t *entry) |
| Advance only a FAT directory entry's last-access date. | |
| void | priv_exfat_file_stamp_create (uint8_t *file_entry) |
| Stamp a fresh exFAT File entry's create, modify, and access fields. | |
| void | priv_exfat_file_stamp_access (uint8_t *file_entry) |
| Advance only an exFAT File entry's last-accessed stamp. | |
| void | priv_fat_entry_set_times (uint8_t *entry, const ra8_fs_datetime_t *create, const ra8_fs_datetime_t *modify, const ra8_fs_datetime_t *access) |
| Set chosen FAT directory-entry timestamps from caller-supplied readings. | |
| void | priv_exfat_file_set_times (uint8_t *file_entry, const ra8_fs_datetime_t *create, const ra8_fs_datetime_t *modify, const ra8_fs_datetime_t *access) |
| Set chosen exFAT File-entry timestamps from caller-supplied readings. | |
| void | priv_exfat_file_stamp_write (uint8_t *file_entry) |
| Advance an exFAT File entry's modification (and access) stamps. | |
On-disk timestamp field offsets, packing constants, and stampers.
The module-private half of the wall-clock seam (ra8_fs_set_clock()). It carries the byte offsets of the timestamp fields inside a 32-byte FAT directory entry and inside an exFAT File entry, the bit layout both formats pack a date and a time into, and the five stamping helpers the create / write / rename paths call.
The stampers deliberately take a raw entry pointer rather than a mount or a file handle: a timestamp is a property of the 32 bytes being assembled, and keeping it that way means the helper can be applied to an entry that is still in a stack buffer (a fresh directory slot, a "." link, an exFAT entry set being built) as easily as to one just read back off the volume.
Pulled in by the ra8_fs_fat_internal.h umbrella, so every ra8_fs_fat*.c file sees it; included by nothing outside this module.
References (every shorthand citation in this file):
Definition in file ra8_fs_fat_time_internal.h.
| enum ra8_fs_exfat_time_off_t : uint8_t |
Byte offsets of the timestamp fields in an exFAT File entry (0x85).
exFAT spec sec 7.4. The three 32-bit stamps share one packed layout (ra8_fs_time_pack_t); the 10ms fields recover the odd second and the hundredths that the 2-second stamp granularity throws away; the UtcOffset bytes say which zone the civil time in the stamp belongs to.
Definition at line 76 of file ra8_fs_fat_time_internal.h.
| enum ra8_fs_time_off_t : uint8_t |
Byte offsets of the timestamp fields in a 32-byte FAT directory entry.
MS FAT spec sec 6, table "Directory Entry". These are the fields priv_write_new_dir_entry() used to leave as zeros: a zero DIR_CrtDate / DIR_WrtDate encodes month 0 and day 0, and both are 1-based, so it is not a date any host can agree on.
Definition at line 53 of file ra8_fs_fat_time_internal.h.
| enum ra8_fs_time_pack_t : uint32_t |
Bit positions, field ranges, and epoch constants for both packings.
FAT splits the stamp across two 16-bit words (MS FAT spec sec 6): date = year-1980 << 9 | month << 5 | day, time = hour << 11 | minute << 5 | second/2. exFAT packs the same six fields into one 32-bit word (exFAT spec sec 7.4.8) with the time in the low half and the date in the high half, which is why the two share the sub-field shifts below.
Definition at line 103 of file ra8_fs_fat_time_internal.h.
| enum ra8_fs_utc_span_t : int16_t |
The signed range of UTC offsets exFAT's 7-bit field can express.
Kept apart from ra8_fs_time_pack_t because these are the only negative constants in the timestamp layer and that enum's underlying type is unsigned. UTC-12:00 and UTC+14:00 are the real extremes of civil time on Earth, and both land inside the 7-bit two's-complement field (-48 and +56 fifteen-minute steps).
| Enumerator | |
|---|---|
| k_fs_utc_span_min | UTC-12:00 expressed in minutes. |
| k_fs_utc_span_max | UTC+14:00 expressed in minutes. |
Definition at line 144 of file ra8_fs_fat_time_internal.h.
| void priv_exfat_file_set_times | ( | uint8_t * | file_entry, |
| const ra8_fs_datetime_t * | create, | ||
| const ra8_fs_datetime_t * | modify, | ||
| const ra8_fs_datetime_t * | access ) |
Set chosen exFAT File-entry timestamps from caller-supplied readings.
The exFAT counterpart of priv_fat_entry_set_times, with the two side fields exFAT carries: create and modify each write their 32-bit timestamp, their 10 ms increment and their UtcOffset byte; access writes LastAccessedTimestamp and its UtcOffset (exFAT has no last-accessed 10 ms field). Every non-NULL reading is treated as a real instant, so its UtcOffset is honoured (OffsetValid set when the offset is a whole 15-minute step in UTC-12:00..UTC+14:00, else recorded unknown). Each reading is clamped before packing.
| [in,out] | file_entry | 32-byte exFAT File (0x85) entry to patch in place. |
| [in] | create | Create stamp, or NULL to leave it unchanged. |
| [in] | modify | Modify stamp, or NULL to leave it unchanged. |
| [in] | access | Access stamp, or NULL to leave it unchanged. |
file_entry is non-NULL and addresses 32 writable bytes. file_entry is a File entry; the caller recomputes SetChecksum after. Definition at line 573 of file ra8_fs_fat_time.c.
References exfat_stamp_t::inc10, internal_clamp_datetime(), internal_exfat_pack(), k_exfat_off_file_atime, k_exfat_off_file_autc, k_exfat_off_file_c10ms, k_exfat_off_file_ctime, k_exfat_off_file_cutc, k_exfat_off_file_m10ms, k_exfat_off_file_mtime, k_exfat_off_file_mutc, priv_wr32(), exfat_stamp_t::stamp, and exfat_stamp_t::utc.
Referenced by internal_utime_exfat().
| void priv_exfat_file_stamp_access | ( | uint8_t * | file_entry | ) |
Advance only an exFAT File entry's last-accessed stamp.
The exFAT counterpart of priv_fat_entry_stamp_access, taken by the rename path for the same reason: the name changed, the bytes did not. Writes LastAccessedTimestamp and its UtcOffset byte; exFAT has no last-accessed 10ms field, so there is none to write.
| [in,out] | file_entry | 32-byte exFAT File (0x85) entry to stamp in place. |
file_entry is non-NULL and addresses 32 writable bytes. file_entry was read back from the volume as part of an entry set. Definition at line 532 of file ra8_fs_fat_time.c.
References internal_exfat_stamp_now(), k_exfat_off_file_atime, k_exfat_off_file_autc, priv_wr32(), exfat_stamp_t::stamp, and exfat_stamp_t::utc.
Referenced by internal_exfat_build_rename_set().
| void priv_exfat_file_stamp_create | ( | uint8_t * | file_entry | ) |
Stamp a fresh exFAT File entry's create, modify, and access fields.
The exFAT counterpart of priv_fat_entry_stamp_create, and it has three more fields to get right than FAT does: the 10ms increments that recover the odd second the 2-second stamp granularity drops, and the UtcOffset bytes that say which zone the civil time belongs to. An offset the format cannot express (not a whole 15-minute step, or outside UTC-12:00..UTC+14:00) is recorded as k_fs_utc_unknown – OffsetValid clear – rather than guessed.
| [in,out] | file_entry | 32-byte exFAT File (0x85) entry to stamp in place. |
file_entry is non-NULL and addresses 32 writable bytes. file_entry is a File entry; the caller recomputes SetChecksum after. Definition at line 505 of file ra8_fs_fat_time.c.
References exfat_stamp_t::inc10, internal_exfat_stamp_now(), k_exfat_off_file_atime, k_exfat_off_file_autc, k_exfat_off_file_c10ms, k_exfat_off_file_ctime, k_exfat_off_file_cutc, k_exfat_off_file_m10ms, k_exfat_off_file_mtime, k_exfat_off_file_mutc, priv_wr32(), exfat_stamp_t::stamp, and exfat_stamp_t::utc.
Referenced by internal_exfat_build_dir_set(), and internal_exfat_build_set().
| void priv_exfat_file_stamp_write | ( | uint8_t * | file_entry | ) |
Advance an exFAT File entry's modification (and access) stamps.
The exFAT counterpart of priv_fat_entry_stamp_write, taken by every flush of a streaming write. It moves LastModifiedTimestamp, its 10 ms increment and its UtcOffset – the three fields that together say WHEN the bytes on the card were put there – and LastAccessedTimestamp with them, because a write is an access. The creation fields are deliberately untouched: a truncate-in-place keeps a file's identity, and its birthday is part of that.
| [in,out] | file_entry | 32-byte exFAT File (0x85) entry to stamp in place. |
file_entry is non-NULL and addresses 32 writable bytes. file_entry was read back from the volume as part of an entry set. Definition at line 520 of file ra8_fs_fat_time.c.
References exfat_stamp_t::inc10, internal_exfat_stamp_now(), k_exfat_off_file_atime, k_exfat_off_file_autc, k_exfat_off_file_m10ms, k_exfat_off_file_mtime, k_exfat_off_file_mutc, priv_wr32(), exfat_stamp_t::stamp, and exfat_stamp_t::utc.
Referenced by priv_exfat_flush_set().
| void priv_fat_entry_set_times | ( | uint8_t * | entry, |
| const ra8_fs_datetime_t * | create, | ||
| const ra8_fs_datetime_t * | modify, | ||
| const ra8_fs_datetime_t * | access ) |
Set chosen FAT directory-entry timestamps from caller-supplied readings.
The utime primitive (ra8_fs_utime()): each non-NULL argument overwrites its timestamp fields, each NULL one leaves them exactly as they are. create writes DIR_CrtTimeTenth / DIR_CrtTime / DIR_CrtDate; modify writes DIR_WrtTime / DIR_WrtDate; access writes DIR_LstAccDate (FAT has no last-access time). Unlike the clock-driven stampers this takes explicit readings, so a backup/restore can put an original create/modify time back rather than the moment of the restore. Each reading is clamped into the on-disk range before packing, so an out-of-range field degrades to the nearest legal one and never fails the call.
| [in,out] | entry | 32-byte directory entry to patch in place. |
| [in] | create | Create stamp to write, or NULL to leave it unchanged. |
| [in] | modify | Modify stamp to write, or NULL to leave it unchanged. |
| [in] | access | Access stamp to write, or NULL to leave it unchanged. |
entry is non-NULL and addresses 32 writable bytes. Definition at line 541 of file ra8_fs_fat_time.c.
References fat_stamp_t::date, internal_clamp_datetime(), internal_fat_pack(), k_dir_off_crt_date, k_dir_off_crt_time, k_dir_off_crt_time_tenth, k_dir_off_lst_acc_date, k_dir_off_wrt_date, k_dir_off_wrt_time, priv_wr16(), fat_stamp_t::tenth, and fat_stamp_t::time.
Referenced by internal_utime_fat().
| void priv_fat_entry_stamp_access | ( | uint8_t * | entry | ) |
Advance only a FAT directory entry's last-access date.
What a rename gets. A rename changes the name, not the bytes, so advancing DIR_WrtDate would tell every rsync, backup and OTA "newest image" heuristic that the contents changed – the exact class of false positive #601 exists to remove, only inverted. FAT has no separate metadata-change field, so the honest record of "this entry was touched" is the access date, which is also the only access field FAT has (there is no last-access TIME).
| [in,out] | entry | 32-byte directory entry to stamp in place. |
entry is non-NULL and addresses 32 writable bytes. entry was read back from the volume. entry is unchanged.Definition at line 497 of file ra8_fs_fat_time.c.
References fat_stamp_t::date, internal_fat_stamp_now(), k_dir_off_lst_acc_date, and priv_wr16().
Referenced by internal_fat_rename().
| void priv_fat_entry_stamp_create | ( | uint8_t * | entry | ) |
Stamp a fresh FAT directory entry's create, write, and access fields.
Reads the installed clock once (or falls back to the FAT epoch) and writes DIR_CrtTimeTenth, DIR_CrtTime, DIR_CrtDate, DIR_LstAccDate, DIR_WrtTime and DIR_WrtDate from that single reading, so a newly created file's three dates agree with each other instead of straddling a clock tick.
| [in,out] | entry | 32-byte directory entry to stamp in place. |
entry is non-NULL and addresses 32 writable bytes. entry (name, attribute, cluster) are already set or will be set without disturbing offsets 13..25. entry holds a legal calendar value. Definition at line 474 of file ra8_fs_fat_time.c.
References fat_stamp_t::date, internal_fat_stamp_now(), k_dir_off_crt_date, k_dir_off_crt_time, k_dir_off_crt_time_tenth, k_dir_off_lst_acc_date, k_dir_off_wrt_date, k_dir_off_wrt_time, priv_wr16(), fat_stamp_t::tenth, and fat_stamp_t::time.
Referenced by internal_create_new(), internal_fat_mkdir(), internal_fat_put_vol_id(), and internal_pack_dot_entry().
| void priv_fat_entry_stamp_write | ( | uint8_t * | entry | ) |
Advance a FAT directory entry's modification time and access date.
The write half: DIR_WrtTime / DIR_WrtDate (what every host shows as "date modified" and what every backup and sync tool keys on) plus DIR_LstAccDate, because writing is also accessing. The create fields are left exactly as they are – a file created on a PC keeps the PC's creation date.
| [in,out] | entry | 32-byte directory entry to stamp in place. |
entry is non-NULL and addresses 32 writable bytes. entry was read back from the volume (or is being assembled for it). Definition at line 487 of file ra8_fs_fat_time.c.
References fat_stamp_t::date, internal_fat_stamp_now(), k_dir_off_lst_acc_date, k_dir_off_wrt_date, k_dir_off_wrt_time, priv_wr16(), and fat_stamp_t::time.
Referenced by internal_close_stamp(), internal_fat_put_vol_id(), internal_fat_trunc_commit(), and internal_truncate_existing().