]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Display the path of the file when file is not found
authorYves Blusseau <blusseau@zetam.org>
Sun, 26 Jun 2011 19:48:52 +0000 (21:48 +0200)
committerYves Blusseau <blusseau@zetam.org>
Sun, 26 Jun 2011 19:48:52 +0000 (21:48 +0200)
* grub-core/fs/fat.c: Display the filename when file is not found.
* grub-core/fs/fshelp.c: Likewise.
* grub-core/fs/hfs.c: Likewise.
* grub-core/fs/jfs.c: Likewise.
* grub-core/fs/minix.c: Likewise.
* grub-core/fs/ufs.c: Likewise.
* grub-core/fs/btrfs.c: Likewise.
* grub-core/commands/i386/pc/play.c: Likewise.

ChangeLog
grub-core/commands/i386/pc/play.c
grub-core/fs/btrfs.c
grub-core/fs/fat.c
grub-core/fs/fshelp.c
grub-core/fs/hfs.c
grub-core/fs/jfs.c
grub-core/fs/minix.c
grub-core/fs/ufs.c

index 17be445af760777eee8195a398aeae8a5a2d6cef..bd6e311bdf824d69cdb35e67762b41d6cfd4fca8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-06-26  Yves Blusseau  <blusseau@zetam.org>
+
+       Display the path of the file when file is not found
+
+       * grub-core/fs/fat.c: Display the filename when file is not found.
+       * grub-core/fs/fshelp.c: Likewise.
+       * grub-core/fs/hfs.c: Likewise.
+       * grub-core/fs/jfs.c: Likewise.
+       * grub-core/fs/minix.c: Likewise.
+       * grub-core/fs/ufs.c: Likewise.
+       * grub-core/fs/btrfs.c: Likewise.
+       * grub-core/commands/i386/pc/play.c: Likewise.
+
 2011-06-26  Szymon Janc <szymon@janc.net.pl>
 
        * grub-core/commands/cmp.c (grub_cmd_cmp): Remove unnecessary NULL
index 57980eb920a24a24b4bb203cfe0c99392540115b..1adf296ec80b4b1546b7694f37bb566e7e23af5f 100644 (file)
@@ -192,7 +192,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
       file = grub_file_open (args[0]);
 
       if (! file)
