Debian Codegraph @

src/import/import-common.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "shared-forward.h"
5
6 typedef enum ImportFlags {
7 /* Public Flags (i.e. accessible via D-Bus, must stay stable! */
8 IMPORT_FORCE = 1 << 0, /* replace existing image */
9 IMPORT_READ_ONLY = 1 << 1, /* make generated image read-only */
10 IMPORT_PULL_KEEP_DOWNLOAD = 1 << 2, /* keep a pristine copy of the downloaded file around */
11
12 /* Private flags */
13 IMPORT_BTRFS_SUBVOL = 1 << 3, /* tar: preferably create images as btrfs subvols */
14 IMPORT_BTRFS_QUOTA = 1 << 4, /* tar: set up btrfs quota for new subvolume as child of parent subvolume */
15 IMPORT_CONVERT_QCOW2 = 1 << 5, /* raw: if we detect a qcow2 image, unpack it */
16 IMPORT_DIRECT = 1 << 6, /* import without rename games */
17 IMPORT_SYNC = 1 << 7, /* fsync() right before we are done */
18 IMPORT_FOREIGN_UID = 1 << 8, /* tar: go via nsresourced/mountfsd and make owned by foreign UID */
19
20 /* When pulling these flags are defined too */
21 IMPORT_PULL_SETTINGS = 1 << 9, /* download .nspawn settings file */
22 IMPORT_PULL_ROOTHASH = 1 << 10, /* only for raw: download .roothash file for verity */
23 IMPORT_PULL_ROOTHASH_SIGNATURE = 1 << 11, /* only for raw: download .roothash.p7s file for verity */
24 IMPORT_PULL_VERITY = 1 << 12, /* only for raw: download .verity file for verity */
25
26 /* The supported flags for the tar and raw importing */
27 IMPORT_FLAGS_MASK_TAR = IMPORT_FORCE|IMPORT_READ_ONLY|IMPORT_BTRFS_SUBVOL|IMPORT_BTRFS_QUOTA|IMPORT_DIRECT|IMPORT_SYNC|IMPORT_FOREIGN_UID,
28 IMPORT_FLAGS_MASK_RAW = IMPORT_FORCE|IMPORT_READ_ONLY|IMPORT_CONVERT_QCOW2|IMPORT_DIRECT|IMPORT_SYNC,
29
30 /* The supported flags for the tar, raw, oci pulling */
31 IMPORT_PULL_FLAGS_MASK_TAR = IMPORT_FLAGS_MASK_TAR|IMPORT_PULL_KEEP_DOWNLOAD|IMPORT_PULL_SETTINGS,
32 IMPORT_PULL_FLAGS_MASK_RAW = IMPORT_FLAGS_MASK_RAW|IMPORT_PULL_KEEP_DOWNLOAD|IMPORT_PULL_SETTINGS|IMPORT_PULL_ROOTHASH|IMPORT_PULL_ROOTHASH_SIGNATURE|IMPORT_PULL_VERITY,
33 IMPORT_PULL_FLAGS_MASK_OCI = IMPORT_FORCE|IMPORT_READ_ONLY|IMPORT_BTRFS_SUBVOL|IMPORT_BTRFS_QUOTA|IMPORT_SYNC|IMPORT_FOREIGN_UID|IMPORT_PULL_SETTINGS,
34
35 _IMPORT_FLAGS_INVALID = -EINVAL,
36 } ImportFlags;
37
38 int import_fork_tar_c(int tree_fd, int userns_fd, PidRef *ret_pid);
39 int import_fork_tar_x(int tree_fd, int userns_fd, PidRef *ret_pid);
40
41 int import_mangle_os_tree_fd(int tree_fd, int userns_fd, ImportFlags flags);
42 int import_mangle_os_tree(const char *path, int userns_fd, ImportFlags flags);
43 int import_mangle_os_tree_fd_foreign(int tree_fd, int userns_fd);
44
45 bool import_validate_local(const char *name, ImportFlags flags);
46
47 int import_allocate_event_with_signals(sd_event **ret);
48
49 int import_make_foreign_userns(int *userns_fd);
50
51 int import_remove_tree(const char *path, int *userns_fd, ImportFlags flags);