btrfs-progs: prop: allow autodetect_object_types() to handle link

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>
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Goffredo Baroncelli 2022-01-05 21:45:52 +01:00 committed by David Sterba
parent 79ef78f0e4
commit 817483211a

View file

@ -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;