pengutronix / genimage

tool to generate multiple filesystem and flash images from a tree
GNU General Public License v2.0
308 stars 110 forks source link

Attempting to specify /root as a mountpoint fails #67

Closed thirtythreeforty closed 5 years ago

thirtythreeforty commented 5 years ago

I have tried to add a separate partition mounted at /root:

image roothome.ubifs {
    ubifs {
        max-size = 2M
    }
    flashtype = w25q64
    mountpoint = /root
}

This produces an error:

INFO: cmd: "mkdir -p "/.../buildroot/output/build/genimage.tmp"" (stderr):
INFO: cmd: "rm -rf "/.../buildroot/output/build/genimage.tmp"/*" (stderr):
INFO: cmd: "mkdir -p "/.../buildroot/output/images"" (stderr):
INFO: cmd: "mkdir -p "/.../buildroot/output/build/genimage.tmp"" (stderr):
INFO: cmd: "cp -a "/.../buildroot/output/target" "/.../buildroot/output/build/genimage.tmp/root"" (stderr):
INFO: cmd: "mv "/.../buildroot/output/build/genimage.tmp/root/root" "/.../buildroot/output/build/genimage.tmp/root"" (stderr):
mv: '/.../buildroot/output/build/genimage.tmp/root/root' and '/.../buildroot/output/build/genimage.tmp/root/root' are the same file
make: *** [Makefile:815: target-post-image] Error 1

It appears genimage is copying the various partitions into the same folder as the root filesystem, which is contained in a folder named "root." This conflicts with the mountpoint name.

I think the best way to fix this (and not just kick the can to some other more obscure name) is to add another directory alongside:

genimage.tmp/
    root/ <-- the existing root directory
    mountpoints/ <-- new
        root/ <-- the overlay
michaelolbrich commented 5 years ago

I think I'd prefer something like this:

genimage.tmp/
    root/ <-- the existing root directory
    mp-root/ <-- the overlay

Or any other prefix. The directory name is already generated anyways to flatten subdirectories, so this should be a very simple change in add_mountpoint().

thirtythreeforty commented 5 years ago

Yeah it wouldn't be too bad. I think an mp- prefix would work too... What would happen if I decided to add a mount point of /home/myuser? How would that look?

michaelolbrich commented 5 years ago

This is handled by path_sanitized(), so (with the proposed change) this will be genimage.tmp/mp-home-myuser/. In theory, there are still collisions possible (/home/myuser/ and /home-myuser/) but I don't think this is really a problem.

thirtythreeforty commented 5 years ago

Gotcha. Yes, collisions will be rare. And that "problem" (however serious you deem it) is orthogonal to this issue anyway.

So mp- sounds good. Would you like a PR, or would you prefer to make the change yourself?

michaelolbrich commented 5 years ago

A PR would be great.