From 4d7ea19ca0eddcc9ea8c46788cf60701cb9c4bbc Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 14 Nov 2023 15:48:00 +0100 Subject: [PATCH] btrfs-progs: property set: skip opening char devices completely Previous fix for char devices and properties opens the path in non blocking mode but this still triggers the watchdog, as reported. Add a workaround to properties to completely skip opening the path and just stat() it. Issue: #699 Signed-off-by: David Sterba --- cmds/property.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmds/property.c b/cmds/property.c index ba8f56a8..be9bdf63 100644 --- a/cmds/property.c +++ b/cmds/property.c @@ -286,6 +286,19 @@ static int check_btrfs_object(const char *object) { int ret; u8 fsid[BTRFS_FSID_SIZE]; + struct stat st; + + ret = stat(object, &st); + if (ret < 0) + return 0; + + /* + * Don't try to read fsid on char devices, this will fail anyway. In + * some cases opening the device can trigger some system events (like a + * watchdog) so do only stat. + */ + if ((st.st_mode & S_IFMT) == S_IFCHR || (st.st_mode & S_IFMT) == S_IFIFO) + return 0; ret = get_fsid(object, fsid, 0); if (ret < 0)