[OpenWrt-Devel] [PATCH fstools V3 1/2] Revert "block: mount_action: handle mount/umount deps"

Jo-Philipp Wich jo at mein.io
Thu Apr 2 08:35:58 EDT 2020


Hi Rafał,

instead of reverting the hierarchical mount handling, isn't fixing the
unintended mounts just a matter of doing a prefix compare during
vlist_for_first_to_element() traversal?

Assuming that `the_dev` refers to the block we do want to mount and `dev` is
the iterator pointing to each `dev` which is lexically ordered before
`the_dev`, would something like the below code suffice?

-- 8< --
size_t tlen = strlen(the_dev->m->target);

vlist_for_first_to_element(&devices, the_dev, dev, node) {
	if (dev->m && dev->m->type == TYPE_MOUNT) {
		/* skip this dev if its mount target path isn't a parent
		   directory of the_dev's target mount path. */
		size_t ilen = strlen(dev->m->target);
		if (ilen > tlen ||
		    strncmp(dev->m->target, the_dev->m->target, ilen) != 0 ||
		    (dev->m->target[ilen] != '/' &&
		     dev->m->target[ilen] != '\0'))
			continue;

		int err = mount_device(dev, type);
		if (err)
			return err;
	}
}
-- >8 --


~ Jo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20200402/f039f2c4/attachment.sig>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list