Skip to content

Commit 4ba164d

Browse files
committed
btrfs-progs: use new libbtrfsutil API in internal code
The unified naming API of libbtrfsutil is exported in the library, we should use it in the internal code as well. In the future the old naming scheme will be deprecated and remove. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent ecf62d9 commit 4ba164d

File tree

14 files changed

+190
-208
lines changed

14 files changed

+190
-208
lines changed

cmds/filesystem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ static int cmd_filesystem_sync(const struct cmd_struct *cmd,
934934
if (check_argc_exact(argc - optind, 1))
935935
return 1;
936936

937-
err = btrfs_util_sync(argv[optind]);
937+
err = btrfs_util_fs_sync(argv[optind]);
938938
if (err) {
939939
error_btrfs_util(err);
940940
return 1;

cmds/property.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static int prop_read_only(enum prop_object_type type,
9090
error("invalid value for property: %s", value);
9191
return -EINVAL;
9292
}
93-
err = btrfs_util_get_subvolume_read_only(object, &is_ro);
93+
err = btrfs_util_subvolume_get_read_only(object, &is_ro);
9494
if (err) {
9595
error_btrfs_util(err);
9696
return -errno;
@@ -99,7 +99,7 @@ static int prop_read_only(enum prop_object_type type,
9999
if (is_ro && read_only)
100100
return 0;
101101

102-
err = btrfs_util_subvolume_info(object, 0, &info);
102+
err = btrfs_util_subvolume_get_info(object, 0, &info);
103103
if (err)
104104
warning("cannot read subvolume info");
105105
if (is_ro && !uuid_is_null(info.received_uuid)) {
@@ -118,7 +118,7 @@ static int prop_read_only(enum prop_object_type type,
118118
if (!is_ro && !uuid_is_null(info.received_uuid))
119119
warning("read-write subvolume with received_uuid, this is bad");
120120

121-
err = btrfs_util_set_subvolume_read_only(object, read_only);
121+
err = btrfs_util_subvolume_set_read_only(object, read_only);
122122
if (err) {
123123
error_btrfs_util(err);
124124
return -errno;
@@ -135,7 +135,7 @@ static int prop_read_only(enum prop_object_type type,
135135
warning("failed to clear received_uuid: %m");
136136
}
137137
} else {
138-
err = btrfs_util_get_subvolume_read_only(object, &read_only);
138+
err = btrfs_util_subvolume_get_read_only(object, &read_only);
139139
if (err) {
140140
error_btrfs_util(err);
141141
return -errno;

cmds/qgroup.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ static struct btrfs_qgroup *get_or_add_qgroup(int fd,
835835
enum btrfs_util_error uret;
836836
char *path;
837837

838-
uret = btrfs_util_subvolume_path_fd(fd, qgroupid, &path);
838+
uret = btrfs_util_subvolume_get_path_fd(fd, qgroupid, &path);
839839
if (uret == BTRFS_UTIL_OK)
840840
bq->path = path;
841841
else if (uret != BTRFS_UTIL_ERROR_SUBVOLUME_NOT_FOUND) {
@@ -852,7 +852,7 @@ static struct btrfs_qgroup *get_or_add_qgroup(int fd,
852852
* Passing @subvol as NULL will force the search to only search
853853
* for the ROOT_ITEM.
854854
*/
855-
uret = btrfs_util_subvolume_info_fd(fd, qgroupid, NULL);
855+
uret = btrfs_util_subvolume_get_info_fd(fd, qgroupid, NULL);
856856
if (uret == BTRFS_UTIL_OK) {
857857
bq->stale = false;
858858
} else if (uret == BTRFS_UTIL_ERROR_SUBVOLUME_NOT_FOUND) {
@@ -2044,7 +2044,7 @@ static int cmd_qgroup_show(const struct cmd_struct *cmd, int argc, char **argv)
20442044
}
20452045

20462046
if (sync) {
2047-
err = btrfs_util_sync_fd(fd);
2047+
err = btrfs_util_fs_sync_fd(fd);
20482048
if (err)
20492049
warning("sync ioctl failed on '%s': %m", path);
20502050
}
@@ -2136,7 +2136,7 @@ static int cmd_qgroup_limit(const struct cmd_struct *cmd, int argc, char **argv)
21362136
if (argc - optind == 2) {
21372137
args.qgroupid = 0;
21382138
path = argv[optind + 1];
2139-
err = btrfs_util_is_subvolume(path);
2139+
err = btrfs_util_subvolume_is_valid(path);
21402140
if (err) {
21412141
error_btrfs_util(err);
21422142
return 1;
@@ -2270,7 +2270,7 @@ static int cmd_qgroup_clear_stale(const struct cmd_struct *cmd, int argc, char *
22702270
}
22712271

22722272
/* Sync the fs so that the qgroup numbers are uptodate. */
2273-
err = btrfs_util_sync_fd(fd);
2273+
err = btrfs_util_fs_sync_fd(fd);
22742274
if (err)
22752275
warning("syncing filesystem failed: %m");
22762276

cmds/subvolume.c

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static int wait_for_subvolume_cleaning(int fd, size_t count, uint64_t *ids,
9292
for (i = 0; i < count; i++) {
9393
if (!ids[i])
9494
continue;
95-
err = btrfs_util_subvolume_info_fd(fd, ids[i], NULL);
95+
err = btrfs_util_subvolume_get_info_fd(fd, ids[i], NULL);
9696
if (err == BTRFS_UTIL_ERROR_SUBVOLUME_NOT_FOUND) {
9797
done++;
9898
pr_verbose(LOG_DEFAULT, "Subvolume id %" PRIu64 " is gone (%zu/%zu)\n",
@@ -306,11 +306,11 @@ static int wait_for_commit(int fd)
306306
enum btrfs_util_error err;
307307
uint64_t transid;
308308

309-
err = btrfs_util_start_sync_fd(fd, &transid);
309+
err = btrfs_util_fs_start_sync_fd(fd, &transid);
310310
if (err)
311311
return -1;
312312

313-
err = btrfs_util_wait_sync_fd(fd, transid);
313+
err = btrfs_util_fs_wait_sync_fd(fd, transid);
314314
if (err)
315315
return -1;
316316

@@ -424,7 +424,7 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
424424
char *subvol;
425425

426426
path = argv[cnt];
427-
err = btrfs_util_subvolume_path(path, subvolid, &subvol);
427+
err = btrfs_util_subvolume_get_path(path, subvolid, &subvol);
428428
/*
429429
* If the subvolume is really not referred by anyone, and refs
430430
* is 0, newer kernel can handle it by just adding an orphan
@@ -451,7 +451,7 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
451451
again:
452452
path = argv[cnt];
453453

454-
err = btrfs_util_is_subvolume(path);
454+
err = btrfs_util_subvolume_is_valid(path);
455455
if (err) {
456456
error_btrfs_util(err);
457457
ret = 1;
@@ -481,7 +481,7 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
481481
}
482482

483483
default_subvol_id = 0;
484-
err = btrfs_util_get_default_subvolume_fd(fd, &default_subvol_id);
484+
err = btrfs_util_subvolume_get_default_fd(fd, &default_subvol_id);
485485
if (err == BTRFS_UTIL_ERROR_SEARCH_FAILED) {
486486
if (geteuid() != 0)
487487
warning("cannot read default subvolume id: %m");
@@ -490,7 +490,7 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
490490
if (subvolid > 0) {
491491
target_subvol_id = subvolid;
492492
} else {
493-
err = btrfs_util_subvolume_id(path, &target_subvol_id);
493+
err = btrfs_util_subvolume_get_id(path, &target_subvol_id);
494494
if (err) {
495495
ret = 1;
496496
goto out;
@@ -530,7 +530,7 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
530530
if (err != BTRFS_UTIL_ERROR_STOP_ITERATION)
531531
warning("failed to iterate subvolumes, nested subvolumes will not be printed: %s", btrfs_util_strerror(err));
532532

533-
btrfs_util_destroy_subvolume_iterator(iter);
533+
btrfs_util_subvolume_iter_destroy(iter);
534534
} else {
535535
warning("failed to create subvolume iterator, nested subvolumes will not be printed: %s", btrfs_util_strerror(err));
536536
}
@@ -554,9 +554,9 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
554554

555555
/* Start deleting. */
556556
if (subvolid == 0)
557-
err = btrfs_util_delete_subvolume_fd(fd, vname, flags);
557+
err = btrfs_util_subvolume_delete_fd(fd, vname, flags);
558558
else
559-
err = btrfs_util_delete_subvolume_by_id_fd(fd, subvolid);
559+
err = btrfs_util_subvolume_delete_by_id_fd(fd, subvolid);
560560
if (err) {
561561
int saved_errno = errno;
562562

@@ -700,7 +700,7 @@ static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char *
700700
dst = argv[optind + 1];
701701

702702
retval = 1; /* failure */
703-
err = btrfs_util_is_subvolume(subvol);
703+
err = btrfs_util_subvolume_is_valid(subvol);
704704
if (err) {
705705
error_btrfs_util(err);
706706
goto out;
@@ -795,7 +795,7 @@ static int cmd_subvolume_get_default(const struct cmd_struct *cmd, int argc, cha
795795
if (fd < 0)
796796
return 1;
797797

798-
err = btrfs_util_get_default_subvolume_fd(fd, &default_id);
798+
err = btrfs_util_subvolume_get_default_fd(fd, &default_id);
799799
if (err) {
800800
error_btrfs_util(err);
801801
goto out;
@@ -815,13 +815,13 @@ static int cmd_subvolume_get_default(const struct cmd_struct *cmd, int argc, cha
815815
goto out;
816816
}
817817

818-
err = btrfs_util_subvolume_info_fd(fd, default_id, &subvol);
818+
err = btrfs_util_subvolume_get_info_fd(fd, default_id, &subvol);
819819
if (err) {
820820
error_btrfs_util(err);
821821
goto out;
822822
}
823823

824-
err = btrfs_util_subvolume_path_fd(fd, default_id, &path);
824+
err = btrfs_util_subvolume_get_path_fd(fd, default_id, &path);
825825
if (err) {
826826
error_btrfs_util(err);
827827
goto out;
@@ -890,7 +890,7 @@ static int cmd_subvolume_set_default(const struct cmd_struct *cmd, int argc, cha
890890
path = argv[optind + 1];
891891
}
892892

893-
err = btrfs_util_set_default_subvolume(path, objectid);
893+
err = btrfs_util_subvolume_set_default(path, objectid);
894894
if (err) {
895895
error_btrfs_util(err);
896896
return 1;
@@ -1327,7 +1327,7 @@ static int cmd_subvolume_find_new(const struct cmd_struct *cmd, int argc, char *
13271327
subvol = argv[optind];
13281328
last_gen = arg_strtou64(argv[optind + 1]);
13291329

1330-
err = btrfs_util_is_subvolume(subvol);
1330+
err = btrfs_util_subvolume_is_valid(subvol);
13311331
if (err) {
13321332
error_btrfs_util(err);
13331333
return 1;
@@ -1337,7 +1337,7 @@ static int cmd_subvolume_find_new(const struct cmd_struct *cmd, int argc, char *
13371337
if (fd < 0)
13381338
return 1;
13391339

1340-
err = btrfs_util_sync_fd(fd);
1340+
err = btrfs_util_fs_sync_fd(fd);
13411341
if (err) {
13421342
error_btrfs_util(err);
13431343
close(fd);
@@ -1583,27 +1583,24 @@ static int cmd_subvolume_show(const struct cmd_struct *cmd, int argc, char **arg
15831583
}
15841584

15851585
if (by_uuid) {
1586-
err = btrfs_util_create_subvolume_iterator_fd(fd,
1587-
BTRFS_FS_TREE_OBJECTID,
1588-
0, &iter);
1586+
err = btrfs_util_subvolume_iter_create_fd(fd, BTRFS_FS_TREE_OBJECTID,
1587+
0, &iter);
15891588
if (err) {
15901589
error_btrfs_util(err);
15911590
goto out;
15921591
}
15931592

15941593
for (;;) {
1595-
err = btrfs_util_subvolume_iterator_next_info(iter,
1596-
&subvol_path,
1597-
&subvol);
1594+
err = btrfs_util_subvolume_iter_next_info(iter, &subvol_path, &subvol);
15981595
if (err == BTRFS_UTIL_ERROR_STOP_ITERATION) {
15991596
uuid_unparse(uuid_arg, uuidparse);
16001597
error("can't find uuid '%s' on '%s'", uuidparse,
16011598
fullpath);
1602-
btrfs_util_destroy_subvolume_iterator(iter);
1599+
btrfs_util_subvolume_iter_destroy(iter);
16031600
goto out;
16041601
} else if (err) {
16051602
error_btrfs_util(err);
1606-
btrfs_util_destroy_subvolume_iterator(iter);
1603+
btrfs_util_subvolume_iter_destroy(iter);
16071604
goto out;
16081605
}
16091606

@@ -1613,19 +1610,19 @@ static int cmd_subvolume_show(const struct cmd_struct *cmd, int argc, char **arg
16131610
free(subvol_path);
16141611
subvol_path = NULL;
16151612
}
1616-
btrfs_util_destroy_subvolume_iterator(iter);
1613+
btrfs_util_subvolume_iter_destroy(iter);
16171614
} else {
16181615
/*
16191616
* If !by_rootid, rootid_arg = 0, which means find the
16201617
* subvolume ID of the fd and use that.
16211618
*/
1622-
err = btrfs_util_subvolume_info_fd(fd, rootid_arg, &subvol);
1619+
err = btrfs_util_subvolume_get_info_fd(fd, rootid_arg, &subvol);
16231620
if (err) {
16241621
error_btrfs_util(err);
16251622
goto out;
16261623
}
16271624

1628-
err = btrfs_util_subvolume_path_fd(fd, subvol.id, &subvol_path);
1625+
err = btrfs_util_subvolume_get_path_fd(fd, subvol.id, &subvol_path);
16291626
if (err) {
16301627
error_btrfs_util(err);
16311628
goto out;
@@ -1655,20 +1652,18 @@ static int cmd_subvolume_show(const struct cmd_struct *cmd, int argc, char **arg
16551652
else
16561653
pr_verbose(LOG_DEFAULT, "\tSnapshot(s):\n");
16571654

1658-
err = btrfs_util_create_subvolume_iterator_fd(fd,
1659-
BTRFS_FS_TREE_OBJECTID, 0,
1660-
&iter);
1655+
err = btrfs_util_subvolume_iter_create_fd(fd, BTRFS_FS_TREE_OBJECTID, 0, &iter);
16611656

16621657
for (;;) {
16631658
struct btrfs_util_subvolume_info subvol2;
16641659
char *path;
16651660

1666-
err = btrfs_util_subvolume_iterator_next_info(iter, &path, &subvol2);
1661+
err = btrfs_util_subvolume_iter_next_info(iter, &path, &subvol2);
16671662
if (err == BTRFS_UTIL_ERROR_STOP_ITERATION) {
16681663
break;
16691664
} else if (err) {
16701665
error_btrfs_util(err);
1671-
btrfs_util_destroy_subvolume_iterator(iter);
1666+
btrfs_util_subvolume_iter_destroy(iter);
16721667
goto out2;
16731668
}
16741669

@@ -1685,7 +1680,7 @@ static int cmd_subvolume_show(const struct cmd_struct *cmd, int argc, char **arg
16851680
if (bconf.output_format == CMD_FORMAT_JSON)
16861681
fmt_print_end_group(&fctx, "snapshots");
16871682

1688-
btrfs_util_destroy_subvolume_iterator(iter);
1683+
btrfs_util_subvolume_iter_destroy(iter);
16891684

16901685
ret = btrfs_qgroup_query(fd, subvol.id, &stats);
16911686
if (ret == -ENOTTY) {
@@ -1779,7 +1774,7 @@ static int cmd_subvolume_sync(const struct cmd_struct *cmd, int argc, char **arg
17791774

17801775
id_count = argc - optind;
17811776
if (!id_count) {
1782-
err = btrfs_util_deleted_subvolumes_fd(fd, &ids, &id_count);
1777+
err = btrfs_util_subvolume_list_deleted_fd(fd, &ids, &id_count);
17831778
if (err) {
17841779
error_btrfs_util(err);
17851780
ret = 1;

common/parse-utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ u64 parse_qgroupid_or_path(const char *p)
360360

361361
path:
362362
/* Path format like subv at 'my_subvol' is the fallback case */
363-
err = btrfs_util_is_subvolume(p);
363+
err = btrfs_util_subvolume_is_valid(p);
364364
if (err)
365365
goto err;
366366
fd = open(p, O_RDONLY);

0 commit comments

Comments
 (0)