]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
copy: Move chattr arguments to full function signatures
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 14 Mar 2023 15:30:46 +0000 (16:30 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 21 Mar 2023 19:53:09 +0000 (20:53 +0100)
These are almost never used, so let's move them to the _full()
functions signatures.

15 files changed:
src/analyze/analyze-security.c
src/analyze/analyze-verify.c
src/firstboot/firstboot.c
src/import/pull-raw.c
src/import/pull-tar.c
src/journal/managed-journal-file.c
src/nspawn/nspawn.c
src/portable/portable.c
src/pstore/pstore.c
src/shared/copy.h
src/shared/discover-image.c
src/shared/edit-util.c
src/test/test-copy.c
src/test/test-execute.c
src/test/test-fs-util.c

index 7662bf1827d356c3566707b73c4735000f251c8f..56bc3627767bfec3d7c9c3200f25ff877f1a71a0 100644 (file)
@@ -2753,7 +2753,7 @@ static int offline_security_checks(
                                 profile = profile_path;
                         }
 
-                        r = copy_file(profile, dropin, 0, 0644, 0, 0, 0);
+                        r = copy_file(profile, dropin, 0, 0644, 0);
                         if (r < 0)
                                 return log_error_errno(r, "Failed to copy: %m");
                 }
index 98d48f627665344f4ce415d1da7ab18f179397b6..3b463f2ac7731d711c90c25a00bbecd58acaeac6 100644 (file)
@@ -40,7 +40,7 @@ static int process_aliases(char *argv[], char *tempdir, char ***ret) {
                 if (!dst)
                         return -ENOMEM;
 
-                r = copy_file(src, dst, 0, 0644, 0, 0, COPY_REFLINK);
+                r = copy_file(src, dst, 0, 0644, COPY_REFLINK);
                 if (r < 0)
                         return r;
 
index 5eaaff7d8417f522d0bfb1be89add2fa734adb7a..8f3e6a12651f4ab8e44e038e0199c3306dd7cc5b 100644 (file)
@@ -325,7 +325,7 @@ static int process_locale(void) {
         if (arg_copy_locale && arg_root) {
 
                 (void) mkdir_parents(etc_localeconf, 0755);
-                r = copy_file("/etc/locale.conf", etc_localeconf, 0, 0644, 0, 0, COPY_REFLINK);
+                r = copy_file("/etc/locale.conf", etc_localeconf, 0, 0644, COPY_REFLINK);
                 if (r != -ENOENT) {
                         if (r < 0)
                                 return log_error_errno(r, "Failed to copy %s: %m", etc_localeconf);
@@ -405,7 +405,7 @@ static int process_keymap(void) {
         if (arg_copy_keymap && arg_root) {
 
                 (void) mkdir_parents(etc_vconsoleconf, 0755);
-                r = copy_file("/etc/vconsole.conf", etc_vconsoleconf, 0, 0644, 0, 0, COPY_REFLINK);
+                r = copy_file("/etc/vconsole.conf", etc_vconsoleconf, 0, 0644, COPY_REFLINK);
                 if (r != -ENOENT) {
                         if (r < 0)
                                 return log_error_errno(r, "Failed to copy %s: %m", etc_vconsoleconf);
index 8a152d0f6f41f8e9390b75f635fafe6bccbafeb6..3befa96a042cb45d6e0718f1025d1e400fe54a5e 100644 (file)
@@ -327,7 +327,6 @@ static int raw_pull_copy_auxiliary_file(
                         *path,
                         local,
                         0644,
-                        0, 0,
                         COPY_REFLINK |
                         (FLAGS_SET(i->flags, PULL_FORCE) ? COPY_REPLACE : 0) |
                         (FLAGS_SET(i->flags, PULL_SYNC) ? COPY_FSYNC_FULL : 0));
index d3a1179ebc7616eb803cdd05b3f72ad785d4246f..f22eb0e3a33da5ebe2d8aa4cf0b50359dda09d64 100644 (file)
@@ -275,7 +275,6 @@ static int tar_pull_make_local_copy(TarPull *i) {
                                 i->settings_path,
                                 local_settings,
                                 0664,
-                                0, 0,
                                 COPY_REFLINK |
                                 (FLAGS_SET(i->flags, PULL_FORCE) ? COPY_REPLACE : 0) |
                                 (FLAGS_SET(i->flags, PULL_SYNC) ? COPY_FSYNC_FULL : 0));
index 538d999de0a611c232173d34c48151ed8a5d74ae..37d41f0678e2491cfba10a53ddab78c78c51366a 100644 (file)
@@ -222,10 +222,11 @@ static void managed_journal_file_set_offline_internal(ManagedJournalFile *f) {
 
                                 log_debug_errno(r, "Failed to re-enable copy-on-write for %s: %m, rewriting file", f->file->path);
 
-                                r = copy_file_atomic(FORMAT_PROC_FD_PATH(f->file->fd), f->file->path, f->file->mode,
-                                                     0,
-                                                     FS_NOCOW_FL,
-                                                     COPY_REPLACE | COPY_FSYNC | COPY_HOLES | COPY_ALL_XATTRS);
+                                r = copy_file_atomic_full(FORMAT_PROC_FD_PATH(f->file->fd), f->file->path, f->file->mode,
+                                                          0,
+                                                          FS_NOCOW_FL,
+                                                          COPY_REPLACE | COPY_FSYNC | COPY_HOLES | COPY_ALL_XATTRS,
+                                                          NULL, NULL);
                                 if (r < 0) {
                                         log_debug_errno(r, "Failed to rewrite %s: %m", f->file->path);
                                         continue;
index 7122902aa0291235e806ad0482bc73a40a8ac41a..056fad005d3e97caf992fd011d77e03b4ba4902c 100644 (file)
@@ -2034,7 +2034,7 @@ static int setup_timezone(const char *dest) {
 
         case TIMEZONE_COPY:
                 /* If mounting failed, try to copy */
-                r = copy_file_atomic("/etc/localtime", where, 0644, 0, 0, COPY_REFLINK|COPY_REPLACE);
+                r = copy_file_atomic("/etc/localtime", where, 0644, COPY_REFLINK|COPY_REPLACE);
                 if (r < 0) {
                         log_full_errno(IN_SET(r, -EROFS, -EACCES, -EPERM) ? LOG_DEBUG : LOG_WARNING, r,
                                        "Failed to copy /etc/localtime to %s, ignoring: %m", where);
@@ -2168,9 +2168,9 @@ static int setup_resolv_conf(const char *dest) {
         }
 
         if (IN_SET(m, RESOLV_CONF_REPLACE_HOST, RESOLV_CONF_REPLACE_STATIC, RESOLV_CONF_REPLACE_UPLINK, RESOLV_CONF_REPLACE_STUB))
-                r = copy_file_atomic(what, where, 0644, 0, 0, COPY_REFLINK|COPY_REPLACE);
+                r = copy_file_atomic(what, where, 0644, COPY_REFLINK|COPY_REPLACE);
         else
-                r = copy_file(what, where, O_TRUNC|O_NOFOLLOW, 0644, 0, 0, COPY_REFLINK);
+                r = copy_file(what, where, O_TRUNC|O_NOFOLLOW, 0644, COPY_REFLINK);
         if (r < 0) {
                 /* If the file already exists as symlink, let's suppress the warning, under the assumption that
                  * resolved or something similar runs inside and the symlink points there.
@@ -5697,7 +5697,10 @@ static int run(int argc, char *argv[]) {
 
                         {
                                 BLOCK_SIGNALS(SIGINT);
-                                r = copy_file(arg_image, np, O_EXCL, arg_read_only ? 0400 : 0600, FS_NOCOW_FL, FS_NOCOW_FL, COPY_REFLINK|COPY_CRTIME|COPY_SIGINT);
+                                r = copy_file_full(arg_image, np, O_EXCL, arg_read_only ? 0400 : 0600,
+                                                   FS_NOCOW_FL, FS_NOCOW_FL,
+                                                   COPY_REFLINK|COPY_CRTIME|COPY_SIGINT,
+                                                   NULL, NULL);
                         }
                         if (r == -EINTR) {
                                 log_error_errno(r, "Interrupted while copying image file to %s, removed again.", np);
index 7b0ee97c8c31f292c2393c7fb1e8723a01a80e9e..23102e51ddff6b94fe305ca32e9cc9cb4b4262a7 100644 (file)
@@ -1072,7 +1072,7 @@ static int install_profile_dropin(
 
         if (flags & PORTABLE_PREFER_COPY) {
 
-                r = copy_file_atomic(from, dropin, 0644, 0, 0, COPY_REFLINK);
+                r = copy_file_atomic(from, dropin, 0644, COPY_REFLINK);
                 if (r < 0)
                         return log_debug_errno(r, "Failed to copy %s %s %s: %m", from, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), dropin);
 
index fa6d6ec0e9c3d8adf99c444107a7bba344ca3b24..815503c6e7f8cf8d2f4261000625ff2a34bcd215 100644 (file)
@@ -152,7 +152,7 @@ static int move_file(PStoreEntry *pe, const char *subdir1, const char *subdir2)
                 r = mkdir_parents(ofd_path, 0755);
                 if (r < 0)
                         return log_error_errno(r, "Failed to create directory %s: %m", ofd_path);
-                r = copy_file_atomic(ifd_path, ofd_path, 0600, 0, 0, COPY_REPLACE);
+                r = copy_file_atomic(ifd_path, ofd_path, 0600, COPY_REPLACE);
                 if (r < 0)
                         return log_error_errno(r, "Failed to copy_file_atomic: %s to %s", ifd_path, ofd_path);
         }
index ab2e256915c9c9c29efdd8c4f4c80287d114c957..ec65959aefde99aff5e16e91ed28bd9d1d4f28b5 100644 (file)
@@ -47,19 +47,19 @@ static inline int copy_file_fd(const char *from, int to, CopyFlags copy_flags) {
 }
 
 int copy_file_at_full(int dir_fdf, const char *from, int dir_fdt, const char *to, int open_flags, mode_t mode, unsigned chattr_flags, unsigned chattr_mask, CopyFlags copy_flags, copy_progress_bytes_t progress, void *userdata);
-static inline int copy_file_at(int dir_fdf, const char *from, int dir_fdt, const char *to, int open_flags, mode_t mode, unsigned chattr_flags, unsigned chattr_mask, CopyFlags copy_flags) {
-        return copy_file_at_full(dir_fdf, from, dir_fdt, to, open_flags, mode, chattr_flags, chattr_mask, copy_flags, NULL, NULL);
+static inline int copy_file_at(int dir_fdf, const char *from, int dir_fdt, const char *to, int open_flags, mode_t mode, CopyFlags copy_flags) {
+        return copy_file_at_full(dir_fdf, from, dir_fdt, to, open_flags, mode, 0, 0, copy_flags, NULL, NULL);
 }
 static inline int copy_file_full(const char *from, const char *to, int open_flags, mode_t mode, unsigned chattr_flags, unsigned chattr_mask, CopyFlags copy_flags, copy_progress_bytes_t progress, void *userdata) {
         return copy_file_at_full(AT_FDCWD, from, AT_FDCWD, to, open_flags, mode, chattr_flags, chattr_mask, copy_flags, progress, userdata);
 }
-static inline int copy_file(const char *from, const char *to, int open_flags, mode_t mode, unsigned chattr_flags, unsigned chattr_mask, CopyFlags copy_flags) {
-        return copy_file_at(AT_FDCWD, from, AT_FDCWD, to, open_flags, mode, chattr_flags, chattr_mask, copy_flags);
+static inline int copy_file(const char *from, const char *to, int open_flags, mode_t mode, CopyFlags copy_flags) {
+        return copy_file_at(AT_FDCWD, from, AT_FDCWD, to, open_flags, mode, copy_flags);
 }
 
 int copy_file_atomic_full(const char *from, const char *to, mode_t mode, unsigned chattr_flags, unsigned chattr_mask, CopyFlags copy_flags, copy_progress_bytes_t progress, void *userdata);
-static inline int copy_file_atomic(const char *from, const char *to, mode_t mode, unsigned chattr_flags, unsigned chattr_mask, CopyFlags copy_flags) {
-        return copy_file_atomic_full(from, to, mode, chattr_flags, chattr_mask, copy_flags, NULL, NULL);
+static inline int copy_file_atomic(const char *from, const char *to, mode_t mode, CopyFlags copy_flags) {
+        return copy_file_atomic_full(from, to, mode, 0, 0, copy_flags, NULL, NULL);
 }
 
 int copy_tree_at_full(int fdf, const char *from, int fdt, const char *to, uid_t override_uid, gid_t override_gid, CopyFlags copy_flags, Hashmap *denylist, copy_progress_path_t progress_path, copy_progress_bytes_t progress_bytes, void *userdata);
index 17a3ac679af8f75c6dd72347926de1153f3ac600..1f5b11f5f4050ede0d6c67eb50b56d9c2c3c5894 100644 (file)
@@ -850,7 +850,7 @@ static int clone_auxiliary_file(const char *path, const char *new_name, const ch
         if (r < 0)
                 return r;
 
-        return copy_file_atomic(path, rs, 0664, 0, 0, COPY_REFLINK);
+        return copy_file_atomic(path, rs, 0664, COPY_REFLINK);
 }
 
 int image_clone(Image *i, const char *new_name, bool read_only) {
@@ -911,7 +911,8 @@ int image_clone(Image *i, const char *new_name, bool read_only) {
         case IMAGE_RAW:
                 new_path = strjoina("/var/lib/machines/", new_name, ".raw");
 
-                r = copy_file_atomic(i->path, new_path, read_only ? 0444 : 0644, FS_NOCOW_FL, FS_NOCOW_FL, COPY_REFLINK|COPY_CRTIME);
+                r = copy_file_atomic_full(i->path, new_path, read_only ? 0444 : 0644, FS_NOCOW_FL, FS_NOCOW_FL,
+                                          COPY_REFLINK|COPY_CRTIME, NULL, NULL);
                 break;
 
         case IMAGE_BLOCK:
index 58cd7fe9f3dae64b36fa995bdd99b30423f2898b..b59f129528821e832f8273ce04ccc62b45a4f0be 100644 (file)
@@ -138,7 +138,7 @@ static int create_edit_temp_file(EditFile *e) {
                 if (r < 0)
                         return r;
 
-                r = copy_file(e->original_path, temp, 0, 0644, 0, 0, COPY_REFLINK);
+                r = copy_file(e->original_path, temp, 0, 0644, COPY_REFLINK);
                 if (r == -ENOENT) {
                         r = touch(temp);
                         mac_selinux_create_file_clear();
index a2b2b34d9845b21a81b5c505afe8f34a9523c3b7..d3f37ea9e39b7d6ab1e366985321b9a2a7c00977 100644 (file)
@@ -39,7 +39,7 @@ TEST(copy_file) {
 
         assert_se(write_string_file(fn, "foo bar bar bar foo", WRITE_STRING_FILE_CREATE) == 0);
 
-        assert_se(copy_file(fn, fn_copy, 0, 0644, 0, 0, COPY_REFLINK) == 0);
+        assert_se(copy_file(fn, fn_copy, 0, 0644, COPY_REFLINK) == 0);
 
         assert_se(read_full_file(fn_copy, &buf, &sz) == 0);
         assert_se(streq(buf, "foo bar bar bar foo\n"));
@@ -366,13 +366,13 @@ TEST(copy_atomic) {
 
         q = strjoina(p, "/fstab");
 
-        r = copy_file_atomic("/etc/fstab", q, 0644, 0, 0, COPY_REFLINK);
+        r = copy_file_atomic("/etc/fstab", q, 0644, COPY_REFLINK);
         if (r == -ENOENT || ERRNO_IS_PRIVILEGE(r))
                 return;
 
-        assert_se(copy_file_atomic("/etc/fstab", q, 0644, 0, 0, COPY_REFLINK) == -EEXIST);
+        assert_se(copy_file_atomic("/etc/fstab", q, 0644, COPY_REFLINK) == -EEXIST);
 
-        assert_se(copy_file_atomic("/etc/fstab", q, 0644, 0, 0, COPY_REPLACE) >= 0);
+        assert_se(copy_file_atomic("/etc/fstab", q, 0644, COPY_REPLACE) >= 0);
 }
 
 TEST(copy_proc) {
@@ -383,7 +383,7 @@ TEST(copy_proc) {
 
         assert_se(mkdtemp_malloc(NULL, &p) >= 0);
         assert_se(f = path_join(p, "version"));
-        assert_se(copy_file("/proc/version", f, 0, MODE_INVALID, 0, 0, 0) >= 0);
+        assert_se(copy_file("/proc/version", f, 0, MODE_INVALID, 0) >= 0);
 
         assert_se(read_one_line_file("/proc/version", &a) >= 0);
         assert_se(read_one_line_file(f, &b) >= 0);
index 0c96f28aa962864a27c357aef93a37e920d2dd4b..fc6eba9fcaf0533303cb21ecfc337396450d9411 100644 (file)
@@ -283,7 +283,7 @@ static void test_exec_workingdirectory(Manager *m) {
 static void test_exec_execsearchpath(Manager *m) {
         assert_se(mkdir_p("/tmp/test-exec_execsearchpath", 0755) >= 0);
 
-        assert_se(copy_file("/bin/ls", "/tmp/test-exec_execsearchpath/ls_temp", 0,  0777, 0, 0, COPY_REPLACE) >= 0);
+        assert_se(copy_file("/bin/ls", "/tmp/test-exec_execsearchpath/ls_temp", 0,  0777, COPY_REPLACE) >= 0);
 
         test(m, "exec-execsearchpath.service", 0, CLD_EXITED);
 
index ce61f28017a4d7828cca9e666aea1e3e7ea6a2e3..f115a40188f65d8149e1a20bee86fc840cb7d424 100644 (file)
@@ -997,7 +997,7 @@ TEST(conservative_rename) {
         assert_se(access(q, F_OK) < 0 && errno == ENOENT);
 
         /* Check that a manual copy is detected */
-        assert_se(copy_file(p, q, 0, MODE_INVALID, 0, 0, COPY_REFLINK) >= 0);
+        assert_se(copy_file(p, q, 0, MODE_INVALID, COPY_REFLINK) >= 0);
         assert_se(conservative_renameat(AT_FDCWD, q, AT_FDCWD, p) == 0);
         assert_se(access(q, F_OK) < 0 && errno == ENOENT);