Skip to contentSkip to conversation

disk: Move hardcoded max disk size literal to a GRUB_DISK_MAX_SECTORS in disk.h

PATCH Superseded Glenn Washburn 2 participants 13 messages Nov 27, 2020 – Dec 11, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 disk: Move hardcoded max disk size literal to a GRUB_DISK_MAX_SECTORS in disk.h

There is a hardcoded maximum disk size that can be read or written from, currently set at 1EiB in grub_disk_adjust_range. Move the literal into a macro in disk.h, so our assumptions are more visible. This hard coded limit does not prevent using larger disks, just grub won't read/write past the limit. The comment accompanying this restriction didn't quite make sense to me, so its been modified.

---
 grub-core/kern/disk_common.c | 13 +++++++------
 include/grub/disk.h          |  6 ++++++
 2 files changed, 13 insertions(+), 6 deletions(-)
grub-core/kern/disk_common.c +7 -6
index 5b92f670b..d20ed20d2 100644
@@ -32,13 +32,14 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
   /* Transform total_sectors to number of 512B blocks.  */
   total_sectors = grub_disk_from_native_sector (disk, disk->total_sectors);
 
-  /* Some drivers have problems with disks above reasonable.
-     Treat unknown as 1EiB disk. While on it, clamp the size to 1EiB.
-     Just one condition is enough since GRUB_DISK_UNKNOWN_SIZE << ls is always
-     above 9EiB.
+  /*
+     Some drivers have problems with disks above reasonable sizes.
+     Clamp the size to GRUB_DISK_MAX_SECTORS. Just one condition is enough
+     since GRUB_DISK_UNKNOWN_SIZE is always above GRUB_DISK_MAX_SECTORS,
+     assuming a maximum 4KiB sector size.
   */
