All of lore.kernel.org
 help / color / mirror / Atom feed
From: Goffredo Baroncelli <kreijack@tiscali.it>
To: linux-btrfs@vger.kernel.org
Cc: Boris Burkov <boris@bur.io>, Goffredo Baroncelli <kreijack@inwind.it>
Subject: [PATCH][V2] btrfs-progs: allow autodetect_object_types() to handle link.
Date: Wed,  5 Jan 2022 21:45:52 +0100	[thread overview]
Message-ID: <da4a4e0cf18df259e63c19872093bf12635da576.1641415488.git.kreijack@inwind.it> (raw)

From: Goffredo Baroncelli <kreijack@inwind.it>

The function autodetect_object_types() tries to detect the type of
btrfs object passed. If it is an "inode" type (e.g. file) this function
returns the type as "inode". If it is a block device, it return it as
"block device".
However it doesn't handle the case where the object passed is a link
to a block device (which could be a valid btrfs device). For example
LVM/DM creates link to block devices. In this case it should return
the type as "block device".

This patch replace the lstat() call with a stat().

Reported-by: Boris Burkov <boris@bur.io>
Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
---
 cmds/property.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmds/property.c b/cmds/property.c
index 59ef997c..b3ccc0ff 100644
--- a/cmds/property.c
+++ b/cmds/property.c
@@ -373,7 +373,7 @@ static int autodetect_object_types(const char *object, int *types_out)
 
 	is_btrfs_object = check_btrfs_object(object);
 
-	ret = lstat(object, &st);
+	ret = stat(object, &st);
 	if (ret < 0) {
 		ret = -errno;
 		goto out;
-- 
2.34.1


             reply	other threads:[~2022-01-05 20:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05 20:45 Goffredo Baroncelli [this message]
2022-01-05 20:48 ` [PATCH][V2] btrfs-progs: allow autodetect_object_types() to handle link Boris Burkov
2022-01-06 14:49 ` David Sterba

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=da4a4e0cf18df259e63c19872093bf12635da576.1641415488.git.kreijack@inwind.it \
    --to=kreijack@tiscali.it \
    --cc=boris@bur.io \
    --cc=kreijack@inwind.it \
    --cc=kreijack@libero.it \
    --cc=linux-btrfs@vger.kernel.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.