diff options
author | Alban Crequy <alban@endocode.com> | 2015-03-10 18:15:52 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-03-10 18:23:46 +0100 |
commit | f85ef957e647c5182acf5e64298f68e4b7fbfe8f (patch) | |
tree | 505151f058adc41e72d262d044cc2b0092a148aa /src/import/import-raw.c | |
parent | 27cc6f166bdebc0e698fb692993b801db2618866 (diff) |
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.
Diffstat (limited to 'src/import/import-raw.c')
-rw-r--r-- | src/import/import-raw.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/import/import-raw.c b/src/import/import-raw.c index 25b52f7cbd..7d1ac2afd7 100644 --- a/src/import/import-raw.c +++ b/src/import/import-raw.c @@ -245,8 +245,9 @@ static int raw_import_finish(RawImport *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; |