Commit Graph

5 Commits

Author SHA1 Message Date
David Sterba 87dba20daf btrfs-progs: change all sysfs helpers to return errno
To be consistent with the rest of the code the sysfs helper should
return the -errno instead of passing -1 from various syscalls. Update
callers that relied on -1 as the invalid file descriptor.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-12-09 01:17:22 +01:00
David Sterba 4576029dfd btrfs-progs: add write helpers for sysfs files
Add convenience wrappers for writing a buffer or u64 to toplevel or FSID
file in sysfs.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-12-09 01:17:22 +01:00
David Sterba a0468efe86 btrfs-progs: reset errno before strtoull()
strtoull may return the boundary values, if the callers could expect
that and verify it then the errno must be reset before the call.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-12-01 02:13:37 +01:00
David Sterba 5aa2ea7db0 btrfs-progs: add more helpers to read values from sysfs
In some places we want to read a single u64 value from a sysfs path, or
from fsid directory. Add helpers that do that in one go.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-28 17:24:24 +02:00
David Sterba 4a96a935ad btrfs-progs: move sysfs related helpers to own file
The sysfs could use more convenience helpers so move the current code to
own file before adding more helpers.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-28 17:24:24 +02:00