}
static int partition_populate_filesystem(Partition *p, const char *node, const Set *denylist) {
+ _cleanup_(loop_device_unrefp) LoopDevice *d = NULL;
+ struct stat st;
int r;
assert(p);
if (strv_isempty(p->copy_files) && strv_isempty(p->make_directories))
return 0;
+ if (stat(node, &st) < 0)
+ return log_error_errno(errno, "Failed to stat %s: %m", node);
+
+ if (!S_ISBLK(st.st_mode)) {
+ r = loop_device_make_by_path(node, O_RDWR, 0, LOCK_EX, &d);
+ if (r < 0)
+ return log_error_errno(r, "Failed to make loopback device of %s: %m", node);
+
+ node = d->node;
+ }
+
log_info("Populating partition %" PRIu64 " with files.", p->partno);
/* We copy in a child process, since we have to mount the fs for that, and we don't want that fs to