-        return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+        return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", args[0]);
 
       if (grub_file_read (file, &tempo, sizeof (tempo)) != sizeof (tempo))
         {
@@ -227,7 +227,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
 
       if (*end)
         /* Was not a number either, assume it was supposed to be a file name.  */
-        return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+        return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", args[0]);
 
       grub_dprintf ("play","tempo = %d\n", tempo);
 
index 533529e3f22edebaa042c3a77c874afa943ce55e..6470c981991d765d23f634163a40fd1c2b8a8e7f 100644 (file)
@@ -1054,6 +1054,7 @@ find_path (struct grub_btrfs_data *data,
   const char *ctoken;
   grub_size_t ctokenlen;
   char *path_alloc = NULL;
+  char *origpath = NULL;
   unsigned symlinks_max = 32;
 
   *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
@@ -1062,6 +1063,9 @@ find_path (struct grub_btrfs_data *data,
   key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
   key->offset = 0;
   skip_default = 1;
+  origpath = grub_strdup (path);
+  if (!origpath)
+    return grub_errno;
 
   while (1)
     {
@@ -1086,6 +1090,7 @@ find_path (struct grub_btrfs_data *data,
       if (*type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
        {
          grub_free (path_alloc);
+         grub_free (origpath);
          return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
        }
 
@@ -1098,13 +1103,16 @@ find_path (struct grub_btrfs_data *data,
        {
          grub_free (direl);
          grub_free (path_alloc);
+         grub_free (origpath);
          return err;
        }
       if (key_cmp (key, &key_out) != 0)
        {
          grub_free (direl);
          grub_free (path_alloc);
-         return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+         err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
+         grub_free (origpath);
+         return err;
        }
 
       struct grub_btrfs_dir_item *cdirel;
@@ -1116,6 +1124,7 @@ find_path (struct grub_btrfs_data *data,
          if (!direl)
            {
              grub_free (path_alloc);
+             grub_free (origpath);
              return grub_errno;
            }
        }
@@ -1125,6 +1134,7 @@ find_path (struct grub_btrfs_data *data,
        {
          grub_free (direl);
          grub_free (path_alloc);
+         grub_free (origpath);
          return err;
        }
 
@@ -1144,7 +1154,9 @@ find_path (struct grub_btrfs_data *data,
        {
          grub_free (direl);
          grub_free (path_alloc);
-         return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+         err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
+         grub_free (origpath);
+         return err;
        }
 
       if (!skip_default)
@@ -1158,6 +1170,7 @@ find_path (struct grub_btrfs_data *data,
            {
              grub_free (direl);
              grub_free (path_alloc);
+             grub_free (origpath);
              return grub_error (GRUB_ERR_SYMLINK_LOOP,
                                 "too deep nesting of symlinks");
            }
@@ -1168,6 +1181,7 @@ find_path (struct grub_btrfs_data *data,
            {
              grub_free (direl);
              grub_free (path_alloc);
+             grub_free (origpath);
              return err;
            }
          tmp = grub_malloc (grub_le_to_cpu64 (inode.size)
@@ -1176,6 +1190,7 @@ find_path (struct grub_btrfs_data *data,
            {
              grub_free (direl);
              grub_free (path_alloc);
+             grub_free (origpath);
              return grub_errno;
            }
 
@@ -1186,12 +1201,14 @@ find_path (struct grub_btrfs_data *data,
            {
              grub_free (direl);
              grub_free (path_alloc);
+             grub_free (origpath);
              grub_free (tmp);
              return grub_errno;
            }
          grub_memcpy (tmp + grub_le_to_cpu64 (inode.size), path, 
                       grub_strlen (path) + 1);
          grub_free (path_alloc);
+         grub_free (origpath);
          path = path_alloc = tmp;
          if (path[0] == '/')
            {
@@ -1218,6 +1235,7 @@ find_path (struct grub_btrfs_data *data,
              {
                grub_free (direl);
                grub_free (path_alloc);
+               grub_free (origpath);
                return err;
              }
            if (cdirel->key.object_id != key_out.object_id
@@ -1225,7 +1243,9 @@ find_path (struct grub_btrfs_data *data,
              {
                grub_free (direl);
                grub_free (path_alloc);
-               return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+               err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
+               grub_free (origpath);
+               return err;
              }
            err = grub_btrfs_read_logical (data, elemaddr,
                                           &ri, sizeof (ri));
@@ -1233,6 +1253,7 @@ find_path (struct grub_btrfs_data *data,
              {
                grub_free (direl);
                grub_free (path_alloc);
+               grub_free (origpath);
                return err;
              }
            key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
@@ -1246,7 +1267,9 @@ find_path (struct grub_btrfs_data *data,
            {
              grub_free (direl);
              grub_free (path_alloc);
-             return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+             err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
+             grub_free (origpath);
+             return err;
            }
          *key = cdirel->key;
          if (*type == GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
@@ -1254,6 +1277,7 @@ find_path (struct grub_btrfs_data *data,
          break;
        default:
          grub_free (path_alloc);
+         grub_free (origpath);
          grub_free (direl);
          return grub_error (GRUB_ERR_BAD_FS, "unrecognised object type 0x%x", 
                             cdirel->key.type);
index f617bb0f4eb1dcbbb1a7f3f102b7eb721b90afba..c78d3fbe6179da79e1b25b40972ce9bfdec588af 100644 (file)
@@ -565,6 +565,7 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
                                const struct grub_dirhook_info *info))
 {
   char *dirname, *dirp;
+  char *origpath = NULL;
   int call_hook;
   int found = 0;
 
@@ -605,6 +606,10 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
       return 0;
     }
 
+  origpath = grub_strdup (path);
+  if (!origpath)
+    return 0;
+
   /* Extract a directory name.  */
   while (*path == '/')
     path++;
@@ -616,7 +621,7 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
 
       dirname = grub_malloc (len + 1);
       if (! dirname)
-       return 0;
+       goto fail;
 
       grub_memcpy (dirname, path, len);
       dirname[len] = '\0';
@@ -629,9 +634,11 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
 
   grub_fat_iterate_dir (disk, data, iter_hook);
   if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook)
-    grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+    grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
 
+ fail:
   grub_free (dirname);
+  grub_free (origpath);
 
   return found ? dirp : 0;
 }
index f879885acd8758173d2fe88fa5169dd1909df915..2ff78c423ba7c6971eb1f69c229fead6917daa5b 100644 (file)
@@ -197,7 +197,7 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
          name = next;
        }
 
-      return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+      return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path);
     }
 
   if (!path || path[0] != '/')
index cb7679ecba5016986850a15e4770e9b5cd32a9fb..6f27c69c48d6f2cfe47575bd59857323a26a1356 100644 (file)
@@ -921,7 +921,7 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
       if (! grub_hfs_find_node (data, (char *) &key, data->cat_root,
                                0, (char *) &fdrec.frec, sizeof (fdrec.frec)))
        {
-         grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+         grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
          goto fail;
        }
 
index c131169d83f469f58c10e88b7b7e00d9fae68307..36ec5fd25fc0e4a37fb729440f6e75f4b5d71193 100644 (file)
@@ -699,7 +699,7 @@ grub_jfs_find_file (struct grub_jfs_data *data, const char *path)
     }
 
   grub_jfs_closedir (diro);
-  grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+  grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path);
   return grub_errno;
 }
 
index 64a64cca03539c44f5e8a7effcfbc7b169abf0b7..055f890959887226d22eea560d6101b1f464aa79 100644 (file)
@@ -424,7 +424,7 @@ grub_minix_find_file (struct grub_minix_data *data, const char *path)
       pos += sizeof (ino) + data->filename_size;
     } while (pos < GRUB_MINIX_INODE_SIZE (data));
 
-  grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+  grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path);
   return grub_errno;
 }
 
index 86fe8af65e169070cce05bd3040c693de9738070..0f4ea0019dfbb755a903f787db08b8b4381172d1 100644 (file)
@@ -514,7 +514,7 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
       pos += grub_le_to_cpu16 (dirent.direntlen);
     } while (pos < INODE_SIZE (data));
 
-  grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
+  grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path);
   return grub_errno;
 }