On Sun, Aug 09, 2020 at 10:33:36AM +0300, Lars Wirzenius wrote: > On Sat, Jan 04, 2020 at 02:55:00AM -0800, Josh Triplett wrote: > vmdb2 depends on the kpartx package; could it, instead, use partx from > > the essential util-linux package? > > Speaking as upstream here: I had a look at partx, but I couldn't > figure out how to replace kpartx with it. If you can show me how to do > that, I'd be happy to make the changes to vmdb2 to use partx and to > drop the kpartx dependency.
partx and kpartx have very similar functionality, just different output. It looks like you're currently using kpartx to tell the kernel to add and delete partition devices; you're also parsing the output to see what device was created. kpartx output looks like this: add map loop0p1 (254:1): 0 10483679 linear 7:0 2048 And you're using the third word as the device name. partx (with the -v option) writes output like this: partition: none, disk: debian.img, lower: 0, upper: 0 Trying to use '/dev/loop0' for the loop device /dev/loop0: partition table type 'gpt' detected range recount: max partno=1, lower=0, upper=0 /dev/loop0: partition #1 added That's not quite as trivial to parse, but you could look for lines that match `^\(/dev/[^:]*\): partition #\([0-9]*\) added$`, and construct the device name as match 1 + "p" + match 2.