]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
mtime support for cpio and tar
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 10 Dec 2010 07:42:40 +0000 (08:42 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 10 Dec 2010 07:42:40 +0000 (08:42 +0100)
grub-core/fs/cpio.c

index c087b4f90e1d9773e2f7740328b8d756e3ab4ec1..486d8215c774c3cefe8efcd62b06012333a6f48c 100644 (file)
@@ -78,7 +78,7 @@ static grub_dl_t my_mod;
 
 static grub_err_t
 grub_cpio_find_file (struct grub_cpio_data *data, char **name,
-                    grub_uint32_t * ofs)
+                    grub_int32_t *mtime, grub_uint32_t * ofs)
 {
 #ifndef MODE_USTAR
       struct head hd;
@@ -91,6 +91,8 @@ grub_cpio_find_file (struct grub_cpio_data *data, char **name,
        return grub_error (GRUB_ERR_BAD_FS, "invalid cpio archive");
 
       data->size = (((grub_uint32_t) hd.filesize_1) << 16) + hd.filesize_2;
+      if (mtime)
+       *mtime = (((grub_uint32_t) hd.mtime_1) << 16) + hd.mtime_2;
 
       if (hd.namesize & 1)
        hd.namesize++;
@@ -139,6 +141,8 @@ grub_cpio_find_file (struct grub_cpio_data *data, char **name,
       data->dofs = data->hofs + GRUB_DISK_SECTOR_SIZE;
       *ofs = data->dofs + ((data->size + GRUB_DISK_SECTOR_SIZE - 1) &
                           ~(GRUB_DISK_SECTOR_SIZE - 1));
+      if (mtime)
+       *mtime = grub_strtoul (hd.mtime, NULL, 8);
 #endif
   return GRUB_ERR_NONE;
 }
@@ -204,7 +208,9 @@ grub_cpio_dir (grub_device_t device, const char *path,
   data->hofs = 0;
   while (1)
     {
-      if (grub_cpio_find_file (data, &name, &ofs))
+      grub_int32_t mtime;
+
+      if (grub_cpio_find_file (data, &name, &mtime, &ofs))
        goto fail;
 
       if (!ofs)
@@ -227,6 +233,8 @@ grub_cpio_dir (grub_device_t device, const char *path,
              struct grub_dirhook_info info;
              grub_memset (&info, 0, sizeof (info));
              info.dir = (p != NULL);
+             info.mtime = mtime;
+             info.mtimeset = 1;
 
              hook (name + len, &info);
              if (prev)
@@ -269,7 +277,7 @@ grub_cpio_open (grub_file_t file, const char *name)
   data->hofs = 0;
   while (1)
     {
-      if (grub_cpio_find_file (data, &fn, &ofs))
+      if (grub_cpio_find_file (data, &fn, NULL, &ofs))
        goto fail;
 
       if (!ofs)