Several FS mtime support.
* grub-core/fs/affs.c (grub_affs_time): New struct. (grub_affs_file): New field mtime. (grub_fshelp_node): Changed 'block' and 'parent' to more appropriate type. Removed 'size'. New field 'di'. All users updated. (grub_affs_mount): Simplify checsum checking. (grub_affs_iterate_dir): New helper grub_affs_create_node. (grub_affs_dir): Handle mtime. * grub-core/fs/cpio.c (grub_cpio_find_file): Handle mtime. (grub_cpio_dir): Likewise. * grub-core/fs/hfs.c (grub_hfs_dirrec): New fields 'ctime' and 'mtime'. (grub_hfs_filerec): New field mtime. (grub_hfs_dir): Handle mtime. (grub_hfs_mtime): New function. (grub_hfs_fs): Register grub_hfs_mtime. * grub-core/fs/iso9660.c (grub_iso9660_date2): New struct. (grub_iso9660_dir): New field mtime. (grub_fshelp_node): New field dirent. (iso9660_to_unixtime): New function. (iso9660_to_unixtime2): Likewise. (grub_iso9660_read_symlink): Use node->dirent. (grub_iso9660_iterate_dir): Likewise. (grub_iso9660_dir): Set mtime. (grub_iso9660_mtime): New function. (grub_iso9660_fs): Register grub_iso9660_mtime. * grub-core/fs/jfs.c (grub_jfs_time): New struct. (grub_jfs_inode): New fields atime, ctime and mtime. (grub_jfs_dir): Set mtime. * grub-core/fs/minix.c (grub_minix_dir): Likewise. * grub-core/fs/ntfs.c (list_file): Set mtime. (grub_ntfs_dir): Likewise. * grub-core/fs/reiserfs.c (grub_fshelp_node): New field 'mtime'. (grub_reiserfs_iterate_dir): Set mtime. (grub_reiserfs_dir): Likewise. * grub-core/fs/sfs.c (grub_sfs_obj): New field mtime. (grub_fshelp_node): Likewise. (grub_sfs_iterate_dir): Set mtime. (grub_sfs_dir): Likewise. * grub-core/fs/udf.c (grub_udf_dir): Set mtime. * grub-core/fs/xfs.c (grub_xfs_time): New struct. (grub_xfs_inode): New fields atime, mtime, ctime. (grub_xfs_dir): Set mtime. * include/grub/datetime.h (grub_datetime2unixtime): New function. * include/grub/hfs.h (grub_hfs_sblock): New fields ctime and mtime. * include/grub/ntfs.h (grub_fshelp_node): New field mtime. Support UDF symlinks. * grub-core/fs/udf.c (grub_udf_iterate_dir): Handle symlinks. (grub_ufs_read_symlink): New function. All users updated. Check amiga partmap checksum. * grub-core/partmap/amiga.c (grub_amiga_rdsk): Pad to 128 bytes. (grub_amiga_partition): Likewise. (amiga_partition_map_checksum): New function. (amiga_partition_map_iterate): Check checksum.
This commit is contained in:
commit
b756f75f07
16 changed files with 466 additions and 64 deletions
|
@ -51,5 +51,78 @@ char *grub_get_weekday_name (struct grub_datetime *datetime);
|
|||
void grub_unixtime2datetime (grub_int32_t nix,
|
||||
struct grub_datetime *datetime);
|
||||
|
||||
static inline int
|
||||
grub_datetime2unixtime (const struct grub_datetime *datetime, grub_int32_t *nix)
|
||||
{
|
||||
grub_int32_t ret;
|
||||
int y4, ay;
|
||||
const grub_uint16_t monthssum[12]
|
||||
= { 0,
|
||||
31,
|
||||
31 + 28,
|
||||
31 + 28 + 31,
|
||||
31 + 28 + 31 + 30,
|
||||
31 + 28 + 31 + 30 + 31,
|
||||
31 + 28 + 31 + 30 + 31 + 30,
|
||||
31 + 28 + 31 + 30 + 31 + 30 + 31,
|
||||
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31,
|
||||
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
|
||||
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
|
||||
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30};
|
||||
const grub_uint8_t months[12] = {31, 28, 31, 30, 31, 30,
|
||||
31, 31, 30, 31, 30, 31};
|
||||
const int SECPERMIN = 60;
|
||||
const int SECPERHOUR = 60 * SECPERMIN;
|
||||
const int SECPERDAY = 24 * SECPERHOUR;
|
||||
const int SECPERYEAR = 365 * SECPERDAY;
|
||||
const int SECPER4YEARS = 4 * SECPERYEAR + SECPERDAY;
|
||||
|
||||
if (datetime->year > 2038 || datetime->year < 1901)
|
||||
return 0;
|
||||
if (datetime->month > 12 || datetime->month < 1)
|
||||
return 0;
|
||||
|
||||
/* In the period of validity of unixtime all years divisible by 4
|
||||
are bissextile*/
|
||||
/* Convenience: let's have 3 consecutive non-bissextile years
|
||||
at the beginning of the epoch. So count from 1971 instead of 1970 */
|
||||
ret = SECPERYEAR + SECPERDAY;
|
||||
|
||||
/* Transform C divisions and modulos to mathematical ones */
|
||||
y4 = (datetime->year - 1971) / 4;
|
||||
if (datetime->year < 1971)
|
||||
y4--;
|
||||
ay = datetime->year - 1971 - 4 * y4;
|
||||
ret += y4 * SECPER4YEARS;
|
||||
ret += ay * SECPERYEAR;
|
||||
|
||||
ret += monthssum[datetime->month - 1] * SECPERDAY;
|
||||
if (ay == 0 && datetime->month >= 3)
|
||||
ret += SECPERDAY;
|
||||
|
||||
ret += (datetime->day - 1) * SECPERDAY;
|
||||
if ((datetime->day > months[datetime->month - 1]
|
||||
&& (!ay || datetime->month != 2 || datetime->day != 29))
|
||||
|| datetime->day < 1)
|
||||
return 0;
|
||||
|
||||
ret += datetime->hour * SECPERHOUR;
|
||||
if (datetime->hour > 23)
|
||||
return 0;
|
||||
ret += datetime->minute * 60;
|
||||
if (datetime->minute > 59)
|
||||
return 0;
|
||||
|
||||
ret += datetime->second;
|
||||
/* Accept leap seconds. */
|
||||
if (datetime->second > 60)
|
||||
return 0;
|
||||
|
||||
if ((datetime->year > 1980 && ret < 0)
|
||||
|| (datetime->year < 1960 && ret > 0))
|
||||
return 0;
|
||||
*nix = ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ! KERNEL_DATETIME_HEADER */
|
||||
|
|
|
@ -39,7 +39,9 @@ typedef struct grub_hfs_extent grub_hfs_datarecord_t[3];
|
|||
struct grub_hfs_sblock
|
||||
{
|
||||
grub_uint16_t magic;
|
||||
grub_uint8_t unused[18];
|
||||
grub_uint32_t ctime;
|
||||
grub_uint32_t mtime;
|
||||
grub_uint8_t unused[10];
|
||||
grub_uint32_t blksz;
|
||||
grub_uint8_t unused2[4];
|
||||
grub_uint16_t first_block;
|
||||
|
|
|
@ -135,6 +135,7 @@ struct grub_fshelp_node
|
|||
struct grub_ntfs_data *data;
|
||||
char *buf;
|
||||
grub_uint64_t size;
|
||||
grub_uint64_t mtime;
|
||||
grub_uint32_t ino;
|
||||
int inode_read;
|
||||
struct grub_ntfs_attr attr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue