From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lO2W4-0004aX-Nw for mharc-grub-devel@gnu.org; Sun, 21 Mar 2021 14:09:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lO2W2-0004aI-Cc for grub-devel@gnu.org; Sun, 21 Mar 2021 14:09:30 -0400 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:33515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lO2Vy-00037E-J1 for grub-devel@gnu.org; Sun, 21 Mar 2021 14:09:29 -0400 Received: by mail-ot1-x331.google.com with SMTP id o19-20020a9d22130000b02901bfa5b79e18so13735087ota.0 for ; Sun, 21 Mar 2021 11:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gsNAoOhPVsF+wr8UMPSXeeVLeLBB1cBArd8ru/cV8zY=; b=wwr55KESWbWOAjrQNDy77b3cMOGnNFaQRly+iTJpGKaKsNPh8Sqiq0YBI0rwTSmtX2 +mBWrdtgychUG/zJPAQNYl5FCihlugzhPgnZ56GBKDsJKSkICbjOekoPmfBdjRPo1JcA fYWciyX1x3b5+UXwJ9hswO5EFqOJKkLICXrPZadHOx1h+b9DoNlrCgMWRvdLcODOHxhF tzuFMydfz6aq1RjCZy0HIJvZXejd3HYJvX2cY9nPUq3ylZoN0C/LsA4DESjt63hEYvoH 2hBHYSNTErfSqN7gSppHLuuaYUnYTnXyo8QiuYRsKcSIbWFYYq+I9aC3nJ0zUFyuKr0H j6HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gsNAoOhPVsF+wr8UMPSXeeVLeLBB1cBArd8ru/cV8zY=; b=fwNXT2qMzeT4qq9GDVqctiaItCwyWYdd0dRxSgx8Y3cVqMyVqLD91KRy+MGm9rHQ9+ ZWWJjAGitBb1DYWuWCsSSCqzWO4g01kyNjPgvftdFmeKQiGM1CZvSpil5TEtJBQoTvER MuMzeiu1tdshKVepBjbUK9dF9ltOi5kGcE6zizuOzxNYbY2iz2BNgEMHnIOUd6x4nutZ HfSTPBfLfcxgzsfTl/QNatqFTsMpjeKDsli/A0auQxGHCok+uMtBt6DR7RfIf26EBC15 G2/pO3FCvbjdewIK+ZYTRtk43qDL5GtPkGtHBHSrfSEyYr1jrqzDVHhXWb8ZhntHFFHi OQng== X-Gm-Message-State: AOAM530q04c7uzmWKiQqdLFrxEpqRPaXTe5WKOE3Xnt5wATuW62Lc6VQ JdV8MjRLNn1ISFmzF5Fd4luIIn+tH3ethA== X-Google-Smtp-Source: ABdhPJycZYX0His2ycphjT/dvE7aK/4OLdLQkjP7e09Xp0p6Ci0F0/f+ZzNtnToAJiLRlbLpz4fucQ== X-Received: by 2002:a05:6830:1bed:: with SMTP id k13mr8320489otb.265.1616350164265; Sun, 21 Mar 2021 11:09:24 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ab16:db00:23af:6780:efd4:8e25]) by smtp.gmail.com with ESMTPSA id t2sm2572769ool.18.2021.03.21.11.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 11:09:23 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn 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 Message-Id: <20210321180910.1828890-1-development@efficientek.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::331; envelope-from=development@efficientek.com; helo=mail-ot1-x331.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Mar 2021 18:09:30 -0000 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 --- 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