diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-03-15 11:55:44 +0100 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-03-15 13:27:20 +0100 |
commit | 39eb3ffaaa3cdaf47c39cee11c80500c2fee338f (patch) | |
tree | b8db20bfd122459d6330d0d0d933e9b4ee1d4c2a /src | |
parent | a45332500d4fa08c039eb57c03b11aded553cf4e (diff) | |
download | systemd-39eb3ffaaa3cdaf47c39cee11c80500c2fee338f.tar.gz |
fs-util: Drop unlink_noerrno()
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/fs-util.c | 7 | ||||
-rw-r--r-- | src/basic/fs-util.h | 4 | ||||
-rw-r--r-- | src/basic/lock-util.c | 2 | ||||
-rw-r--r-- | src/boot/bootctl-install.c | 9 | ||||
-rw-r--r-- | src/home/homed-manager.c | 7 | ||||
-rw-r--r-- | src/test/test-fs-util.c | 19 |
6 files changed, 12 insertions, 36 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index a895f4f2df..deab6e525d 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -33,11 +33,6 @@ #include "umask-util.h" #include "user-util.h" -int unlink_noerrno(const char *path) { - PROTECT_ERRNO; - return RET_NERRNO(unlink(path)); -} - int rmdir_parents(const char *path, const char *stop) { char *p; int r; @@ -674,7 +669,7 @@ void unlink_tempfilep(char (*p)[]) { * successfully created. We ignore both the rare case where the * original suffix is used and unlink failures. */ if (!endswith(*p, ".XXXXXX")) - (void) unlink_noerrno(*p); + (void) unlink(*p); } int unlinkat_deallocate(int fd, const char *name, UnlinkDeallocateFlags flags) { diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h index 932d003f19..dad8f35239 100644 --- a/src/basic/fs-util.h +++ b/src/basic/fs-util.h @@ -22,8 +22,6 @@ #define PTR_TO_MODE(p) ((mode_t) ((uintptr_t) (p)-1)) #define MODE_TO_PTR(u) ((void *) ((uintptr_t) (u)+1)) -int unlink_noerrno(const char *path); - int rmdir_parents(const char *path, const char *stop); int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); @@ -99,7 +97,7 @@ static inline char* unlink_and_free(char *p) { if (!p) return NULL; - (void) unlink_noerrno(p); + (void) unlink(p); return mfree(p); } DEFINE_TRIVIAL_CLEANUP_FUNC(char*, unlink_and_free); diff --git a/src/basic/lock-util.c b/src/basic/lock-util.c index c7a7b68ebc..13e4c12237 100644 --- a/src/basic/lock-util.c +++ b/src/basic/lock-util.c @@ -100,7 +100,7 @@ void release_lock_file(LockFile *f) { f->operation = LOCK_EX|LOCK_NB; if ((f->operation & ~LOCK_NB) == LOCK_EX) - unlink_noerrno(f->path); + (void) unlink(f->path); f->path = mfree(f->path); } diff --git a/src/boot/bootctl-install.c b/src/boot/bootctl-install.c index 624b88abe3..9fee309328 100644 --- a/src/boot/bootctl-install.c +++ b/src/boot/bootctl-install.c @@ -262,13 +262,14 @@ static int copy_file_with_version_check(const char *from, const char *to, bool f r = fsync_full(fd_to); if (r < 0) { - (void) unlink_noerrno(t); + (void) unlink(t); return log_error_errno(r, "Failed to copy data from \"%s\" to \"%s\": %m", from, t); } - if (renameat(AT_FDCWD, t, AT_FDCWD, to) < 0) { - (void) unlink_noerrno(t); - return log_error_errno(errno, "Failed to rename \"%s\" to \"%s\": %m", t, to); + r = RET_NERRNO(renameat(AT_FDCWD, t, AT_FDCWD, to)); + if (r < 0) { + (void) unlink(t); + return log_error_errno(r, "Failed to rename \"%s\" to \"%s\": %m", t, to); } log_info("Copied \"%s\" to \"%s\".", from, to); diff --git a/src/home/homed-manager.c b/src/home/homed-manager.c index 84b5618671..258d2b16ed 100644 --- a/src/home/homed-manager.c +++ b/src/home/homed-manager.c @@ -1456,9 +1456,10 @@ static int manager_generate_key_pair(Manager *m) { return log_error_errno(errno, "Failed to move public key file into place: %m"); temp_public = mfree(temp_public); - if (rename(temp_private, "/var/lib/systemd/home/local.private") < 0) { - (void) unlink_noerrno("/var/lib/systemd/home/local.public"); /* try to remove the file we already created */ - return log_error_errno(errno, "Failed to move private key file into place: %m"); + r = RET_NERRNO(rename(temp_private, "/var/lib/systemd/home/local.private")); + if (r < 0) { + (void) unlink("/var/lib/systemd/home/local.public"); /* try to remove the file we already created */ + return log_error_errno(r, "Failed to move private key file into place: %m"); } temp_private = mfree(temp_private); diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c index c009424a2b..98417c9d32 100644 --- a/src/test/test-fs-util.c +++ b/src/test/test-fs-util.c @@ -508,25 +508,6 @@ TEST(chase_symlinks_at) { fd = safe_close(fd); } -TEST(unlink_noerrno) { - char *name; - int fd; - - name = strjoina(arg_test_dir ?: "/tmp", "/test-close_nointr.XXXXXX"); - fd = mkostemp_safe(name); - assert_se(fd >= 0); - assert_se(close_nointr(fd) >= 0); - - { - PROTECT_ERRNO; - errno = 42; - assert_se(unlink_noerrno(name) >= 0); - assert_se(errno == 42); - assert_se(unlink_noerrno(name) < 0); - assert_se(errno == 42); - } -} - TEST(readlink_and_make_absolute) { const char *tempdir, *name, *name2, *name_alias; _cleanup_free_ char *r1 = NULL, *r2 = NULL, *pwd = NULL; |