summaryrefslogtreecommitdiff
path: root/src/shared/btrfs-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-12-21 16:51:05 +0100
committerLennart Poettering <lennart@poettering.net>2022-12-23 17:35:21 +0100
commit03469b770bbe056b8df3bd109926b3941c0da878 (patch)
treeb61883dcf8facf19076670ce9a8de2be27e01c41 /src/shared/btrfs-util.c
parent7b2ffb593e57b4e3e13de06f0ce382bdd19d37cc (diff)
downloadsystemd-03469b770bbe056b8df3bd109926b3941c0da878.tar.gz
shared: port various shared helpers basename() → path_extract_filename()
Diffstat (limited to 'src/shared/btrfs-util.c')
-rw-r--r--src/shared/btrfs-util.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c
index 0a4bd48b88..0ef3c608bb 100644
--- a/src/shared/btrfs-util.c
+++ b/src/shared/btrfs-util.c
@@ -51,20 +51,22 @@ static int validate_subvolume_name(const char *name) {
return 0;
}
-static int extract_subvolume_name(const char *path, const char **subvolume) {
- const char *fn;
+static int extract_subvolume_name(const char *path, char **ret) {
+ _cleanup_free_ char *fn = NULL;
int r;
assert(path);
- assert(subvolume);
+ assert(ret);
- fn = basename(path);
+ r = path_extract_filename(path, &fn);
+ if (r < 0)
+ return r;
r = validate_subvolume_name(fn);
if (r < 0)
return r;
- *subvolume = fn;
+ *ret = TAKE_PTR(fn);
return 0;
}
@@ -119,8 +121,8 @@ int btrfs_subvol_make_fd(int fd, const char *subvolume) {
}
int btrfs_subvol_make(const char *path) {
+ _cleanup_free_ char *subvolume = NULL;
_cleanup_close_ int fd = -EBADF;
- const char *subvolume;
int r;
assert(path);
@@ -1180,8 +1182,8 @@ static int subvol_remove_children(int fd, const char *subvolume, uint64_t subvol
}
int btrfs_subvol_remove(const char *path, BtrfsRemoveFlags flags) {
+ _cleanup_free_ char *subvolume = NULL;
_cleanup_close_ int fd = -EBADF;
- const char *subvolume;
int r;
assert(path);
@@ -1578,8 +1580,8 @@ int btrfs_subvol_snapshot_fd_full(
copy_progress_bytes_t progress_bytes,
void *userdata) {
+ _cleanup_free_ char *subvolume = NULL;
_cleanup_close_ int new_fd = -EBADF;
- const char *subvolume;
int r;
assert(old_fd >= 0);