From f85ef957e647c5182acf5e64298f68e4b7fbfe8f Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 10 Mar 2015 18:15:52 +0100 Subject: util: add rename_noreplace renameat2() exists since Linux 3.15 but btrfs support for the flag RENAME_NOREPLACE was added later. This patch implements a fallback when renameat2() returns EINVAL. EINVAL is the error returned when the filesystem does not support one of the flags. --- src/import/import-tar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/import/import-tar.c') diff --git a/src/import/import-tar.c b/src/import/import-tar.c index dd95575660..ef2345c7b9 100644 --- a/src/import/import-tar.c +++ b/src/import/import-tar.c @@ -201,8 +201,9 @@ static int tar_import_finish(TarImport *i) { (void) rm_rf_dangerous(i->final_path, false, true, false); } - if (renameat2(AT_FDCWD, i->temp_path, AT_FDCWD, i->final_path, RENAME_NOREPLACE) < 0) - return log_error_errno(errno, "Failed to move image into place: %m"); + r = rename_noreplace(AT_FDCWD, i->temp_path, AT_FDCWD, i->final_path); + if (r < 0) + return log_error_errno(r, "Failed to move image into place: %m"); free(i->temp_path); i->temp_path = NULL; -- cgit v1.2.3-54-g00ecf