]> git.hungrycats.org Git - btrfs-progs/commitdiff
btrfs-progs: don't reuse filesystem fd for sysfs files
authorDavid Sterba <dsterba@suse.com>
Wed, 22 Jul 2026 11:32:01 +0000 (13:32 +0200)
committerQu Wenruo <wqu@suse.com>
Mon, 3 Aug 2026 00:44:50 +0000 (10:14 +0930)
Sysfs helpers reuse the input file descriptor of the filesystem for the
sysfs files, as this is one time read. For clarity use two variables for
that.

Signed-off-by: David Sterba <dsterba@suse.com>
common/sysfs-utils.c

index 4caa94c45e8ce93e731ccdcf3798b125aff02db5..e32ef077d0d7f4d1a44591996ddde9c2bd133947 100644 (file)
@@ -168,12 +168,12 @@ int sysfs_write_file_u64(const char *name, u64 value)
        return ret;
 }
 
-int sysfs_read_fsid_file_u64(int fd, const char *name, u64 *value)
+int sysfs_read_fsid_file_u64(int fs_fd, const char *name, u64 *value)
 {
-       int ret;
+       int ret, fd;
        char str[32] = { 0 };
 
-       fd = sysfs_open_fsid_file(fd, name);
+       fd = sysfs_open_fsid_file(fs_fd, name);
        if (fd < 0)
                return fd;
 
@@ -189,12 +189,12 @@ out:
        return ret;
 }
 
-int sysfs_write_fsid_file_u64(int fd, const char *name, u64 value)
+int sysfs_write_fsid_file_u64(int fs_fd, const char *name, u64 value)
 {
-       int ret;
+       int ret, fd;
        char str[32] = { 0 };
 
-       fd = sysfs_open_fsid_file_rw(fd, name);
+       fd = sysfs_open_fsid_file_rw(fs_fd, name);
        if (fd < 0)
                return fd;
 
@@ -204,12 +204,12 @@ int sysfs_write_fsid_file_u64(int fd, const char *name, u64 value)
        return ret;
 }
 
-int sysfs_read_fsid_file_clean_str(int fd, const char *name, char *buf, size_t size)
+int sysfs_read_fsid_file_clean_str(int fs_fd, const char *name, char *buf, size_t size)
 {
-       int ret;
+       int ret, fd;
        size_t end;
 
-       fd = sysfs_open_fsid_file(fd, name);
+       fd = sysfs_open_fsid_file(fs_fd, name);
        if (fd < 0)
                return fd;