/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once

typedef enum TarFlags {
        TAR_SELINUX               = 1 << 0, /* Include SELinux xattr in tarball, or unpack it */
        TAR_SQUASH_UIDS_ABOVE_64K = 1 << 1, /* Squash UIDs/GIDs above 64K when packing/unpacking to the nobody user */
        TAR_OCI_WHITEOUTS         = 1 << 2, /* Turn OCI/aufs whiteout inodes into overlayfs whiteouts */
} TarFlags;

/* Allocates a tmpfs superblock for tar_c() to keep its hardlink database in. Requires CAP_SYS_ADMIN in the
 * caller's user namespace, hence callers that drop privileges must do this first and pass the fd along. */
int tar_hardlink_db_new(void);

int tar_x(int input_fd, int tree_fd, TarFlags flags);
int tar_c(int tree_fd, int output_fd, const char *filename, int hardlink_db_fd, TarFlags flags);
