mtime support
PATCH 1/1 mtime support
Hello. Here is the patch to support mtime. This is a prerequisite for -nt test which can be very useful for e.g. finding last compiled kernel Also in the same time it makes the dir call easily extendable
Regards
Vladimir 'phcoder' Serbinenko
common.rmk +1 -1
@@ -352,7 +358,7 @@ terminal_mod_CFLAGS = $(COMMON_CFLAGS) terminal_mod_LDFLAGS = $(COMMON_LDFLAGS) # For ls.mod. -ls_mod_SOURCES = commands/ls.c +ls_mod_SOURCES = commands/ls.c lib/datetime.c ls_mod_CFLAGS = $(COMMON_CFLAGS) ls_mod_LDFLAGS = $(COMMON_LDFLAGS)
i386-coreboot.rmk +2 -2
@@ -87,7 +87,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - grub_emu_init.c + grub_emu_init.c lib/datetime.c grub_emu_LDFLAGS = $(LIBCURSES)
@@ -127,7 +127,7 @@ normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/menu_viewer.c normal/menu_entry.c \ normal/misc.c grub_script.tab.c \ normal/script.c \ - normal/i386/setjmp.S + normal/i386/setjmp.S lib/datetime.c normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_ASFLAGS = $(COMMON_ASFLAGS) normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
i386-efi.rmk +2 -2
@@ -64,7 +64,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - grub_emu_init.c + grub_emu_init.c lib/datetime.c grub_emu_LDFLAGS = $(LIBCURSES)
@@ -124,7 +124,7 @@ normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/menu_viewer.c normal/menu_entry.c \ normal/misc.c grub_script.tab.c \ normal/script.c \ - normal/i386/setjmp.S + normal/i386/setjmp.S lib/datetime.c normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_ASFLAGS = $(COMMON_ASFLAGS) normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
i386-ieee1275.rmk +1 -1
@@ -117,8 +117,8 @@ normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/menu_viewer.c normal/menu_entry.c \ normal/misc.c grub_script.tab.c \ normal/script.c \ - normal/i386/setjmp.S + normal/i386/setjmp.S lib/datetime.c normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_ASFLAGS = $(COMMON_ASFLAGS) normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
i386-pc.rmk +1 -2
@@ -145,8 +145,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - grub_emu_init.c - + grub_emu_init.c lib/datetime.c grub_emu_LDFLAGS = $(LIBCURSES) ifeq ($(enable_grub_emu_usb), yes)
powerpc-ieee1275.rmk +2 -2
@@ -69,7 +69,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - grub_script.tab.c grub_emu_init.c + grub_script.tab.c grub_emu_init.c lib/datetime.c grub_emu_LDFLAGS = $(LIBCURSES)
@@ -137,7 +137,7 @@ normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/menu_viewer.c normal/menu_entry.c \ normal/misc.c grub_script.tab.c \ normal/script.c \ - normal/powerpc/setjmp.S + normal/powerpc/setjmp.S lib/datetime.c normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_ASFLAGS = $(COMMON_ASFLAGS) normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
sparc64-ieee1275.rmk +2 -2
@@ -64,7 +64,7 @@ grub_mkimage_SOURCES = util/sparc64/ieee1275/grub- # partmap/acorn.c \ # util/console.c util/grub-emu.c util/misc.c \ # util/hostdisk.c util/getroot.c \ -# util/sparc64/ieee1275/misc.c +# util/sparc64/ieee1275/misc.c lib/datetime.c grub_emu_LDFLAGS = $(LIBCURSES)
@@ -170,7 +170,7 @@ normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/menu_viewer.c normal/menu_entry.c \ normal/misc.c grub_script.tab.c \ normal/script.c \ - normal/sparc64/setjmp.S + normal/sparc64/setjmp.S lib/datetime.c normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_ASFLAGS = $(COMMON_ASFLAGS) normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
x86_64-efi.rmk +2 -2
@@ -66,7 +66,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - grub_emu_init.c + grub_emu_init.c lib/datetime.c grub_emu_LDFLAGS = $(LIBCURSES)
@@ -126,7 +126,7 @@ normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/menu_viewer.c normal/menu_entry.c \ normal/misc.c grub_script.tab.c \ normal/script.c \ - normal/x86_64/setjmp.S + normal/x86_64/setjmp.S lib/datetime.c normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_ASFLAGS = $(COMMON_ASFLAGS) normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
fs.c +2 -2
@@ -65,10 +65,10 @@ grub_fs_t grub_fs_probe (grub_device_t device) {grub_fs_t p; - autoint dummy_func (const char *filename,int dir); + autoint dummy_func (const char *filename,struct grub_dirhook_info info);int dummy_func (const char *filename __attribute__ ((unused)), -int dir __attribute__ ((unused))) +struct grub_dirhook_info info __attribute__ ((unused))) {return 1 ; }
rescue.c +2 -2
@@ -176,9 +176,9 @@ grub_rescue_print_devices (const char *name) }static int -grub_rescue_print_files (const char *filename,int dir) +grub_rescue_print_files (const char *filename,struct grub_dirhook_info info) { -grub_printf ("%s%s " , filename, dir ?"/" :"" ); +grub_printf ("%s%s " , filename, info.dir ?"/" :"" );return 0 ; }
datetime.c +42 -0
45 lines not on this page · raw message
xfs.c +5 -8
@@ -620,7 +620,7 @@ grub_xfs_mount (grub_disk_t disk)static grub_err_t grub_xfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_xfs_data *data =0 ;;struct grub_fshelp_node *fdiro =0 ;
@@ -633,14 +633,11 @@ grub_xfs_dir (grub_device_t device, const char *pa enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
afs.c +5 -8
@@ -562,7 +562,7 @@ grub_afs_close (grub_file_t file)static grub_err_t grub_afs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_afs_data *data =0 ;;struct grub_fshelp_node *fdiro =0 ;
@@ -575,14 +575,11 @@ grub_afs_dir (grub_device_t device, const char *pa enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
ntfs.c +7 -9
@@ -864,7 +864,8 @@ fail:static grub_err_t grub_ntfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_ntfs_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -877,14 +878,11 @@ grub_ntfs_dir (grub_device_t device, const char *p enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { -grub_free (node ); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR ); +grub_free (node); +return hook (filename, info); }#ifndef GRUB_UTIL
fat.c +127 -121
323 lines not on this page · raw message
udf.c +6 -9
@@ -768,7 +768,7 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,static grub_err_t grub_udf_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_udf_data *data =0 ;struct grub_fshelp_node rootnode;
@@ -782,14 +782,11 @@ grub_udf_dir (grub_device_t device, const char *pa enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { -grub_free (node ); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR ); +grub_free (node); +return hook (filename, info); }#ifndef GRUB_UTIL
iso9660.c +6 -8
@@ -666,7 +666,8 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,static grub_err_t grub_iso9660_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_iso9660_data *data =0 ;struct grub_fshelp_node rootnode;
@@ -680,14 +681,11 @@ grub_iso9660_dir (grub_device_t device, const char enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
affs.c +6 -8
@@ -456,7 +456,8 @@ grub_affs_read (grub_file_t file, char *buf, grub_static grub_err_t grub_affs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_affs_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -469,14 +470,11 @@ grub_affs_dir (grub_device_t device, const char *p enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
hfs.c +10 -5
@@ -721,7 +721,8 @@ grub_hfs_find_dir (struct grub_hfs_data *data, constatic grub_err_t grub_hfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {int inode;
@@ -732,13 +733,17 @@ grub_hfs_dir (grub_device_t device, const char *pachar fname[32 ] = {0 };char *filetype = rec->data;struct grub_hfs_catalog_key *ckey = rec->key; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info));grub_strncpy (fname, (char *) (ckey->str), ckey->strlen); -if (*filetype ==GRUB_HFS_FILETYPE_DIR ) -return hook (fname,1 ); -else if (*filetype ==GRUB_HFS_FILETYPE_FILE ) -return hook (fname,0 ); +if (*filetype ==GRUB_HFS_FILETYPE_DIR + || *filetype ==GRUB_HFS_FILETYPE_FILE ) + { + info.dir = (*filetype ==GRUB_HFS_FILETYPE_DIR ); +return hook (fname, info); + }return 0 ; }
reiserfs.c +6 -6
@@ -1266,7 +1266,8 @@ grub_reiserfs_close (grub_file_t file)/* Call HOOK with each file under DIR. */ static grub_err_t grub_reiserfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_reiserfs_data *data =0 ;struct grub_fshelp_node root, *found;
@@ -1280,12 +1281,11 @@ grub_reiserfs_dir (grub_device_t device, const cha enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); +return hook (filename, info); }#ifndef GRUB_UTIL grub_dl_ref (my_mod);
jfs.c +6 -5
@@ -728,7 +728,7 @@ grub_jfs_lookup_symlink (struct grub_jfs_data *datstatic grub_err_t grub_jfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_jfs_data *data =0 ;struct grub_jfs_diropen *diro =0 ;
@@ -752,14 +752,15 @@ grub_jfs_dir (grub_device_t device, const char *pawhile (grub_jfs_getent (diro) !=GRUB_ERR_OUT_OF_RANGE ) {struct grub_jfs_inode inode; -int isdir; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info));if (grub_jfs_read_inode (data, diro->ino, &inode)) goto fail; - isdir = (grub_le_to_cpu32 (inode.mode) - &GRUB_JFS_FILETYPE_MASK ) ==GRUB_JFS_FILETYPE_DIR ; -if (hook (diro->name, isdir)) + info.dir = (grub_le_to_cpu32 (inode.mode) + &GRUB_JFS_FILETYPE_MASK ) ==GRUB_JFS_FILETYPE_DIR ; +if (hook (diro->name, info)) goto fail; }
ext2.c +53 -11
106 lines not on this page · raw message
minix.c +8 -3
@@ -461,7 +461,8 @@ grub_minix_mount (grub_disk_t disk)static grub_err_t grub_minix_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_minix_data *data =0 ;struct grub_minix_sblock *sblock;
@@ -492,6 +493,9 @@ grub_minix_dir (grub_device_t device, const char *grub_uint16_t ino;char filename[data->filename_size +1 ];int dirino = data->ino; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); +if (grub_minix_read_file (data,0 , pos,sizeof (ino), (char *) &ino) <0 )
@@ -506,8 +510,9 @@ grub_minix_dir (grub_device_t device, const char */* The filetype is not stored in the dirent. Read the inode to find out the filetype. This *REALLY* sucks. */ grub_minix_read_inode (data,grub_le_to_cpu16 (ino)); -if (hook (filename, ((GRUB_MINIX_INODE_MODE (data) - &GRUB_MINIX_IFDIR ) ==GRUB_MINIX_IFDIR )) ?1 :0 ) + info.dir = ((GRUB_MINIX_INODE_MODE (data) + &GRUB_MINIX_IFDIR ) ==GRUB_MINIX_IFDIR ); +if (hook (filename, info) ?1 :0 )break ;/* Load the old inode back in. */
hfsplus.c +6 -8
@@ -885,7 +885,8 @@ grub_hfsplus_read (grub_file_t file, char *buf, grstatic grub_err_t grub_hfsplus_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_hfsplus_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -898,14 +899,11 @@ grub_hfsplus_dir (grub_device_t device, const char enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
cpio.c +7 -2
@@ -183,7 +183,8 @@ fail:static grub_err_t grub_cpio_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_cpio_data *data;grub_uint32_t ofs;
@@ -227,7 +228,11 @@ grub_cpio_dir (grub_device_t device, const char *pif ((!prev) || (grub_strcmp (prev, name) !=0 )) { -hook (name + len, p !=NULL ); +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = (p !=NULL ); + +hook (name + len, info);if (prev)grub_free (prev); prev = name;
sfs.c +6 -8
@@ -527,7 +527,8 @@ grub_sfs_read (grub_file_t file, char *buf, grub_sstatic grub_err_t grub_sfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_sfs_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -540,14 +541,11 @@ grub_sfs_dir (grub_device_t device, const char *pa enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
ufs.c +6 -2
@@ -544,7 +544,8 @@ grub_ufs_mount (grub_disk_t disk)static grub_err_t grub_ufs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_ufs_data *data;struct grub_ufs_sblock *sblock;
@@ -586,13 +587,16 @@ grub_ufs_dir (grub_device_t device, const char *pa {char filename[dirent.namelen +1 ]; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info));if (grub_ufs_read_file (data,0 , pos +sizeof (dirent), dirent.namelen, filename) <0 )break ; filename[dirent.namelen] ='\0' ; -if (hook (filename, dirent.filetype ==GRUB_UFS_FILETYPE_DIR )) + info.dir = (dirent.filetype ==GRUB_UFS_FILETYPE_DIR ); +if (hook (filename, info))break ; }
completion.c +2 -2
@@ -123,9 +123,9 @@ iterate_partition (grub_disk_t disk, const grub_pa }static int -iterate_dir (const char *filename,int dir) +iterate_dir (const char *filename,struct grub_dirhook_info info) { -if (! dir) +if (! info.dir) {const char *prefix;if (cmdline_state ==GRUB_PARSER_STATE_DQUOTE )
cmdline.c +1 -1
@@ -304,7 +304,7 @@ grub_cmdline_get (const char *prompt, char cmdlineif ((grub_getxy () >>8 ) !=0 )grub_putchar ('\n' ); -grub_printf (prompt); +grub_printf ("%s" , prompt); xpos = plen; ystart = ypos = (grub_getxy () &0xFF );
misc.c +18 -0
@@ -23,6 +23,7 @@#include <grub/err.h> #include <grub/misc.h> #include <grub/mm.h> +#include <grub/lib/datetime.h> /* Print the information on the device NAME. */ grub_err_t
@@ -63,6 +64,23 @@ grub_normal_print_device_info (const char *name) } grub_errno =GRUB_ERR_NONE ; } +if (fs->mtime) + { +grub_int32_t tm; +struct grub_datetime datetime; + (fs->mtime) (dev, &tm); +if (grub_errno ==GRUB_ERR_NONE ) + { +grub_unixtime2datetime (tm, &datetime); +grub_printf (", Last modification time %d-%02d-%02d " +"%02d:%02d:%02d %s" , + datetime.year, datetime.month, datetime.day, + datetime.hour, datetime.minute, datetime.second, +grub_get_weekday_name (&datetime)); + + } + grub_errno =GRUB_ERR_NONE ; + }if (fs->uuid) {char *uuid;
ls.c +30 -10
@@ -29,6 +29,7 @@#include <grub/term.h> #include <grub/partition.h> #include <grub/file.h> +#include <grub/lib/datetime.h> static const struct grub_arg_option options[] = {
@@ -68,25 +69,27 @@ grub_ls_list_files (char *dirname, int longlist, igrub_fs_t fs;const char *path;grub_device_t dev; - autoint print_files (const char *filename,int dir); - autoint print_files_long (const char *filename,int dir); + + autoint print_files (const char *filename,struct grub_dirhook_info info); + autoint print_files_long (const char *filename, +struct grub_dirhook_info info); -int print_files (const char *filename,int dir) +int print_files (const char *filename,struct grub_dirhook_info info) {if (all || filename[0 ] !='.' ) -grub_printf ("%s%s " , filename, dir ?"/" :"" ); +grub_printf ("%s%s " , filename, info.dir ?"/" :"" );return 0 ; } -int print_files_long (const char *filename,int dir) +int print_files_long (const char *filename,struct grub_dirhook_info info) {char pathname[grub_strlen (dirname) +grub_strlen (filename) +1 ];if ((! all) && (filename[0 ] =='.' ))return 0 ; -if (! dir) +if (! info.dir) {grub_file_t file;
@@ -138,7 +141,23 @@ grub_ls_list_files (char *dirname, int longlist, ielse grub_printf ("%-12s" ,"DIR" ); -grub_printf ("%s%s\n" , filename, dir ?"/" :"" ); +if (info.mtimeset) + { +struct grub_datetime datetime; +grub_unixtime2datetime (info.mtime, &datetime); +if (human) +grub_printf (" %d-%02d-%02d %02d:%02d:%02d %-11s " , + datetime.year, datetime.month, datetime.day, + datetime.hour, datetime.minute, + datetime.second, +grub_get_weekday_name (&datetime)); +else +grub_printf (" %04d%02d%02d%02d%02d%02d " , + datetime.year, datetime.month, + datetime.day, datetime.hour, + datetime.minute, datetime.second); + } +grub_printf ("%s%s\n" , filename, info.dir ?"/" :"" );return 0 ; }
@@ -181,7 +200,7 @@ grub_ls_list_files (char *dirname, int longlist, i/* PATH might be a regular file. */ char *p;grub_file_t file; - +struct grub_dirhook_info info; grub_errno =0 ; file =grub_file_open (dirname);
@@ -196,10 +215,11 @@ grub_ls_list_files (char *dirname, int longlist, i goto fail; all =1 ; +grub_memset (&info,0 ,sizeof (info));if (longlist) -print_files_long (p,0 ); +print_files_long (p, info);else -print_files (p,0 ); +print_files (p, info);grub_free (dirname); }
hostfs.c +8 -3
@@ -57,7 +57,8 @@ is_dir (const char *path, const char *name)static grub_err_t grub_hostfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {DIR *dir;
@@ -73,16 +74,20 @@ grub_hostfs_dir (grub_device_t device, const charwhile (1 ) {struct dirent *de; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); de =readdir (dir);if (! de)break ;#ifdef DT_DIR -hook (de->d_name, de->d_type ==DT_DIR ); + info.dir = (de->d_type ==DT_DIR );#else -hook (de->d_name,is_dir (path, de->d_name)); + info.dir =is_dir (path, de->d_name);#endif +hook (de->d_name, info); + }closedir (dir);
grub/lib/datetime.h +4 -0
@@ -41,4 +41,8 @@ grub_err_t grub_set_datetime (struct grub_datetimeint grub_get_weekday (struct grub_datetime *datetime);char *grub_get_weekday_name (struct grub_datetime *datetime); +void grub_unixtime2datetime (grub_int32_t nix, +struct grub_datetime *datetime); + +#endif /* ! KERNEL_DATETIME_HEADER */
grub/fs.h +12 -1
@@ -27,6 +27,13 @@/* Forward declaration is required, because of mutual reference. */ struct grub_file ; +struct grub_dirhook_info +{ +int dir:1 ; +int mtimeset:1 ; +grub_int32_t mtime; +}; +/* Filesystem descriptor. */ struct grub_fs {
@@ -35,7 +42,8 @@ struct grub_fs/* Call HOOK with each file under DIR. */ grub_err_t (*dir) (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)); +int (*hook) (const char *filename, +struct grub_dirhook_info info));/* Open a file named NAME and initialize FILE. */ grub_err_t (*open) (struct grub_file *file,const char *name);
@@ -56,6 +64,9 @@ struct grub_fscaller. */ grub_err_t (*uuid) (grub_device_t device,char **uuid); +/* Get writing time of filesystem. */ +grub_err_t (*mtime) (grub_device_t device,grub_int32_t *timebuf); +/* The next filesystem. */ struct grub_fs *next; };
grub/fshelp.h +2 -0
@@ -27,6 +27,8 @@typedef struct grub_fshelp_node *grub_fshelp_node_t ;#define GRUB_FSHELP_CASE_INSENSITIVE 0x100 +#define GRUB_FSHELP_TYPE_MASK 0xff +#define GRUB_FSHELP_FLAGS_MASK 0x100enum grub_fshelp_filetype {
ChangeLog +60 -0
63 lines not on this page · raw message
Made corrections to issues pointed by Vesa Jääskeläinen Regards
Vladimir 'phcoder' Serbinenko
Quoted 7 lines · phcoder
Hello. Here is the patch to support mtime. This is a prerequisite for -nt test which can be very useful for e.g. finding last compiled kernel Also in the same time it makes the dir call easily extendable
Regards
Vladimir 'phcoder' Serbinenko
Index: conf/common.rmk
===================================================================
i386-coreboot.rmk +2 -2
@@ -75,7 +75,7 @@ kern/loader.c kern/main.c kern/misc.c kern/parser.c \ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ - normal/completion.c normal/main.c \ + normal/completion.c normal/datetime.c normal/main.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/misc.c normal/script.c \ normal/color.c \
@@ -121,7 +121,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
i386-efi.rmk +3 -2
@@ -52,7 +52,8 @@ kern/loader.c kern/main.c kern/misc.c kern/parser.c \ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ - normal/completion.c normal/context.c normal/main.c \ + normal/completion.c normal/datetime.c normal/context.c \ + normal/main.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/misc.c normal/script.c \ normal/color.c \
@@ -118,9 +119,9 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \ normal/misc.c grub_script.tab.c \ normal/script.c \
normal/i386/setjmp.S
normal_mod_CFLAGS = $(COMMON_CFLAGS)
normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
@@ -175,7 +176,7 @@
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For datetime.mod
-datetime_mod_SOURCES = lib/datetime.c lib/efi/datetime.c +datetime_mod_SOURCES = lib/efi/datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS) datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
i386-ieee1275.rmk +3 -3
@@ -74,7 +74,7 @@ kern/loader.c kern/main.c kern/misc.c kern/parser.c \ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ - normal/completion.c normal/main.c \ + normal/completion.c normal/datetime.c normal/main.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/misc.c normal/script.c \ normal/color.c \
@@ -111,7 +111,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
@@ -190,7 +192,7 @@ lspci_mod_LDFLAGS = $(COMMON_LDFLAGS) # For datetime.mod -datetime_mod_SOURCES = lib/datetime.c lib/i386/datetime.c +datetime_mod_SOURCES = lib/i386/datetime.c datetime_mod_CFLAGS = $(COMMON_CFLAGS) datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
i386-pc.rmk +4 -3
@@ -128,7 +128,8 @@ kern/loader.c kern/main.c kern/misc.c kern/parser.c \ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ - normal/completion.c normal/main.c normal/color.c \ + normal/completion.c normal/datetime.c normal/main.c \ + normal/color.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/misc.c normal/script.c \ partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \
@@ -208,7 +228,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
@@ -344,7 +368,7 @@ pxecmd_mod_LDFLAGS = $(COMMON_LDFLAGS) # For datetime.mod -datetime_mod_SOURCES = lib/datetime.c lib/i386/datetime.c +datetime_mod_SOURCES = lib/i386/datetime.c datetime_mod_CFLAGS = $(COMMON_CFLAGS) datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
powerpc-ieee1275.rmk +2 -2
@@ -56,7 +56,7 @@ kern/misc.c kern/parser.c kern/partition.c kern/rescue.c \ kern/term.c fs/fshelp.c \ normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/menu_entry.c normal/menu_viewer.c normal/misc.c \ normal/script.c \
@@ -131,7 +131,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
sparc64-ieee1275.rmk +3 -2
@@ -56,7 +56,8 @@ # kern/file.c kern/fs.c kern/loader.c kern/main.c kern/misc.c \ # kern/parser.c kern/partition.c kern/rescue.c kern/term.c \ # normal/arg.c normal/cmdline.c normal/command.c \ -# normal/completion.c normal/context.c normal/execute.c \ +# normal/completion.c normal/datetime.c normal/context.c \ +# normal/execute.c \ # normal/function.c normal/lexer.c \ # normal/main.c normal/menu.c normal/menu_entry.c \ # normal/menu_viewer.c normal/misc.c \
@@ -164,7 +165,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
x86_64-efi.rmk +4 -3
@@ -54,7 +54,8 @@ kern/loader.c kern/main.c kern/misc.c kern/parser.c \ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ - normal/completion.c normal/context.c normal/main.c \ + normal/completion.c normal/datetime.c normal/context.c \ + normal/main.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/misc.c normal/script.c \ normal/color.c \
@@ -120,7 +121,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
@@ -177,7 +178,7 @@ lspci_mod_LDFLAGS = $(COMMON_LDFLAGS) # For datetime.mod -datetime_mod_SOURCES = lib/datetime.c lib/efi/datetime.c +datetime_mod_SOURCES = lib/efi/datetime.c datetime_mod_CFLAGS = $(COMMON_CFLAGS) datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
fs.c +2 -2
@@ -65,10 +65,10 @@ grub_fs_probe (grub_device_t device) {grub_fs_t p; - autoint dummy_func (const char *filename,int dir); + autoint dummy_func (const char *filename,struct grub_dirhook_info info);int dummy_func (const char *filename __attribute__ ((unused)), -int dir __attribute__ ((unused))) +struct grub_dirhook_info info __attribute__ ((unused))) {return 1 ; }
rescue.c +2 -2
@@ -176,9 +176,9 @@ }static int -grub_rescue_print_files (const char *filename,int dir) +grub_rescue_print_files (const char *filename,struct grub_dirhook_info info) { -grub_printf ("%s%s " , filename, dir ?"/" :"" ); +grub_printf ("%s%s " , filename, info.dir ?"/" :"" );return 0 ; }
datehook.c +1 -1
@@ -22,7 +22,7 @@#include <grub/env.h> #include <grub/misc.h> #include <grub/normal.h> -#include <grub/lib/datetime.h> +#include <grub/datetime.h> static char *grub_datetime_names[] = {
efi/datetime.c +1 -1
@@ -21,7 +21,7 @@#include <grub/symbol.h> #include <grub/efi/api.h> #include <grub/efi/efi.h> -#include <grub/lib/datetime.h> +#include <grub/datetime.h> grub_err_t grub_get_datetime (struct grub_datetime *datetime)
i386/datetime.c +1 -1
@@ -17,7 +17,7 @@* along with GRUB. If not, see <http://www.gnu.org/licenses/>. */ -#include <grub/lib/datetime.h> +#include <grub/datetime.h> #include <grub/i386/cmos.h> grub_err_t
datetime.c +0 -49
49 lines not on this page · raw message
xfs.c +5 -8
@@ -620,7 +620,7 @@static grub_err_t grub_xfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_xfs_data *data =0 ;;struct grub_fshelp_node *fdiro =0 ;
@@ -633,14 +633,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
afs.c +5 -8
@@ -562,7 +562,7 @@static grub_err_t grub_afs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_afs_data *data =0 ;;struct grub_fshelp_node *fdiro =0 ;
@@ -575,14 +575,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
ntfs.c +7 -9
@@ -864,7 +864,8 @@static grub_err_t grub_ntfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_ntfs_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -877,14 +878,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { -grub_free (node ); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR ); +grub_free (node); +return hook (filename, info); }#ifndef GRUB_UTIL
fat.c +127 -121
323 lines not on this page · raw message
udf.c +6 -9
@@ -768,7 +768,7 @@static grub_err_t grub_udf_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_udf_data *data =0 ;struct grub_fshelp_node rootnode;
@@ -782,14 +782,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { -grub_free (node ); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR ); +grub_free (node); +return hook (filename, info); }#ifndef GRUB_UTIL
iso9660.c +6 -8
@@ -666,7 +666,8 @@static grub_err_t grub_iso9660_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_iso9660_data *data =0 ;struct grub_fshelp_node rootnode;
@@ -680,14 +681,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
affs.c +6 -8
@@ -456,7 +456,8 @@static grub_err_t grub_affs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_affs_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -469,14 +470,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
hfs.c +10 -5
@@ -721,7 +721,8 @@static grub_err_t grub_hfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {int inode;
@@ -732,13 +733,17 @@char fname[32 ] = {0 };char *filetype = rec->data;struct grub_hfs_catalog_key *ckey = rec->key; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info));grub_strncpy (fname, (char *) (ckey->str), ckey->strlen); -if (*filetype ==GRUB_HFS_FILETYPE_DIR ) -return hook (fname,1 ); -else if (*filetype ==GRUB_HFS_FILETYPE_FILE ) -return hook (fname,0 ); +if (*filetype ==GRUB_HFS_FILETYPE_DIR + || *filetype ==GRUB_HFS_FILETYPE_FILE ) + { + info.dir = (*filetype ==GRUB_HFS_FILETYPE_DIR ); +return hook (fname, info); + }return 0 ; }
reiserfs.c +6 -6
@@ -1266,7 +1266,8 @@/* Call HOOK with each file under DIR. */ static grub_err_t grub_reiserfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_reiserfs_data *data =0 ;struct grub_fshelp_node root, *found;
@@ -1280,12 +1281,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); +return hook (filename, info); }#ifndef GRUB_UTIL grub_dl_ref (my_mod);
jfs.c +6 -5
@@ -728,7 +728,7 @@static grub_err_t grub_jfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_jfs_data *data =0 ;struct grub_jfs_diropen *diro =0 ;
@@ -752,14 +752,15 @@while (grub_jfs_getent (diro) !=GRUB_ERR_OUT_OF_RANGE ) {struct grub_jfs_inode inode; -int isdir; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info));if (grub_jfs_read_inode (data, diro->ino, &inode)) goto fail; - isdir = (grub_le_to_cpu32 (inode.mode) - &GRUB_JFS_FILETYPE_MASK ) ==GRUB_JFS_FILETYPE_DIR ; -if (hook (diro->name, isdir)) + info.dir = (grub_le_to_cpu32 (inode.mode) + &GRUB_JFS_FILETYPE_MASK ) ==GRUB_JFS_FILETYPE_DIR ; +if (hook (diro->name, info)) goto fail; }
ext2.c +53 -11
106 lines not on this page · raw message
minix.c +8 -3
@@ -461,7 +461,8 @@static grub_err_t grub_minix_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_minix_data *data =0 ;struct grub_minix_sblock *sblock;
@@ -492,6 +493,9 @@grub_uint16_t ino;char filename[data->filename_size +1 ];int dirino = data->ino; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); +if (grub_minix_read_file (data,0 , pos,sizeof (ino), (char *) &ino) <0 )
@@ -506,8 +510,9 @@/* The filetype is not stored in the dirent. Read the inode to find out the filetype. This *REALLY* sucks. */ grub_minix_read_inode (data,grub_le_to_cpu16 (ino)); -if (hook (filename, ((GRUB_MINIX_INODE_MODE (data) - &GRUB_MINIX_IFDIR ) ==GRUB_MINIX_IFDIR )) ?1 :0 ) + info.dir = ((GRUB_MINIX_INODE_MODE (data) + &GRUB_MINIX_IFDIR ) ==GRUB_MINIX_IFDIR ); +if (hook (filename, info) ?1 :0 )break ;/* Load the old inode back in. */
hfsplus.c +6 -8
@@ -885,7 +885,8 @@static grub_err_t grub_hfsplus_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_hfsplus_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -898,14 +899,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
cpio.c +7 -2
@@ -183,7 +183,8 @@static grub_err_t grub_cpio_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_cpio_data *data;grub_uint32_t ofs;
@@ -227,7 +228,11 @@if ((!prev) || (grub_strcmp (prev, name) !=0 )) { -hook (name + len, p !=NULL ); +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = (p !=NULL ); + +hook (name + len, info);if (prev)grub_free (prev); prev = name;
sfs.c +6 -8
@@ -527,7 +527,8 @@static grub_err_t grub_sfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_sfs_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -540,14 +541,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
ufs.c +6 -2
@@ -544,7 +544,8 @@static grub_err_t grub_ufs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_ufs_data *data;struct grub_ufs_sblock *sblock;
@@ -586,13 +587,16 @@ {char filename[dirent.namelen +1 ]; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info));if (grub_ufs_read_file (data,0 , pos +sizeof (dirent), dirent.namelen, filename) <0 )break ; filename[dirent.namelen] ='\0' ; -if (hook (filename, dirent.filetype ==GRUB_UFS_FILETYPE_DIR )) + info.dir = (dirent.filetype ==GRUB_UFS_FILETYPE_DIR ); +if (hook (filename, info))break ; }
grub/fs.h +12 -1
@@ -27,6 +27,13 @@/* Forward declaration is required, because of mutual reference. */ struct grub_file ; +struct grub_dirhook_info +{ +int dir:1 ; +int mtimeset:1 ; +grub_int32_t mtime; +}; +/* Filesystem descriptor. */ struct grub_fs {
@@ -35,7 +42,8 @@/* Call HOOK with each file under DIR. */ grub_err_t (*dir) (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)); +int (*hook) (const char *filename, +struct grub_dirhook_info info));/* Open a file named NAME and initialize FILE. */ grub_err_t (*open) (struct grub_file *file,const char *name);
@@ -56,6 +64,9 @@caller. */ grub_err_t (*uuid) (grub_device_t device,char **uuid); +/* Get writing time of filesystem. */ +grub_err_t (*mtime) (grub_device_t device,grub_int32_t *timebuf); +/* The next filesystem. */ struct grub_fs *next; };
grub/fshelp.h +2 -0
@@ -27,6 +27,8 @@typedef struct grub_fshelp_node *grub_fshelp_node_t ;#define GRUB_FSHELP_CASE_INSENSITIVE 0x100 +#define GRUB_FSHELP_TYPE_MASK 0xff +#define GRUB_FSHELP_FLAGS_MASK 0x100enum grub_fshelp_filetype {
completion.c +2 -2
@@ -123,9 +123,9 @@ }static int -iterate_dir (const char *filename,int dir) +iterate_dir (const char *filename,struct grub_dirhook_info info) { -if (! dir) +if (! info.dir) {const char *prefix;if (cmdline_state ==GRUB_PARSER_STATE_DQUOTE )
misc.c +18 -0
@@ -23,6 +23,7 @@#include <grub/err.h> #include <grub/misc.h> #include <grub/mm.h> +#include <grub/datetime.h> /* Print the information on the device NAME. */ grub_err_t
@@ -63,6 +64,23 @@ } grub_errno =GRUB_ERR_NONE ; } +if (fs->mtime) + { +grub_int32_t tm; +struct grub_datetime datetime; + (fs->mtime) (dev, &tm); +if (grub_errno ==GRUB_ERR_NONE ) + { +grub_unixtime2datetime (tm, &datetime); +grub_printf (", Last modification time %d-%02d-%02d " +"%02d:%02d:%02d %s" , + datetime.year, datetime.month, datetime.day, + datetime.hour, datetime.minute, datetime.second, +grub_get_weekday_name (&datetime)); + + } + grub_errno =GRUB_ERR_NONE ; + }if (fs->uuid) {char *uuid;
datetime.c +52 -1
62 lines not on this page · raw message
Property changes on: normal/datetime.c
___________________________________________________________________
Added: svn:mergeinfo
date.c +1 -1
@@ -22,7 +22,7 @@#include <grub/arg.h> #include <grub/err.h> #include <grub/misc.h> -#include <grub/lib/datetime.h> +#include <grub/datetime.h> #define GRUB_DATETIME_SET_YEAR 1#define GRUB_DATETIME_SET_MONTH 2
ls.c +27 -7
@@ -29,6 +29,7 @@#include <grub/term.h> #include <grub/partition.h> #include <grub/file.h> +#include <grub/datetime.h> static const struct grub_arg_option options[] = {
@@ -68,25 +69,27 @@grub_fs_t fs;const char *path;grub_device_t dev; - autoint print_files (const char *filename,int dir); - autoint print_files_long (const char *filename,int dir); + + autoint print_files (const char *filename,struct grub_dirhook_info info); + autoint print_files_long (const char *filename, +struct grub_dirhook_info info); -int print_files (const char *filename,int dir) +int print_files (const char *filename,struct grub_dirhook_info info) {if (all || filename[0 ] !='.' ) -grub_printf ("%s%s " , filename, dir ?"/" :"" ); +grub_printf ("%s%s " , filename, info.dir ?"/" :"" );return 0 ; } -int print_files_long (const char *filename,int dir) +int print_files_long (const char *filename,struct grub_dirhook_info info) {char pathname[grub_strlen (dirname) +grub_strlen (filename) +1 ];if ((! all) && (filename[0 ] =='.' ))return 0 ; -if (! dir) +if (! info.dir) {grub_file_t file;
@@ -138,7 +141,23 @@else grub_printf ("%-12s" ,"DIR" ); -grub_printf ("%s%s\n" , filename, dir ?"/" :"" ); +if (info.mtimeset) + { +struct grub_datetime datetime; +grub_unixtime2datetime (info.mtime, &datetime); +if (human) +grub_printf (" %d-%02d-%02d %02d:%02d:%02d %-11s " , + datetime.year, datetime.month, datetime.day, + datetime.hour, datetime.minute, + datetime.second, +grub_get_weekday_name (&datetime)); +else +grub_printf (" %04d%02d%02d%02d%02d%02d " , + datetime.year, datetime.month, + datetime.day, datetime.hour, + datetime.minute, datetime.second); + } +grub_printf ("%s%s\n" , filename, info.dir ?"/" :"" );return 0 ; }
@@ -181,3 +200,4 @@/* PATH might be a regular file. */ char *p;grub_file_t file; +struct grub_dirhook_info info;
grub_errno = 0;
file = grub_file_open (dirname);
@@ -196,10 +215,11 @@
goto fail;
all = 1;
+ grub_memset (&info, 0, sizeof (info));
if (longlist)
- print_files_long (p, 0);
+ print_files_long (p, info);
else
- print_files (p, 0);
+ print_files (p, info);
grub_free (dirname);
}
hostfs.c +8 -3
@@ -57,7 +57,8 @@static grub_err_t grub_hostfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {DIR *dir;
@@ -73,16 +74,20 @@while (1 ) {struct dirent *de; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); de =readdir (dir);if (! de)break ;#ifdef DT_DIR -hook (de->d_name, de->d_type ==DT_DIR ); + info.dir = (de->d_type ==DT_DIR );#else -hook (de->d_name,is_dir (path, de->d_name)); + info.dir =is_dir (path, de->d_name);#endif +hook (de->d_name, info); + }closedir (dir);
ChangeLog +64 -0
67 lines not on this page · raw message
Fixed an issue with FAT code
Quoted 13 lines · phcoder
Made corrections to issues pointed by Vesa Jääskeläinen Regards
Vladimir 'phcoder' SerbinenkoQuoted 7 lines · phcoder
Hello. Here is the patch to support mtime. This is a prerequisite for -nt test which can be very useful for e.g. finding last compiled kernel Also in the same time it makes the dir call easily extendable
Regards
Vladimir 'phcoder' Serbinenko
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko
Index: conf/common.rmk
===================================================================
i386-coreboot.rmk +2 -2
@@ -75,7 +75,7 @@ kern/loader.c kern/main.c kern/misc.c kern/parser.c \ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ - normal/completion.c normal/main.c \ + normal/completion.c normal/datetime.c normal/main.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/misc.c normal/script.c \ normal/color.c \
@@ -121,7 +121,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
i386-efi.rmk +3 -2
@@ -52,7 +52,8 @@ kern/loader.c kern/main.c kern/misc.c kern/parser.c \ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ - normal/completion.c normal/context.c normal/main.c \ + normal/completion.c normal/datetime.c normal/context.c \ + normal/main.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/misc.c normal/script.c \ normal/color.c \
@@ -118,9 +119,9 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \ normal/misc.c grub_script.tab.c \ normal/script.c \
normal/i386/setjmp.S
normal_mod_CFLAGS = $(COMMON_CFLAGS)
normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
@@ -175,7 +176,7 @@
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For datetime.mod
-datetime_mod_SOURCES = lib/datetime.c lib/efi/datetime.c +datetime_mod_SOURCES = lib/efi/datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS) datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
i386-ieee1275.rmk +3 -3
@@ -74,7 +74,7 @@ kern/loader.c kern/main.c kern/misc.c kern/parser.c \ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ - normal/completion.c normal/main.c \ + normal/completion.c normal/datetime.c normal/main.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/misc.c normal/script.c \ normal/color.c \
@@ -111,7 +111,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
@@ -190,7 +192,7 @@ lspci_mod_LDFLAGS = $(COMMON_LDFLAGS) # For datetime.mod -datetime_mod_SOURCES = lib/datetime.c lib/i386/datetime.c +datetime_mod_SOURCES = lib/i386/datetime.c datetime_mod_CFLAGS = $(COMMON_CFLAGS) datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
i386-pc.rmk +4 -3
@@ -128,7 +128,8 @@ kern/loader.c kern/main.c kern/misc.c kern/parser.c \ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ - normal/completion.c normal/main.c normal/color.c \ + normal/completion.c normal/datetime.c normal/main.c \ + normal/color.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/misc.c normal/script.c \ partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \
@@ -208,7 +228,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
@@ -344,7 +368,7 @@ pxecmd_mod_LDFLAGS = $(COMMON_LDFLAGS) # For datetime.mod -datetime_mod_SOURCES = lib/datetime.c lib/i386/datetime.c +datetime_mod_SOURCES = lib/i386/datetime.c datetime_mod_CFLAGS = $(COMMON_CFLAGS) datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
powerpc-ieee1275.rmk +2 -2
@@ -56,7 +56,7 @@ kern/misc.c kern/parser.c kern/partition.c kern/rescue.c \ kern/term.c fs/fshelp.c \ normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/menu_entry.c normal/menu_viewer.c normal/misc.c \ normal/script.c \
@@ -131,7 +131,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
sparc64-ieee1275.rmk +3 -2
@@ -56,7 +56,8 @@ # kern/file.c kern/fs.c kern/loader.c kern/main.c kern/misc.c \ # kern/parser.c kern/partition.c kern/rescue.c kern/term.c \ # normal/arg.c normal/cmdline.c normal/command.c \ -# normal/completion.c normal/context.c normal/execute.c \ +# normal/completion.c normal/datetime.c normal/context.c \ +# normal/execute.c \ # normal/function.c normal/lexer.c \ # normal/main.c normal/menu.c normal/menu_entry.c \ # normal/menu_viewer.c normal/misc.c \
@@ -164,7 +165,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
x86_64-efi.rmk +4 -3
@@ -54,7 +54,8 @@ kern/loader.c kern/main.c kern/misc.c kern/parser.c \ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ - normal/completion.c normal/context.c normal/main.c \ + normal/completion.c normal/datetime.c normal/context.c \ + normal/main.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/misc.c normal/script.c \ normal/color.c \
@@ -120,7 +121,7 @@ # keep it simpler to update to different architectures. # normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ - normal/completion.c normal/execute.c \ + normal/completion.c normal/datetime.c normal/execute.c \ normal/function.c normal/lexer.c normal/main.c normal/menu.c \ normal/color.c \ normal/menu_viewer.c normal/menu_entry.c \
@@ -177,7 +178,7 @@ lspci_mod_LDFLAGS = $(COMMON_LDFLAGS) # For datetime.mod -datetime_mod_SOURCES = lib/datetime.c lib/efi/datetime.c +datetime_mod_SOURCES = lib/efi/datetime.c datetime_mod_CFLAGS = $(COMMON_CFLAGS) datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
fs.c +2 -2
@@ -65,10 +65,10 @@ grub_fs_probe (grub_device_t device) {grub_fs_t p; - autoint dummy_func (const char *filename,int dir); + autoint dummy_func (const char *filename,struct grub_dirhook_info info);int dummy_func (const char *filename __attribute__ ((unused)), -int dir __attribute__ ((unused))) +struct grub_dirhook_info info __attribute__ ((unused))) {return 1 ; }
rescue.c +2 -2
@@ -176,9 +176,9 @@ }static int -grub_rescue_print_files (const char *filename,int dir) +grub_rescue_print_files (const char *filename,struct grub_dirhook_info info) { -grub_printf ("%s%s " , filename, dir ?"/" :"" ); +grub_printf ("%s%s " , filename, info.dir ?"/" :"" );return 0 ; }
datehook.c +1 -1
@@ -22,7 +22,7 @@#include <grub/env.h> #include <grub/misc.h> #include <grub/normal.h> -#include <grub/lib/datetime.h> +#include <grub/datetime.h> static char *grub_datetime_names[] = {
efi/datetime.c +1 -1
@@ -21,7 +21,7 @@#include <grub/symbol.h> #include <grub/efi/api.h> #include <grub/efi/efi.h> -#include <grub/lib/datetime.h> +#include <grub/datetime.h> grub_err_t grub_get_datetime (struct grub_datetime *datetime)
i386/datetime.c +1 -1
@@ -17,7 +17,7 @@* along with GRUB. If not, see <http://www.gnu.org/licenses/>. */ -#include <grub/lib/datetime.h> +#include <grub/datetime.h> #include <grub/i386/cmos.h> grub_err_t
datetime.c +0 -49
49 lines not on this page · raw message
xfs.c +5 -8
@@ -620,7 +620,7 @@static grub_err_t grub_xfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_xfs_data *data =0 ;;struct grub_fshelp_node *fdiro =0 ;
@@ -633,14 +633,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
afs.c +5 -8
@@ -562,7 +562,7 @@static grub_err_t grub_afs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_afs_data *data =0 ;;struct grub_fshelp_node *fdiro =0 ;
@@ -575,14 +575,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
ntfs.c +7 -9
@@ -864,7 +864,8 @@static grub_err_t grub_ntfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_ntfs_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -877,14 +878,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { -grub_free (node ); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR ); +grub_free (node); +return hook (filename, info); }#ifndef GRUB_UTIL
fat.c +127 -121
323 lines not on this page · raw message
udf.c +6 -9
@@ -768,7 +768,7 @@static grub_err_t grub_udf_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_udf_data *data =0 ;struct grub_fshelp_node rootnode;
@@ -782,14 +782,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { -grub_free (node ); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR ); +grub_free (node); +return hook (filename, info); }#ifndef GRUB_UTIL
iso9660.c +6 -8
@@ -666,7 +666,8 @@static grub_err_t grub_iso9660_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_iso9660_data *data =0 ;struct grub_fshelp_node rootnode;
@@ -680,14 +681,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
affs.c +6 -8
@@ -456,7 +456,8 @@static grub_err_t grub_affs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_affs_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -469,14 +470,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
hfs.c +10 -5
@@ -721,7 +721,8 @@static grub_err_t grub_hfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {int inode;
@@ -732,13 +733,17 @@char fname[32 ] = {0 };char *filetype = rec->data;struct grub_hfs_catalog_key *ckey = rec->key; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info));grub_strncpy (fname, (char *) (ckey->str), ckey->strlen); -if (*filetype ==GRUB_HFS_FILETYPE_DIR ) -return hook (fname,1 ); -else if (*filetype ==GRUB_HFS_FILETYPE_FILE ) -return hook (fname,0 ); +if (*filetype ==GRUB_HFS_FILETYPE_DIR + || *filetype ==GRUB_HFS_FILETYPE_FILE ) + { + info.dir = (*filetype ==GRUB_HFS_FILETYPE_DIR ); +return hook (fname, info); + }return 0 ; }
reiserfs.c +6 -6
@@ -1266,7 +1266,8 @@/* Call HOOK with each file under DIR. */ static grub_err_t grub_reiserfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_reiserfs_data *data =0 ;struct grub_fshelp_node root, *found;
@@ -1280,12 +1281,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); +return hook (filename, info); }#ifndef GRUB_UTIL grub_dl_ref (my_mod);
jfs.c +6 -5
@@ -728,7 +728,7 @@static grub_err_t grub_jfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename,struct grub_dirhook_info info)) {struct grub_jfs_data *data =0 ;struct grub_jfs_diropen *diro =0 ;
@@ -752,14 +752,15 @@while (grub_jfs_getent (diro) !=GRUB_ERR_OUT_OF_RANGE ) {struct grub_jfs_inode inode; -int isdir; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info));if (grub_jfs_read_inode (data, diro->ino, &inode)) goto fail; - isdir = (grub_le_to_cpu32 (inode.mode) - &GRUB_JFS_FILETYPE_MASK ) ==GRUB_JFS_FILETYPE_DIR ; -if (hook (diro->name, isdir)) + info.dir = ((grub_le_to_cpu32 (inode.mode) + &GRUB_JFS_FILETYPE_MASK ) ==GRUB_JFS_FILETYPE_DIR ); +if (hook (diro->name, info)) goto fail; }
ext2.c +53 -11
106 lines not on this page · raw message
minix.c +8 -3
@@ -461,7 +461,8 @@static grub_err_t grub_minix_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_minix_data *data =0 ;struct grub_minix_sblock *sblock;
@@ -492,6 +493,9 @@grub_uint16_t ino;char filename[data->filename_size +1 ];int dirino = data->ino; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); +if (grub_minix_read_file (data,0 , pos,sizeof (ino), (char *) &ino) <0 )
@@ -506,8 +510,9 @@/* The filetype is not stored in the dirent. Read the inode to find out the filetype. This *REALLY* sucks. */ grub_minix_read_inode (data,grub_le_to_cpu16 (ino)); -if (hook (filename, ((GRUB_MINIX_INODE_MODE (data) - &GRUB_MINIX_IFDIR ) ==GRUB_MINIX_IFDIR )) ?1 :0 ) + info.dir = ((GRUB_MINIX_INODE_MODE (data) + &GRUB_MINIX_IFDIR ) ==GRUB_MINIX_IFDIR ); +if (hook (filename, info) ?1 :0 )break ;/* Load the old inode back in. */
hfsplus.c +6 -8
@@ -885,7 +885,8 @@static grub_err_t grub_hfsplus_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_hfsplus_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -898,14 +899,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
cpio.c +7 -2
@@ -183,7 +183,8 @@static grub_err_t grub_cpio_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_cpio_data *data;grub_uint32_t ofs;
@@ -227,7 +228,11 @@if ((!prev) || (grub_strcmp (prev, name) !=0 )) { -hook (name + len, p !=NULL ); +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = (p !=NULL ); + +hook (name + len, info);if (prev)grub_free (prev); prev = name;
sfs.c +6 -8
@@ -527,7 +527,8 @@static grub_err_t grub_sfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_sfs_data *data =0 ;struct grub_fshelp_node *fdiro =0 ;
@@ -540,14 +541,11 @@ enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); + info.dir = ((filetype &GRUB_FSHELP_TYPE_MASK ) ==GRUB_FSHELP_DIR );grub_free (node); - -if (filetype ==GRUB_FSHELP_DIR ) -return hook (filename,1 ); -else -return hook (filename,0 ); - -return 0 ; +return hook (filename, info); }#ifndef GRUB_UTIL
ufs.c +6 -2
@@ -544,7 +544,8 @@static grub_err_t grub_ufs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {struct grub_ufs_data *data;struct grub_ufs_sblock *sblock;
@@ -586,13 +587,16 @@ {char filename[dirent.namelen +1 ]; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info));if (grub_ufs_read_file (data,0 , pos +sizeof (dirent), dirent.namelen, filename) <0 )break ; filename[dirent.namelen] ='\0' ; -if (hook (filename, dirent.filetype ==GRUB_UFS_FILETYPE_DIR )) + info.dir = (dirent.filetype ==GRUB_UFS_FILETYPE_DIR ); +if (hook (filename, info))break ; }
grub/fs.h +12 -1
@@ -27,6 +27,13 @@/* Forward declaration is required, because of mutual reference. */ struct grub_file ; +struct grub_dirhook_info +{ +int dir:1 ; +int mtimeset:1 ; +grub_int32_t mtime; +}; +/* Filesystem descriptor. */ struct grub_fs {
@@ -35,7 +42,8 @@/* Call HOOK with each file under DIR. */ grub_err_t (*dir) (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)); +int (*hook) (const char *filename, +struct grub_dirhook_info info));/* Open a file named NAME and initialize FILE. */ grub_err_t (*open) (struct grub_file *file,const char *name);
@@ -56,6 +64,9 @@caller. */ grub_err_t (*uuid) (grub_device_t device,char **uuid); +/* Get writing time of filesystem. */ +grub_err_t (*mtime) (grub_device_t device,grub_int32_t *timebuf); +/* The next filesystem. */ struct grub_fs *next; };
grub/fshelp.h +2 -0
@@ -27,6 +27,8 @@typedef struct grub_fshelp_node *grub_fshelp_node_t ;#define GRUB_FSHELP_CASE_INSENSITIVE 0x100 +#define GRUB_FSHELP_TYPE_MASK 0xff +#define GRUB_FSHELP_FLAGS_MASK 0x100enum grub_fshelp_filetype {
completion.c +2 -2
@@ -123,9 +123,9 @@ }static int -iterate_dir (const char *filename,int dir) +iterate_dir (const char *filename,struct grub_dirhook_info info) { -if (! dir) +if (! info.dir) {const char *prefix;if (cmdline_state ==GRUB_PARSER_STATE_DQUOTE )
misc.c +18 -0
@@ -23,6 +23,7 @@#include <grub/err.h> #include <grub/misc.h> #include <grub/mm.h> +#include <grub/datetime.h> /* Print the information on the device NAME. */ grub_err_t
@@ -63,6 +64,23 @@ } grub_errno =GRUB_ERR_NONE ; } +if (fs->mtime) + { +grub_int32_t tm; +struct grub_datetime datetime; + (fs->mtime) (dev, &tm); +if (grub_errno ==GRUB_ERR_NONE ) + { +grub_unixtime2datetime (tm, &datetime); +grub_printf (", Last modification time %d-%02d-%02d " +"%02d:%02d:%02d %s" , + datetime.year, datetime.month, datetime.day, + datetime.hour, datetime.minute, datetime.second, +grub_get_weekday_name (&datetime)); + + } + grub_errno =GRUB_ERR_NONE ; + }if (fs->uuid) {char *uuid;
datetime.c +52 -1
62 lines not on this page · raw message
Property changes on: normal/datetime.c
___________________________________________________________________
Added: svn:mergeinfo
date.c +1 -1
@@ -22,7 +22,7 @@#include <grub/arg.h> #include <grub/err.h> #include <grub/misc.h> -#include <grub/lib/datetime.h> +#include <grub/datetime.h> #define GRUB_DATETIME_SET_YEAR 1#define GRUB_DATETIME_SET_MONTH 2
ls.c +27 -7
@@ -29,6 +29,7 @@#include <grub/term.h> #include <grub/partition.h> #include <grub/file.h> +#include <grub/datetime.h> static const struct grub_arg_option options[] = {
@@ -68,25 +69,27 @@grub_fs_t fs;const char *path;grub_device_t dev; - autoint print_files (const char *filename,int dir); - autoint print_files_long (const char *filename,int dir); + + autoint print_files (const char *filename,struct grub_dirhook_info info); + autoint print_files_long (const char *filename, +struct grub_dirhook_info info); -int print_files (const char *filename,int dir) +int print_files (const char *filename,struct grub_dirhook_info info) {if (all || filename[0 ] !='.' ) -grub_printf ("%s%s " , filename, dir ?"/" :"" ); +grub_printf ("%s%s " , filename, info.dir ?"/" :"" );return 0 ; } -int print_files_long (const char *filename,int dir) +int print_files_long (const char *filename,struct grub_dirhook_info info) {char pathname[grub_strlen (dirname) +grub_strlen (filename) +1 ];if ((! all) && (filename[0 ] =='.' ))return 0 ; -if (! dir) +if (! info.dir) {grub_file_t file;
@@ -138,7 +141,23 @@else grub_printf ("%-12s" ,"DIR" ); -grub_printf ("%s%s\n" , filename, dir ?"/" :"" ); +if (info.mtimeset) + { +struct grub_datetime datetime; +grub_unixtime2datetime (info.mtime, &datetime); +if (human) +grub_printf (" %d-%02d-%02d %02d:%02d:%02d %-11s " , + datetime.year, datetime.month, datetime.day, + datetime.hour, datetime.minute, + datetime.second, +grub_get_weekday_name (&datetime)); +else +grub_printf (" %04d%02d%02d%02d%02d%02d " , + datetime.year, datetime.month, + datetime.day, datetime.hour, + datetime.minute, datetime.second); + } +grub_printf ("%s%s\n" , filename, info.dir ?"/" :"" );return 0 ; }
@@ -181,3 +200,4 @@/* PATH might be a regular file. */ char *p;grub_file_t file; +struct grub_dirhook_info info;
grub_errno = 0;
file = grub_file_open (dirname);
@@ -196,10 +215,11 @@
goto fail;
all = 1;
+ grub_memset (&info, 0, sizeof (info));
if (longlist)
- print_files_long (p, 0);
+ print_files_long (p, info);
else
- print_files (p, 0);
+ print_files (p, info);
grub_free (dirname);
}
hostfs.c +8 -3
@@ -57,7 +57,8 @@static grub_err_t grub_hostfs_dir (grub_device_t device,const char *path, -int (*hook) (const char *filename,int dir)) +int (*hook) (const char *filename, +struct grub_dirhook_info info)) {DIR *dir;
@@ -73,16 +74,20 @@while (1 ) {struct dirent *de; +struct grub_dirhook_info info; +grub_memset (&info,0 ,sizeof (info)); de =readdir (dir);if (! de)break ;#ifdef DT_DIR -hook (de->d_name, de->d_type ==DT_DIR ); + info.dir = (de->d_type ==DT_DIR );#else -hook (de->d_name,is_dir (path, de->d_name)); + info.dir =is_dir (path, de->d_name);#endif +hook (de->d_name, info); + }closedir (dir);
ChangeLog +63 -0
66 lines not on this page · raw message