]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #24571 from yuwata/dissect-loop-image-use-backing-file
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 Sep 2022 14:45:29 +0000 (23:45 +0900)
committerGitHub <noreply@github.com>
Wed, 7 Sep 2022 14:45:29 +0000 (23:45 +0900)
dissect: save image path to LoopDevice and use it when dissect loop device

1  2 
src/shared/loop-util.c

index ba818d5371fc962d50a55493e38275edff207660,7a1b5ad2d394992d7c7b9d3cbcf202a7b8bd90ce..f380338554d27ba2b879d7e4b3e8d1ca49d3db16
@@@ -70,58 -71,10 +71,11 @@@ static int get_current_uevent_seqnum(ui
          return 0;
  }
  
- static int device_has_block_children(sd_device *d) {
-         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
-         const char *main_ss, *main_dt;
-         int r;
-         assert(d);
-         /* Checks if the specified device currently has block device children (i.e. partition block
-          * devices). */
-         r = sd_device_get_subsystem(d, &main_ss);
-         if (r < 0)
-                 return r;
-         if (!streq(main_ss, "block"))
-                 return -EINVAL;
-         r = sd_device_get_devtype(d, &main_dt);
-         if (r < 0)
-                 return r;
-         if (!streq(main_dt, "disk")) /* Refuse invocation on partition block device, insist on "whole" device */
-                 return -EINVAL;
-         r = sd_device_enumerator_new(&e);
-         if (r < 0)
-                 return r;
-         r = sd_device_enumerator_allow_uninitialized(e);
-         if (r < 0)
-                 return r;
-         r = sd_device_enumerator_add_match_parent(e, d);
-         if (r < 0)
-                 return r;
-         r = sd_device_enumerator_add_match_subsystem(e, "block", /* match = */ true);
-         if (r < 0)
-                 return r;
-         r = sd_device_enumerator_add_match_property(e, "DEVTYPE", "partition");
-         if (r < 0)
-                 return r;
-         return !!sd_device_enumerator_get_device_first(e);
- }
  static int open_lock_fd(int primary_fd, int operation) {
 -        int lock_fd;
 +        _cleanup_close_ int lock_fd = -1;
  
          assert(primary_fd >= 0);
 +        assert(IN_SET(operation & ~LOCK_NB, LOCK_SH, LOCK_EX));
  
          lock_fd = fd_reopen(primary_fd, O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
          if (lock_fd < 0)