From 1c926126cee3bbada71605de1fd4cbb5bca8523d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 26 Feb 2021 22:49:38 +0100 Subject: [PATCH] import: drop some now unused functions from import-common.c --- src/import/import-common.c | 51 -------------------------------------- src/import/import-common.h | 3 --- 2 files changed, 54 deletions(-) diff --git a/src/import/import-common.c b/src/import/import-common.c index 53aed6a514c..247f49a855a 100644 --- a/src/import/import-common.c +++ b/src/import/import-common.c @@ -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; diff --git a/src/import/import-common.h b/src/import/import-common.h index 36052a29522..97fc16d1b9d 100644 --- a/src/import/import-common.h +++ b/src/import/import-common.h @@ -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); -- 2.47.3