-  if (total_sectors > (1ULL << 51))
-    total_sectors = (1ULL << 51);
+  if (total_sectors > GRUB_DISK_MAX_SECTORS)
+    total_sectors = GRUB_DISK_MAX_SECTORS;
 
   if ((total_sectors <= *sector
        || ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
include/grub/disk.h +6 -0
index 1a9e8fcf4..0bf08091f 100644
@@ -157,6 +157,12 @@ struct grub_disk_memberlist
 typedef struct grub_disk_memberlist *grub_disk_memberlist_t;
 #endif
 
+/*
+   Some drivers have problems with disks above reasonable sizes.
+   Set max disk size at 1EiB.
+*/
+#define GRUB_DISK_MAX_SECTORS	(1ULL << (60 - 9))
+
 /* The sector size.  */
 #define GRUB_DISK_SECTOR_SIZE	0x200
 #define GRUB_DISK_SECTOR_BITS	9
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/1 loopback: Do not automaticaly replace existing loopback dev, error instead

If there is a loopback device with the same name as the one to be created, instead of closing the old one and replacing it with the new one, return an error instead. If the loopback device was created, its probably being used by something and just replacing it may cause grub to loop forever. This fixes obvious problems like loopback d (d)/somefile'. Its not too onerous to force the user to delete the loopback first with the -d' switch.

---
 grub-core/disk/loopback.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
grub-core/disk/loopback.c +5 -10
index 0f58d8622..d77584855 100644
@@ -98,18 +98,13 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
   if (! file)
     return grub_errno;
 
-  /* First try to replace the old device.  */
+  /* Check that a device with requested name does not already exist.  */
   for (newdev = loopback_list; newdev; newdev = newdev->next)
     if (grub_strcmp (newdev->devname, args[0]) == 0)
-      break;
-
-  if (newdev)
-    {
-      grub_file_close (newdev->file);
-      newdev->file = file;
-
-      return 0;
-    }
+      {
+	ret = grub_error(GRUB_ERR_BAD_ARGUMENT, "device name already exists");
+	goto fail;
+      }
 
   /* Unable to replace it, make a new entry.  */
   newdev = grub_malloc (sizeof (struct grub_loopback));
Signature · 1 line
2.27.0
#4 lore raw
In reply to Glenn Washburn
Quoted 43 lines · Glenn Washburn

There is a hardcoded maximum disk size that can be read or written from, currently set at 1EiB in grub_disk_adjust_range. Move the literal into a macro in disk.h, so our assumptions are more visible. This hard coded limit does not prevent using larger disks, just grub won't read/write past the limit. The comment accompanying this restriction didn't quite make sense to me, so its been modified.

---
 grub-core/kern/disk_common.c | 13 +++++++------
 include/grub/disk.h          |  6 ++++++
 2 files changed, 13 insertions(+), 6 deletions(-)
grub-core/kern/disk_common.c +7 -6
index 5b92f670b..d20ed20d2 100644
@@ -32,13 +32,14 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
   /* Transform total_sectors to number of 512B blocks.  */
   total_sectors = grub_disk_from_native_sector (disk, disk->total_sectors);
 
-  /* Some drivers have problems with disks above reasonable.
-     Treat unknown as 1EiB disk. While on it, clamp the size to 1EiB.
-     Just one condition is enough since GRUB_DISK_UNKNOWN_SIZE << ls is always
-     above 9EiB.
+  /*
+     Some drivers have problems with disks above reasonable sizes.
+     Clamp the size to GRUB_DISK_MAX_SECTORS. Just one condition is enough
+     since GRUB_DISK_UNKNOWN_SIZE is always above GRUB_DISK_MAX_SECTORS,
+     assuming a maximum 4KiB sector size.
   */
-  if (total_sectors > (1ULL << 51))
-    total_sectors = (1ULL << 51);
+  if (total_sectors > GRUB_DISK_MAX_SECTORS)
+    total_sectors = GRUB_DISK_MAX_SECTORS;
 
   if ((total_sectors <= *sector
        || ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
include/grub/disk.h +0 -0
index 1a9e8fcf4..0bf08091f 100644

include/grub/disk.h struct grub_disk_memberlist · line 162

Quoted 6 lines
include/grub/disk.h +3 -0
@@ -157,6 +157,12 @@ struct grub_disk_memberlist
 typedef struct grub_disk_memberlist *grub_disk_memberlist_t;
 #endif
 
+/*
+   Some drivers have problems with disks above reasonable sizes.
+   Set max disk size at 1EiB.

The comment is formatted incorrectly [1].

include/grub/disk.h struct grub_disk_memberlist · line 168

Quoted 6 lines
include/grub/disk.h +3 -0
+*/
+#define GRUB_DISK_MAX_SECTORS	(1ULL << (60 - 9))
+
 /* The sector size.  */
 #define GRUB_DISK_SECTOR_SIZE	0x200
 #define GRUB_DISK_SECTOR_BITS	9

Please move the constant below these definitions and do this:
#define GRUB_DISK_MAX_SECTORS (1ULL << (60 - GRUB_DISK_SECTOR_BITS))

[1] https://www.gnu.org/software/grub/manual/grub-dev/grub-dev.html#Comments

#5 lore raw
Quoted 53 lines · On Mon, 30 Nov 2020 15:42:14 +0100 Daniel Kiper <[email protected]> wrote:
Quoted 52 lines · Glenn Washburn

There is a hardcoded maximum disk size that can be read or written from, currently set at 1EiB in grub_disk_adjust_range. Move the literal into a macro in disk.h, so our assumptions are more visible. This hard coded limit does not prevent using larger disks, just grub won't read/write past the limit. The comment accompanying this restriction didn't quite make sense to me, so its been modified.

---
 grub-core/kern/disk_common.c | 13 +++++++------
 include/grub/disk.h          |  6 ++++++
 2 files changed, 13 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/grub-core/kern/disk_common.c index 5b92f670b..d20ed20d2 100644

grub-core/kern/disk_common.c +0 -0
@@ -32,13 +32,14 @@ grub_disk_adjust_range (grub_disk_t disk,

grub_disk_addr_t *sector, /* Transform total_sectors to number of 512B blocks. */ total_sectors = grub_disk_from_native_sector (disk, disk->total_sectors);

grub-core/kern/disk_common.c +0 -2
-  /* Some drivers have problems with disks above reasonable.
-     Treat unknown as 1EiB disk. While on it, clamp the size to

1EiB.
- Just one condition is enough since GRUB_DISK_UNKNOWN_SIZE <<
ls is always

grub-core/kern/disk_common.c +3 -1
-     above 9EiB.
+  /*
+     Some drivers have problems with disks above reasonable sizes.
+     Clamp the size to GRUB_DISK_MAX_SECTORS. Just one condition

is enough
+ since GRUB_DISK_UNKNOWN_SIZE is always above
GRUB_DISK_MAX_SECTORS,

grub-core/kern/disk_common.c +3 -2
+     assuming a maximum 4KiB sector size.
   */
-  if (total_sectors > (1ULL << 51))
-    total_sectors = (1ULL << 51);
+  if (total_sectors > GRUB_DISK_MAX_SECTORS)
+    total_sectors = GRUB_DISK_MAX_SECTORS;
 
   if ((total_sectors <= *sector
        || ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
include/grub/disk.h +0 -0
index 1a9e8fcf4..0bf08091f 100644
@@ -157,6 +157,12 @@ struct grub_disk_memberlist
 typedef struct grub_disk_memberlist *grub_disk_memberlist_t;
 #endif
 
Quoted 5 lines

include/grub/disk.h struct grub_disk_memberlist · line 162

Quoted 3 lines
include/grub/disk.h +3 -0
+/*
+   Some drivers have problems with disks above reasonable sizes.
+   Set max disk size at 1EiB.

The comment is formatted incorrectly [1].

Yep, copy/paste from the comment changed in previous diff which had an incorrectly formatted comment and didn't catch it. Good catch. I'll fix the comment in the previous diff as well.

Quoted 10 lines

include/grub/disk.h struct grub_disk_memberlist · line 168

Quoted 6 lines
include/grub/disk.h +3 -0
+*/
+#define GRUB_DISK_MAX_SECTORS	(1ULL << (60 - 9))
+
 /* The sector size.  */
 #define GRUB_DISK_SECTOR_SIZE	0x200
 #define GRUB_DISK_SECTOR_BITS	9

Please move the constant below these definitions and do this:
#define GRUB_DISK_MAX_SECTORS (1ULL << (60 -
GRUB_DISK_SECTOR_BITS))

Great idea.

Quoted 2 lines

[1]
https://www.gnu.org/software/grub/manual/grub-dev/grub-dev.html#Comments

#6 lore raw

PATCH v2 1/1 disk: Move hardcoded max disk size literal to a GRUB_DISK_MAX_SECTORS in disk.h

In reply to Glenn Washburn

There is a hardcoded maximum disk size that can be read or written from, currently set at 1EiB in grub_disk_adjust_range. Move the literal into a macro in disk.h, so our assumptions are more visible. This hard coded limit does not prevent using larger disks, just grub won't read/write past the limit. The comment accompanying this restriction didn't quite make sense to me, so its been modified.

---
 grub-core/kern/disk_common.c | 15 ++++++++-------
 include/grub/disk.h          |  6 ++++++
 2 files changed, 14 insertions(+), 7 deletions(-)
grub-core/kern/disk_common.c +8 -7
index 2ca12b5f8..d43b927a4 100644
@@ -32,13 +32,14 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
   /* Transform total_sectors to number of 512B blocks.  */
   total_sectors = disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
 
-  /* Some drivers have problems with disks above reasonable.
-     Treat unknown as 1EiB disk. While on it, clamp the size to 1EiB.
-     Just one condition is enough since GRUB_DISK_UNKNOWN_SIZE << ls is always
-     above 9EiB.
-  */
-  if (total_sectors > (1ULL << 51))
-    total_sectors = (1ULL << 51);
+  /*
+   * Some drivers have problems with disks above reasonable sizes.
+   * Clamp the size to GRUB_DISK_MAX_SECTORS. Just one condition is enough
+   * since GRUB_DISK_UNKNOWN_SIZE is always above GRUB_DISK_MAX_SECTORS,
+   * assuming a maximum 4KiB sector size.
+   */
+  if (total_sectors > GRUB_DISK_MAX_SECTORS)
+    total_sectors = GRUB_DISK_MAX_SECTORS;
 
   if ((total_sectors <= *sector
        || ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
include/grub/disk.h +6 -0
index 132a1bb75..93f4ae226 100644
@@ -161,6 +161,12 @@ typedef struct grub_disk_memberlist *grub_disk_memberlist_t;
 #define GRUB_DISK_SECTOR_SIZE	0x200
 #define GRUB_DISK_SECTOR_BITS	9
 
+/*
+ * Some drivers have problems with disks above reasonable sizes.
+ * Set max disk size at 1EiB.
+ */
+#define GRUB_DISK_MAX_SECTORS	(1ULL << (60 - GRUB_DISK_MAX_SECTORS))
+
 /* The maximum number of disk caches.  */
 #define GRUB_DISK_CACHE_NUM	1021
 
Signature · 1 line
2.27.0
Reviewed-by on v2 1/1
#7 lore raw
Quoted 8 lines · Glenn Washburn

There is a hardcoded maximum disk size that can be read or written from, currently set at 1EiB in grub_disk_adjust_range. Move the literal into a macro in disk.h, so our assumptions are more visible. This hard coded limit does not prevent using larger disks, just grub won't read/write past the limit. The comment accompanying this restriction didn't quite make sense to me, so its been modified.

Except one nit...

Quoted 14 lines
---
 grub-core/kern/disk_common.c | 15 ++++++++-------
 include/grub/disk.h          |  6 ++++++
 2 files changed, 14 insertions(+), 7 deletions(-)
grub-core/kern/disk_common.c +0 -1
index 2ca12b5f8..d43b927a4 100644
@@ -32,13 +32,14 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
   /* Transform total_sectors to number of 512B blocks.  */
   total_sectors = disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
 
-  /* Some drivers have problems with disks above reasonable.

grub-core/kern/disk_common.c grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector, · line 38

Quoted 10 lines
grub-core/kern/disk_common.c +4 -6
-     Treat unknown as 1EiB disk. While on it, clamp the size to 1EiB.
-     Just one condition is enough since GRUB_DISK_UNKNOWN_SIZE << ls is always
-     above 9EiB.
-  */
-  if (total_sectors > (1ULL << 51))
-    total_sectors = (1ULL << 51);
+  /*
+   * Some drivers have problems with disks above reasonable sizes.
+   * Clamp the size to GRUB_DISK_MAX_SECTORS. Just one condition is enough
+   * since GRUB_DISK_UNKNOWN_SIZE is always above GRUB_DISK_MAX_SECTORS,

s/GRUB_DISK_UNKNOWN_SIZE/GRUB_DISK_SIZE_UNKNOWN/

I can fix it before committing the patch.

Daniel

#2 lore raw

Re: [PATCH] loopback: Do not automaticaly replace existing loopback dev, error instead

In reply to Glenn Washburn
Quoted 17 lines · Glenn Washburn

If there is a loopback device with the same name as the one to be created, instead of closing the old one and replacing it with the new one, return an error instead. If the loopback device was created, its probably being used by something and just replacing it may cause grub to loop forever. This fixes obvious problems like loopback d (d)/somefile'. Its not too onerous to force the user to delete the loopback first with the -d' switch.

---
 grub-core/disk/loopback.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
grub-core/disk/loopback.c +0 -0
index 0f58d8622..d77584855 100644

grub-core/disk/loopback.c grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args) · line 103

Quoted 7 lines
grub-core/disk/loopback.c +1 -1
@@ -98,18 +98,13 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
   if (! file)
     return grub_errno;
 
-  /* First try to replace the old device.  */
+  /* Check that a device with requested name does not already exist.  */
   for (newdev = loopback_list; newdev; newdev = newdev->next)
     if (grub_strcmp (newdev->devname, args[0]) == 0)

Could you move this check before grub_file_open() call? Then you do not need to open and close file for nothing.

Quoted 6 lines
grub-core/disk/loopback.c +0 -6
-      break;
-
-  if (newdev)
-    {
-      grub_file_close (newdev->file);
-      newdev->file = file;

grub-core/disk/loopback.c grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args) · line 110

Quoted 10 lines
grub-core/disk/loopback.c +4 -3
-
-      return 0;
-    }
+      {
+	ret = grub_error(GRUB_ERR_BAD_ARGUMENT, "device name already exists");
+	goto fail;
+      }
 
   /* Unable to replace it, make a new entry.  */
   newdev = grub_malloc (sizeof (struct grub_loopback));

Daniel

#8 lore raw

PATCH v2 1/1 loopback: Do not automaticaly replace existing loopback dev, error instead

In reply to Glenn Washburn

If there is a loopback device with the same name as the one to be created, instead of closing the old one and replacing it with the new one, return an error instead. If the loopback device was created, its probably being used by something and just replacing it may cause grub to crash unexpectedly. This fixes obvious problems like loopback d (d)/somefile'. Its not too onerous to force the user to delete the loopback first with the -d' switch.

---
 grub-core/disk/loopback.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
grub-core/disk/loopback.c +5 -13
index cdf9123fa..ef3a05fec 100644
@@ -92,24 +92,16 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
   if (argc < 2)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
 
+  /* Check that a device with requested name does not already exist.  */
+  for (newdev = loopback_list; newdev; newdev = newdev->next)
+    if (grub_strcmp (newdev->devname, args[0]) == 0)
+      return grub_error(GRUB_ERR_BAD_ARGUMENT, "device name already exists");
+
   file = grub_file_open (args[1], GRUB_FILE_TYPE_LOOPBACK
 			 | GRUB_FILE_TYPE_NO_DECOMPRESS);
   if (! file)
     return grub_errno;
 
-  /* First try to replace the old device.  */
-  for (newdev = loopback_list; newdev; newdev = newdev->next)
-    if (grub_strcmp (newdev->devname, args[0]) == 0)
-      break;
-
-  if (newdev)
-    {
-      grub_file_close (newdev->file);
-      newdev->file = file;
-
-      return 0;
-    }
-
   /* Unable to replace it, make a new entry.  */
   newdev = grub_malloc (sizeof (struct grub_loopback));
   if (! newdev)
Signature · 1 line
2.27.0
#3 lore raw

Re: [PATCH] loopback: Do not automaticaly replace existing loopback dev, error instead

In reply to Daniel Kiper
Quoted 22 lines · On Wed, 2 Dec 2020 15:36:06 +0100 Daniel Kiper <[email protected]> wrote:
Quoted 21 lines · Glenn Washburn

If there is a loopback device with the same name as the one to be created, instead of closing the old one and replacing it with the new one, return an error instead. If the loopback device was created, its probably being used by something and just replacing it may cause grub to loop forever. This fixes obvious problems like loopback d (d)/somefile'. Its not too onerous to force the user to delete the loopback first with the -d' switch.

---
 grub-core/disk/loopback.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
grub-core/disk/loopback.c +0 -0
index 0f58d8622..d77584855 100644
@@ -98,18 +98,13 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt,
 int argc, char **args) if (! file)
     return grub_errno;
 
Quoted 7 lines
Quoted 4 lines
grub-core/disk/loopback.c +1 -1
-  /* First try to replace the old device.  */
+  /* Check that a device with requested name does not already

exist. */ for (newdev = loopback_list; newdev; newdev = newdev->next) if (grub_strcmp (newdev->devname, args[0]) == 0)

Could you move this check before grub_file_open() call? Then you do not need to open and close file for nothing.

Good idea.

Quoted 15 lines
Quoted 15 lines
grub-core/disk/loopback.c +2 -9
-      break;
-
-  if (newdev)
-    {
-      grub_file_close (newdev->file);
-      newdev->file = file;
-
-      return 0;
-    }
+      {
+	ret = grub_error(GRUB_ERR_BAD_ARGUMENT, "device name

already exists");

grub-core/disk/loopback.c +2 -0
+	goto fail;
+      }
Quoted 4 lines
Quoted 2 lines
   /* Unable to replace it, make a new entry.  */
   newdev = grub_malloc (sizeof (struct grub_loopback));

Daniel

Glenn

Reviewed-by on v2 1/1
#9 lore raw

Re: [PATCH v2] loopback: Do not automaticaly replace existing loopback dev, error instead

In reply to Glenn Washburn
Quoted 8 lines · Glenn Washburn

If there is a loopback device with the same name as the one to be created, instead of closing the old one and replacing it with the new one, return an error instead. If the loopback device was created, its probably being used by something and just replacing it may cause grub to crash unexpectedly. This fixes obvious problems like loopback d (d)/somefile'. Its not too onerous to force the user to delete the loopback first with the -d' switch.

Daniel

PS May I ask you to create new thread for new version of the patches
instead of attaching them to previous threads?

#10 lore raw

Re: [PATCH v2] loopback: Do not automaticaly replace existing loopback dev, error instead

Quoted 9 lines · On Fri, 4 Dec 2020 13:34:44 +0100 Daniel Kiper <[email protected]> wrote:
Quoted 8 lines · Glenn Washburn

If there is a loopback device with the same name as the one to be created, instead of closing the old one and replacing it with the new one, return an error instead. If the loopback device was created, its probably being used by something and just replacing it may cause grub to crash unexpectedly. This fixes obvious problems like loopback d (d)/somefile'. Its not too onerous to force the user to delete the loopback first with the -d' switch.

Quoted 8 lines
Quoted 1 line

Daniel

PS May I ask you to create new thread for new version of the patches
instead of attaching them to previous threads?

These two patches were not meant to be a thread together, ie separate patches, which was why I was treating them separately. I can see how that might be confusing now.

Glenn

#11 lore raw

Re: [PATCH v2] loopback: Do not automaticaly replace existing loopback dev, error instead

Quoted 16 lines · Glenn Washburn
Quoted 13 lines · On Fri, 4 Dec 2020 13:34:44 +0100 Daniel Kiper <[email protected]> wrote:
Quoted 9 lines · Glenn Washburn

If there is a loopback device with the same name as the one to be created, instead of closing the old one and replacing it with the new one, return an error instead. If the loopback device was created, its probably being used by something and just replacing it may cause grub to crash unexpectedly. This fixes obvious problems like loopback d (d)/somefile'. Its not too onerous to force the user to delete the loopback first with the -d' switch.

Quoted 8 lines
Quoted 4 lines

Daniel

PS May I ask you to create new thread for new version of the patches
instead of attaching them to previous threads?

These two patches were not meant to be a thread together, ie separate patches, which was why I was treating them separately. I can see how that might be confusing now.

I was also referring to the LUKS2 patches, sorry if I was not precise, which are always connected to the first thread created. This is confusing too. Could you create separate thread for each version of patchset in the future?

Daniel

#12 lore raw

Re: [PATCH v2] loopback: Do not automaticaly replace existing loopback dev, error instead

Quoted 23 lines · On Thu, 10 Dec 2020 17:55:20 +0100 Daniel Kiper <[email protected]> wrote:
Quoted 22 lines · Glenn Washburn
Quoted 18 lines · On Fri, 4 Dec 2020 13:34:44 +0100 Daniel Kiper <[email protected]> wrote:
Quoted 10 lines · Glenn Washburn

If there is a loopback device with the same name as the one to be created, instead of closing the old one and replacing it with the new one, return an error instead. If the loopback device was created, its probably being used by something and just replacing it may cause grub to crash unexpectedly. This fixes obvious problems like loopback d (d)/somefile'. Its not too onerous to force the user to delete the loopback first with the -d' switch.

Daniel

PS May I ask you to create new thread for new version of the patches instead of attaching them to previous threads?

Quoted 8 lines
Quoted 3 lines

These two patches were not meant to be a thread together, ie separate patches, which was why I was treating them separately. I can see how that might be confusing now.

I was also referring to the LUKS2 patches, sorry if I was not precise, which are always connected to the first thread created. This is confusing too. Could you create separate thread for each version of patchset in the future?

I was keeping them together because that was its easy to find the comments from the previous version of the patch series to make sure things weren't forgotten. Honestly, with more experience with submitting patches this way, what I like best is to always send a new version of a patch series in reply to the very first cover letter, so each new version of a series is at the same thread depth. In my viewer, I can collapse the thread to the patch series version when I don't need to see anything in that version and the versions are ordered in alphabetical order. I only started doing this with the LUKS patches after v4, so its still confusing because there's a thread depth of 6 or so before each version is at the same thread depth. Perhaps, its not a big deal to have versions of patch series connected with previous versions. I'll create a new thread for the next LUKS patch series. On further series, I may consistently use the above method (unlike the current LUKS thread) and you can tell me if you still don't like it.

Glenn