From: David Teigland <teigland@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - devices: don't use deleted loop backing file for device id
Date: Tue, 8 Jun 2021 17:18:10 +0000 (GMT) [thread overview]
Message-ID: <20210608171810.CD3153853828@sourceware.org> (raw)
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ca930bd936de2e7d4a83fa64add800baf6cfd116
Commit: ca930bd936de2e7d4a83fa64add800baf6cfd116
Parent: 5e17203ff5dd4296760e5dad683e4cc84df2801d
Author: David Teigland <teigland@redhat.com>
AuthorDate: Tue Jun 8 12:16:06 2021 -0500
Committer: David Teigland <teigland@redhat.com>
CommitterDate: Tue Jun 8 12:16:06 2021 -0500
devices: don't use deleted loop backing file for device id
check for "(deleted)" in the backing_file string and
fall back to devname for id.
$ cat /sys/block/loop0/loop/backing_file
/root/looptmp (deleted)
---
lib/device/device_id.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 67f72e51b..1b98487ab 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -325,8 +325,12 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
else if (idtype == DEV_ID_TYPE_MD_UUID)
_read_sys_block(cmd, dev, "md/uuid", sysbuf, sizeof(sysbuf));
- else if (idtype == DEV_ID_TYPE_LOOP_FILE)
+ else if (idtype == DEV_ID_TYPE_LOOP_FILE) {
_read_sys_block(cmd, dev, "loop/backing_file", sysbuf, sizeof(sysbuf));
+ /* if backing file is deleted, fall back to devname */
+ if (strstr(sysbuf, "(deleted)"))
+ sysbuf[0] = '\0';
+ }
else if (idtype == DEV_ID_TYPE_DEVNAME) {
if (!(idname = strdup(dev_name(dev))))
reply other threads:[~2021-06-08 17:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210608171810.CD3153853828@sourceware.org \
--to=teigland@sourceware.org \
--cc=lvm-devel@redhat.com \
/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.