]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
import: drop some now unused functions from import-common.c 20420/head
authorLennart Poettering <lennart@poettering.net>
Fri, 26 Feb 2021 21:49:38 +0000 (22:49 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 17 Aug 2021 08:09:17 +0000 (10:09 +0200)
src/import/import-common.c
src/import/import-common.h

index 53aed6a514cc0bf7a516a85bc145c91b987bec2c..247f49a855aec19b4b939d83e1ff0394a85582a4 100644 (file)
 #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;
index 36052a295226104b78fb56921067e0265167f149..97fc16d1b9d32c2bf61e9602a155af0fa93c11f2 100644 (file)
@@ -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);