]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/disk/loopback.c: Use sequential IDs rather than pointer.
authorVladimir Serbinenko <phcoder@gmail.com>
Sun, 15 Dec 2013 13:31:21 +0000 (14:31 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sun, 15 Dec 2013 13:31:21 +0000 (14:31 +0100)
In case of quick removal of loopback and adding another one it may
get same ID, confusing the cache system.

ChangeLog
grub-core/disk/loopback.c

index 136a78bb59d4047c59f77c37d85125077c8e0f4f..506b85dbc81692a92095ee0c20f650c6fcb7700f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-12-15  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/disk/loopback.c: Use sequential IDs rather than pointer.
+
+       In case of quick removal of loopback and adding another one it may
+       get same ID, confusing the cache system.
+
 2013-12-15  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/commands/acpi.c: Use grub_addr_t rather than long when
index d9fa1f3c57df219042579fad2f15d887eb0592be..2d8deaeafbd128cf6b791adc4a50fec4e53770a4 100644 (file)
@@ -32,9 +32,11 @@ struct grub_loopback
   char *devname;
   grub_file_t file;
   struct grub_loopback *next;
+  unsigned long id;
 };
 
 static struct grub_loopback *loopback_list;
+static unsigned long last_id = 0;
 
 static const struct grub_arg_option options[] =
   {
@@ -120,6 +122,7 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
     }
 
   newdev->file = file;
+  newdev->id = last_id++;
 
   /* Add the new entry to the list.  */
   newdev->next = loopback_list;
@@ -171,7 +174,7 @@ grub_loopback_open (const char *name, grub_disk_t disk)
   disk->max_agglomerate = 1 << (29 - GRUB_DISK_SECTOR_BITS
                                - GRUB_DISK_CACHE_BITS);
 
-  disk->id = (unsigned long) dev;
+  disk->id = dev->id;
 
   disk->data = dev;