import: Clean up headers

Split out of #37344.
This commit is contained in:
Daan De Meyer
2025-05-21 18:09:52 +02:00
parent 6ad1d1ede6
commit 9412e9e97b
31 changed files with 106 additions and 151 deletions
+3 -3
View File
@@ -1,14 +1,14 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <fcntl.h>
#include "sd-event.h"
#include "alloc-util.h"
#include "curl-util.h"
#include "fd-util.h"
#include "locale-util.h"
#include "hashmap.h"
#include "log.h"
#include "string-util.h"
#include "time-util.h"
#include "version.h"
static void curl_glue_check_finished(CurlGlue *g) {
+3 -7
View File
@@ -2,16 +2,12 @@
#pragma once
#include <curl/curl.h>
#include <sys/types.h>
#include "sd-event.h"
#include "hashmap.h"
#include "time-util.h"
#include "forward.h"
typedef struct CurlGlue CurlGlue;
struct CurlGlue {
typedef struct CurlGlue {
sd_event *event;
CURLM *curl;
sd_event_source *timer;
@@ -20,7 +16,7 @@ struct CurlGlue {
void (*on_finished)(CurlGlue *g, CURL *curl, CURLcode code);
void *userdata;
};
} CurlGlue;
int curl_glue_new(CurlGlue **glue, sd_event *event);
CurlGlue* curl_glue_unref(CurlGlue *glue);
+5 -5
View File
@@ -3,26 +3,26 @@
#include <sys/sendfile.h>
#include "sd-daemon.h"
#include "sd-event.h"
#include "alloc-util.h"
#include "btrfs-util.h"
#include "copy.h"
#include "export-raw.h"
#include "fd-util.h"
#include "format-util.h"
#include "fs-util.h"
#include "import-common.h"
#include "log.h"
#include "missing_fcntl.h"
#include "pretty-print.h"
#include "ratelimit.h"
#include "stat-util.h"
#include "string-util.h"
#include "terminal-util.h"
#include "time-util.h"
#include "tmpfile-util.h"
#define COPY_BUFFER_SIZE (16*1024)
struct RawExport {
typedef struct RawExport {
sd_event *event;
RawExportFinished on_finished;
@@ -52,7 +52,7 @@ struct RawExport {
bool eof;
bool tried_reflink;
bool tried_sendfile;
};
} RawExport;
RawExport *raw_export_unref(RawExport *e) {
if (!e)
+1 -3
View File
@@ -1,10 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-event.h"
#include "forward.h"
#include "import-compress.h"
#include "memory-util.h"
typedef struct RawExport RawExport;
+8 -2
View File
@@ -1,22 +1,28 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/stat.h>
#include "sd-daemon.h"
#include "sd-event.h"
#include "alloc-util.h"
#include "btrfs-util.h"
#include "export-tar.h"
#include "fd-util.h"
#include "format-util.h"
#include "import-common.h"
#include "log.h"
#include "pretty-print.h"
#include "process-util.h"
#include "ratelimit.h"
#include "string-util.h"
#include "terminal-util.h"
#include "time-util.h"
#include "tmpfile-util.h"
#define COPY_BUFFER_SIZE (16*1024)
struct TarExport {
typedef struct TarExport {
sd_event *event;
TarExportFinished on_finished;
@@ -49,7 +55,7 @@ struct TarExport {
bool eof;
bool tried_splice;
};
} TarExport;
TarExport *tar_export_unref(TarExport *e) {
if (!e)
+1 -3
View File
@@ -1,10 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-event.h"
#include "forward.h"
#include "import-compress.h"
#include "memory-util.h"
typedef struct TarExport TarExport;
+4 -7
View File
@@ -4,7 +4,6 @@
#include <locale.h>
#include "sd-event.h"
#include "sd-id128.h"
#include "alloc-util.h"
#include "ansi-color.h"
@@ -13,14 +12,12 @@
#include "export-raw.h"
#include "export-tar.h"
#include "fd-util.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "import-common.h"
#include "import-util.h"
#include "log.h"
#include "main-func.h"
#include "runtime-scope.h"
#include "signal-util.h"
#include "string-util.h"
#include "terminal-util.h"
#include "verbs.h"
static ImportCompressType arg_compress = IMPORT_COMPRESS_UNKNOWN;
@@ -56,7 +53,7 @@ static void on_tar_finished(TarExport *export, int error, void *userdata) {
if (error == 0)
log_info("Operation completed successfully.");
sd_event_exit(event, abs(error));
sd_event_exit(event, ABS(error));
}
static int export_tar(int argc, char *argv[], void *userdata) {
@@ -129,7 +126,7 @@ static void on_raw_finished(RawExport *export, int error, void *userdata) {
if (error == 0)
log_info("Operation completed successfully.");
sd_event_exit(event, abs(error));
sd_event_exit(event, ABS(error));
}
static int export_raw(int argc, char *argv[], void *userdata) {
+2 -5
View File
@@ -1,25 +1,22 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sched.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <unistd.h>
#include "sd-event.h"
#include "alloc-util.h"
#include "btrfs-util.h"
#include "capability-util.h"
#include "chattr-util.h"
#include "dirent-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "import-common.h"
#include "log.h"
#include "os-util.h"
#include "process-util.h"
#include "selinux-util.h"
#include "signal-util.h"
#include "stat-util.h"
#include "tmpfile-util.h"
+1 -5
View File
@@ -1,11 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <errno.h>
#include <stdbool.h>
#include <sys/types.h>
#include "sd-event.h"
#include "forward.h"
typedef enum ImportFlags {
/* Public Flags (i.e. accessible via D-Bus, must stay stable! */
+3 -2
View File
@@ -1,8 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "assert-util.h"
#include <stdlib.h>
#include <string.h>
#include "import-compress.h"
#include "log.h"
#include "string-table.h"
void import_compress_free(ImportCompress *c) {
+1 -5
View File
@@ -1,20 +1,16 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <errno.h>
#if HAVE_BZIP2
#include <bzlib.h>
#endif
#include <lzma.h>
#include <sys/types.h>
#include <zlib.h>
#if HAVE_ZSTD
#include <zstd.h>
#include <zstd_errors.h>
#endif
#include "macro.h"
#include "forward.h"
typedef enum ImportCompressType {
IMPORT_COMPRESS_UNKNOWN,
+4 -3
View File
@@ -10,19 +10,20 @@
#include "discover-image.h"
#include "fd-util.h"
#include "format-util.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "import-common.h"
#include "import-util.h"
#include "install-file.h"
#include "log.h"
#include "main-func.h"
#include "mkdir-label.h"
#include "parse-argument.h"
#include "path-util.h"
#include "ratelimit.h"
#include "rm-rf.h"
#include "runtime-scope.h"
#include "signal-util.h"
#include "string-util.h"
#include "terminal-util.h"
#include "time-util.h"
#include "tmpfile-util.h"
#include "verbs.h"
+3 -1
View File
@@ -6,6 +6,7 @@
#include "creds-util.h"
#include "discover-image.h"
#include "efivars.h"
#include "errno-util.h"
#include "extract-word.h"
#include "fd-util.h"
#include "fileio.h"
@@ -14,9 +15,10 @@
#include "initrd-util.h"
#include "json-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "proc-cmdline.h"
#include "special.h"
#include "specifier.h"
#include "string-util.h"
#include "unit-name.h"
#include "web-util.h"
+6 -8
View File
@@ -1,15 +1,15 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/stat.h>
#include "sd-daemon.h"
#include "sd-event.h"
#include "alloc-util.h"
#include "btrfs-util.h"
#include "copy.h"
#include "fd-util.h"
#include "format-util.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "import-common.h"
#include "import-compress.h"
#include "import-raw.h"
@@ -17,18 +17,16 @@
#include "install-file.h"
#include "io-util.h"
#include "log.h"
#include "machine-pool.h"
#include "missing_fs.h"
#include "mkdir-label.h"
#include "path-util.h"
#include "pretty-print.h"
#include "qcow2-util.h"
#include "ratelimit.h"
#include "rm-rf.h"
#include "string-util.h"
#include "terminal-util.h"
#include "time-util.h"
#include "tmpfile-util.h"
struct RawImport {
typedef struct RawImport {
sd_event *event;
char *image_root;
@@ -63,7 +61,7 @@ struct RawImport {
uint64_t offset;
uint64_t size_max;
};
} RawImport;
RawImport* raw_import_unref(RawImport *i) {
if (!i)
+1 -3
View File
@@ -1,10 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-event.h"
#include "forward.h"
#include "import-common.h"
#include "memory-util.h"
typedef struct RawImport RawImport;
+7 -9
View File
@@ -1,16 +1,15 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/stat.h>
#include "sd-daemon.h"
#include "sd-event.h"
#include "alloc-util.h"
#include "btrfs-util.h"
#include "copy.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "format-util.h"
#include "import-common.h"
#include "import-compress.h"
#include "import-tar.h"
@@ -18,19 +17,18 @@
#include "install-file.h"
#include "io-util.h"
#include "log.h"
#include "machine-pool.h"
#include "missing_fs.h"
#include "mkdir-label.h"
#include "path-util.h"
#include "pretty-print.h"
#include "process-util.h"
#include "qcow2-util.h"
#include "ratelimit.h"
#include "rm-rf.h"
#include "string-util.h"
#include "terminal-util.h"
#include "time-util.h"
#include "tmpfile-util.h"
struct TarImport {
typedef struct TarImport {
sd_event *event;
char *image_root;
@@ -63,7 +61,7 @@ struct TarImport {
unsigned last_percent;
RateLimit progress_ratelimit;
};
} TarImport;
TarImport* tar_import_unref(TarImport *i) {
if (!i)
+1 -3
View File
@@ -1,10 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-event.h"
#include "forward.h"
#include "import-common.h"
#include "memory-util.h"
typedef struct TarImport TarImport;
+5 -6
View File
@@ -4,7 +4,6 @@
#include <locale.h>
#include "sd-event.h"
#include "sd-id128.h"
#include "alloc-util.h"
#include "ansi-color.h"
@@ -12,18 +11,18 @@
#include "discover-image.h"
#include "env-util.h"
#include "fd-util.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "import-raw.h"
#include "import-tar.h"
#include "import-util.h"
#include "io-util.h"
#include "log.h"
#include "main-func.h"
#include "parse-argument.h"
#include "parse-util.h"
#include "path-util.h"
#include "runtime-scope.h"
#include "signal-util.h"
#include "string-util.h"
#include "terminal-util.h"
#include "verbs.h"
static const char *arg_image_root = NULL;
@@ -133,7 +132,7 @@ static void on_tar_finished(TarImport *import, int error, void *userdata) {
if (error == 0)
log_info("Operation completed successfully.");
sd_event_exit(event, abs(error));
sd_event_exit(event, ABS(error));
}
static int import_tar(int argc, char *argv[], void *userdata) {
@@ -202,7 +201,7 @@ static void on_raw_finished(RawImport *import, int error, void *userdata) {
if (error == 0)
log_info("Operation completed successfully.");
sd_event_exit(event, abs(error));
sd_event_exit(event, ABS(error));
}
static int import_raw(int argc, char *argv[], void *userdata) {
+5 -5
View File
@@ -1,8 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <getopt.h>
#include <locale.h>
#include "sd-bus.h"
#include "sd-event.h"
#include "alloc-util.h"
#include "build.h"
@@ -12,12 +14,9 @@
#include "discover-image.h"
#include "fd-util.h"
#include "format-table.h"
#include "hostname-util.h"
#include "import-common.h"
#include "import-util.h"
#include "locale-util.h"
#include "log.h"
#include "macro.h"
#include "main-func.h"
#include "os-util.h"
#include "pager.h"
@@ -26,9 +25,10 @@
#include "path-util.h"
#include "polkit-agent.h"
#include "pretty-print.h"
#include "signal-util.h"
#include "sort-util.h"
#include "runtime-scope.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "verbs.h"
#include "web-util.h"
+10 -12
View File
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/prctl.h>
#include <sys/wait.h>
#include <stdlib.h>
#include "sd-bus.h"
#include "sd-varlink.h"
@@ -11,6 +10,7 @@
#include "bus-common-errors.h"
#include "bus-get-properties.h"
#include "bus-log-control-api.h"
#include "bus-object.h"
#include "bus-polkit.h"
#include "bus-util.h"
#include "common-signal.h"
@@ -21,33 +21,31 @@
#include "event-util.h"
#include "fd-util.h"
#include "float.h"
#include "hostname-util.h"
#include "hashmap.h"
#include "import-common.h"
#include "import-util.h"
#include "json-util.h"
#include "machine-pool.h"
#include "main-func.h"
#include "mkdir-label.h"
#include "notify-recv.h"
#include "os-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "percent-util.h"
#include "pidref.h"
#include "process-util.h"
#include "runtime-scope.h"
#include "service-util.h"
#include "set.h"
#include "signal-util.h"
#include "socket-util.h"
#include "stat-util.h"
#include "string-table.h"
#include "strv.h"
#include "syslog-util.h"
#include "user-util.h"
#include "varlink-io.systemd.Import.h"
#include "varlink-io.systemd.service.h"
#include "varlink-util.h"
#include "web-util.h"
typedef struct Transfer Transfer;
typedef struct Manager Manager;
typedef enum TransferType {
@@ -62,7 +60,7 @@ typedef enum TransferType {
_TRANSFER_TYPE_INVALID = -EINVAL,
} TransferType;
struct Transfer {
typedef struct Transfer {
Manager *manager;
uint32_t id;
@@ -96,9 +94,9 @@ struct Transfer {
int stdout_fd;
Set *varlink_subscribed;
};
} Transfer;
struct Manager {
typedef struct Manager {
sd_event *event;
sd_bus *bus;
sd_varlink_server *varlink_server;
@@ -114,7 +112,7 @@ struct Manager {
bool use_btrfs_quota;
RuntimeScope runtime_scope; /* for now: always RUNTIME_SCOPE_SYSTEM */
};
} Manager;
#define TRANSFERS_MAX 64
+3 -7
View File
@@ -1,24 +1,20 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/prctl.h>
#include "sd-id128.h"
#include "alloc-util.h"
#include "btrfs-util.h"
#include "capability-util.h"
#include "copy.h"
#include "dirent-util.h"
#include "discover-image.h"
#include "escape.h"
#include "fd-util.h"
#include "hostname-util.h"
#include "io-util.h"
#include "log.h"
#include "memory-util.h"
#include "os-util.h"
#include "path-util.h"
#include "process-util.h"
#include "pull-common.h"
#include "pull-job.h"
#include "rm-rf.h"
#include "signal-util.h"
#include "siphash24.h"
#include "string-util.h"
#include "strv.h"
+4 -2
View File
@@ -1,12 +1,14 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdbool.h>
#include "forward.h"
#include "import-common.h"
#include "import-util.h"
#include "pull-job.h"
typedef struct CurlGlue CurlGlue;
typedef struct PullJob PullJob;
int pull_find_old_etags(const char *url, const char *root, int dt, const char *prefix, const char *suffix, char ***etags);
int pull_make_path(const char *url, const char *etag, const char *image_root, const char *prefix, const char *suffix, char **ret);
+2 -2
View File
@@ -8,16 +8,16 @@
#include "fd-util.h"
#include "format-util.h"
#include "hexdecoct.h"
#include "import-util.h"
#include "io-util.h"
#include "log.h"
#include "machine-pool.h"
#include "parse-util.h"
#include "pull-common.h"
#include "pull-job.h"
#include "curl-util.h"
#include "string-util.h"
#include "strv.h"
#include "sync-util.h"
#include "time-util.h"
#include "xattr-util.h"
void pull_job_close_disk_fd(PullJob *j) {
+5 -3
View File
@@ -1,12 +1,14 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <curl/curl.h>
#include <sys/stat.h>
#include "curl-util.h"
#include "forward.h"
#include "import-compress.h"
#include "openssl-util.h"
typedef struct CurlGlue CurlGlue;
typedef struct PullJob PullJob;
typedef void (*PullJobFinished)(PullJob *job);
@@ -27,7 +29,7 @@ typedef enum PullJobState {
#define PULL_JOB_IS_COMPLETE(j) (IN_SET((j)->state, PULL_JOB_DONE, PULL_JOB_FAILED))
struct PullJob {
typedef struct PullJob {
PullJobState state;
int error;
@@ -77,7 +79,7 @@ struct PullJob {
char *checksum;
bool sync;
bool force_memory;
};
} PullJob;
int pull_job_new(PullJob **job, const char *url, CurlGlue *glue, void *userdata);
PullJob* pull_job_unref(PullJob *job);
+3 -13
View File
@@ -1,34 +1,24 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <curl/curl.h>
#include <sys/xattr.h>
#include "sd-daemon.h"
#include "sd-event.h"
#include "alloc-util.h"
#include "btrfs-util.h"
#include "copy.h"
#include "curl-util.h"
#include "fd-util.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "import-common.h"
#include "import-util.h"
#include "install-file.h"
#include "log.h"
#include "macro.h"
#include "missing_fs.h"
#include "mkdir-label.h"
#include "path-util.h"
#include "pull-common.h"
#include "pull-job.h"
#include "pull-raw.h"
#include "qcow2-util.h"
#include "rm-rf.h"
#include "string-util.h"
#include "strv.h"
#include "tmpfile-util.h"
#include "utf8.h"
#include "web-util.h"
typedef enum RawProgress {
@@ -39,7 +29,7 @@ typedef enum RawProgress {
RAW_COPYING,
} RawProgress;
struct RawPull {
typedef struct RawPull {
sd_event *event;
CurlGlue *glue;
@@ -79,7 +69,7 @@ struct RawPull {
char *verity_temp_path;
char *checksum;
};
} RawPull;
RawPull* raw_pull_unref(RawPull *i) {
if (!i)
+2 -4
View File
@@ -1,11 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-event.h"
#include "forward.h"
#include "import-common.h"
#include "import-util.h"
#include "macro.h"
#include "pull-common.h"
typedef struct RawPull RawPull;
+4 -10
View File
@@ -1,23 +1,20 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <curl/curl.h>
#include <sys/prctl.h>
#include <dirent.h>
#include "sd-daemon.h"
#include "sd-event.h"
#include "alloc-util.h"
#include "btrfs-util.h"
#include "copy.h"
#include "curl-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "import-common.h"
#include "import-util.h"
#include "install-file.h"
#include "log.h"
#include "macro.h"
#include "mkdir-label.h"
#include "path-util.h"
#include "process-util.h"
@@ -26,10 +23,7 @@
#include "pull-tar.h"
#include "rm-rf.h"
#include "string-util.h"
#include "strv.h"
#include "tmpfile-util.h"
#include "user-util.h"
#include "utf8.h"
#include "web-util.h"
typedef enum TarProgress {
@@ -39,7 +33,7 @@ typedef enum TarProgress {
TAR_COPYING,
} TarProgress;
struct TarPull {
typedef struct TarPull {
sd_event *event;
CurlGlue *glue;
@@ -66,7 +60,7 @@ struct TarPull {
char *settings_temp_path;
char *checksum;
};
} TarPull;
TarPull* tar_pull_unref(TarPull *i) {
if (!i)
+2 -4
View File
@@ -1,11 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-event.h"
#include "forward.h"
#include "import-common.h"
#include "import-util.h"
#include "macro.h"
#include "pull-common.h"
typedef struct TarPull TarPull;
+6 -5
View File
@@ -2,9 +2,9 @@
#include <getopt.h>
#include <locale.h>
#include <stdio.h>
#include "sd-event.h"
#include "sd-id128.h"
#include "alloc-util.h"
#include "ansi-color.h"
@@ -12,18 +12,19 @@
#include "discover-image.h"
#include "env-util.h"
#include "hexdecoct.h"
#include "hostname-util.h"
#include "import-common.h"
#include "import-util.h"
#include "io-util.h"
#include "log.h"
#include "main-func.h"
#include "parse-argument.h"
#include "parse-util.h"
#include "path-util.h"
#include "pull-raw.h"
#include "pull-tar.h"
#include "runtime-scope.h"
#include "signal-util.h"
#include "string-util.h"
#include "terminal-util.h"
#include "verbs.h"
#include "web-util.h"
@@ -109,7 +110,7 @@ static void on_tar_finished(TarPull *pull, int error, void *userdata) {
if (error == 0)
log_info("Operation completed successfully.");
sd_event_exit(event, abs(error));
sd_event_exit(event, ABS(error));
}
static int pull_tar(int argc, char *argv[], void *userdata) {
@@ -179,7 +180,7 @@ static void on_raw_finished(RawPull *pull, int error, void *userdata) {
if (error == 0)
log_info("Operation completed successfully.");
sd_event_exit(event, abs(error));
sd_event_exit(event, ABS(error));
}
static int pull_raw(int argc, char *argv[], void *userdata) {
+1 -2
View File
@@ -3,8 +3,7 @@
#include <zlib.h>
#include "alloc-util.h"
#include "assert-util.h"
#include "btrfs-util.h"
#include "copy.h"
#include "qcow2-util.h"
#include "sparse-endian.h"
-2
View File
@@ -1,8 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "fd-util.h"
#include "log.h"