mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-23 14:45:19 +00:00
btrfs-progs: use get_sysfs_proto_supported() in get_sysfs_proto_supported()
Use the sysfs helper to read u64 value of send stream. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
22495fc8fd
commit
9da7e92af9
17
cmds/send.c
17
cmds/send.c
@ -438,25 +438,18 @@ static void free_send_info(struct btrfs_send *sctx)
|
||||
|
||||
static u32 get_sysfs_proto_supported(void)
|
||||
{
|
||||
int fd;
|
||||
int ret;
|
||||
char buf[32] = {};
|
||||
char *end = NULL;
|
||||
u64 version;
|
||||
|
||||
fd = sysfs_open_file("features/send_stream_version");
|
||||
if (fd < 0) {
|
||||
ret = sysfs_read_file_u64("features/send_stream_version", &version);
|
||||
if (ret < 0) {
|
||||
/*
|
||||
* No file is either no version support or old kernel with just
|
||||
* v1.
|
||||
* No file or error is either no version support or old kernel
|
||||
* with just v1.
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
ret = sysfs_read_file(fd, buf, sizeof(buf));
|
||||
close(fd);
|
||||
if (ret <= 0)
|
||||
return 1;
|
||||
version = strtoull(buf, &end, 10);
|
||||
|
||||
if (version == ULLONG_MAX && errno == ERANGE)
|
||||
return 1;
|
||||
if (version > U32_MAX) {
|
||||
|
Loading…
Reference in New Issue
Block a user