From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org, Daniel Kiper <daniel.kiper@oracle.com>
Cc: Glenn Washburn <development@efficientek.com>
Subject: [PATCH] fs: Allow number of blocks in block list to be optional, defaulting length to device length
Date: Sun, 21 Mar 2021 13:09:10 -0500 [thread overview]
Message-ID: <20210321180910.1828890-1-development@efficientek.com> (raw)
This is primarily useful to do something like "loopback newdev (dev)8+" to
create a device that skips the first 4K, which may contain a container
header, eg. a non-standard RAID1 header, that grub does not recognize. This
would allow that container data to be potentially accessed up to the end of
container, which may be necessary for some layouts that store data at the
end. There is currently not a good way to programmatically get the number
of sectors on a disk to set the appropriate length of the blocklist.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
docs/grub.texi | 10 ++++++----
grub-core/kern/fs.c | 6 +++++-
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/docs/grub.texi b/docs/grub.texi
index eeb3118eb..b1abb6c6a 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -3036,16 +3036,18 @@ snapshot name is omitted.
A block list is used for specifying a file that doesn't appear in the
filesystem, like a chainloader. The syntax is
-@code{[@var{offset}]+@var{length}[,[@var{offset}]+@var{length}]@dots{}}.
+@code{[@var{offset}]+[@var{length}][,[@var{offset}]+[@var{length}]]@dots{}}.
Here is an example:
@example
-@code{0+100,200+1,300+300}
+@code{0+100,200+1,300+300,800+}
@end example
This represents that GRUB should read blocks 0 through 99, block 200,
-and blocks 300 through 599. If you omit an offset, then GRUB assumes
-the offset is zero.
+blocks 300 through 599, and blocks 800 until the end of the device.
+If you omit an offset, then GRUB assumes the offset is zero. If the
+length is omitted, then GRUB assumes the block list extends until the
+end of the device.
Like the file name syntax (@pxref{File name syntax}), if a blocklist
does not contain a device name, then GRUB uses GRUB's @dfn{root
diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c
index c698295bc..e0d7e16a2 100644
--- a/grub-core/kern/fs.c
+++ b/grub-core/kern/fs.c
@@ -173,7 +173,11 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
}
p++;
- blocks[i].length = grub_strtoul (p, &p, 0);
+ if (*p == '\0' || *p == ',')
+ blocks[i].length = max_sectors - blocks[i].offset;
+ else
+ blocks[i].length = grub_strtoul (p, &p, 0);
+
if (grub_errno != GRUB_ERR_NONE
|| blocks[i].length == 0
|| (*p && *p != ',' && ! grub_isspace (*p)))
--
2.27.0
next reply other threads:[~2021-03-21 18:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-21 18:09 Glenn Washburn [this message]
2021-09-01 12:28 ` [PATCH] fs: Allow number of blocks in block list to be optional, defaulting length to device length Daniel Kiper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210321180910.1828890-1-development@efficientek.com \
--to=development@efficientek.com \
--cc=daniel.kiper@oracle.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.