]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
home: use open_image_file() helper at one more place 22746/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Mar 2022 07:01:23 +0000 (16:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Mar 2022 13:07:11 +0000 (22:07 +0900)
src/home/homework-luks.c

index a7e53013ed301c7575e6f0d68fcae7e4b9c27392..38164fadc341f46ba89b3090ab4dcc971078f2fc 100644 (file)
@@ -2200,12 +2200,10 @@ int home_create_luks(
 
                 /* Let's place the home directory on a real device, i.e. an USB stick or such */
 
-                setup->image_fd = open(ip, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
+                setup->image_fd = open_image_file(h, ip, &st);
                 if (setup->image_fd < 0)
-                        return log_error_errno(errno, "Failed to open device %s: %m", ip);
+                        return setup->image_fd;
 
-                if (fstat(setup->image_fd, &st) < 0)
-                        return log_error_errno(errno, "Failed to stat device %s: %m", ip);
                 if (!S_ISBLK(st.st_mode))
                         return log_error_errno(SYNTHETIC_ERRNO(ENOTBLK), "Device is not a block device, refusing.");