import: drop some now unused functions from import-common.c
This commit is contained in:
@@ -23,57 +23,6 @@
|
||||
#include "tmpfile-util.h"
|
||||
#include "util.h"
|
||||
|
||||
int import_make_read_only_fd(int fd) {
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
/* First, let's make this a read-only subvolume if it refers
|
||||
* to a subvolume */
|
||||
r = btrfs_subvol_set_read_only_fd(fd, true);
|
||||
if (r >= 0)
|
||||
return 0;
|
||||
|
||||
if (!ERRNO_IS_NOT_SUPPORTED(r) && !IN_SET(r, -ENOTDIR, -EINVAL))
|
||||
return log_error_errno(r, "Failed to make subvolume read-only: %m");
|
||||
|
||||
/* This doesn't refer to a subvolume, or the file system isn't even btrfs. In that, case fall back to
|
||||
* chmod()ing */
|
||||
|
||||
r = fstat(fd, &st);
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "Failed to stat image: %m");
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
/* For directories set the immutable flag on the dir itself */
|
||||
|
||||
r = chattr_fd(fd, FS_IMMUTABLE_FL, FS_IMMUTABLE_FL, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set +i attribute on directory image: %m");
|
||||
|
||||
} else if (S_ISREG(st.st_mode)) {
|
||||
/* For regular files drop "w" flags */
|
||||
|
||||
if ((st.st_mode & 0222) != 0)
|
||||
if (fchmod(fd, st.st_mode & 07555) < 0)
|
||||
return log_error_errno(errno, "Failed to chmod() image: %m");
|
||||
} else
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EBADFD), "Image of unexpected type");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int import_make_read_only(const char *path) {
|
||||
_cleanup_close_ int fd = 1;
|
||||
|
||||
fd = open(path, O_RDONLY|O_NOCTTY|O_CLOEXEC);
|
||||
if (fd < 0)
|
||||
return log_error_errno(errno, "Failed to open %s: %m", path);
|
||||
|
||||
return import_make_read_only_fd(fd);
|
||||
}
|
||||
|
||||
int import_fork_tar_x(const char *path, pid_t *ret) {
|
||||
_cleanup_close_pair_ int pipefd[2] = { -1, -1 };
|
||||
bool use_selinux;
|
||||
|
||||
@@ -18,9 +18,6 @@ typedef enum ImportFlags {
|
||||
IMPORT_FLAGS_MASK_RAW = IMPORT_FORCE|IMPORT_READ_ONLY|IMPORT_CONVERT_QCOW2|IMPORT_DIRECT|IMPORT_SYNC,
|
||||
} ImportFlags;
|
||||
|
||||
int import_make_read_only_fd(int fd);
|
||||
int import_make_read_only(const char *path);
|
||||
|
||||
int import_fork_tar_c(const char *path, pid_t *ret);
|
||||
int import_fork_tar_x(const char *path, pid_t *ret);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user