summaryrefslogtreecommitdiffstats
path: root/src/shared/btrfs-util.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-12-24 00:13:00 +0100
committerGitHub <noreply@github.com>2022-12-24 00:13:00 +0100
commit20ada514648d2c479a49689c6714c72af31ab8f6 (patch)
tree81b91da00312fef71aeb10ed9e0d339ce708474a /src/shared/btrfs-util.c
parentprioq: make prioq_reshuffle() void (diff)
parentlock-file: various updates (diff)
downloadsystemd-20ada514648d2c479a49689c6714c72af31ab8f6.tar.xz
systemd-20ada514648d2c479a49689c6714c72af31ab8f6.zip
Merge pull request #25828 from poettering/no-more-basename
convert a number of basename() invocations to 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);