output file cannot be in the UBIFS root directory check is not working quite well
Hi,
Consider the following sequence of commands:
cd ~
mkdir -p /tmp/wtf/wtf1
chmod u-r /tmp/wtf
mkfs.ubifs -m 4096 -e 516096 -c 4095 -d /tmp/wtf/wtf1 -o mytest.img
Error: output file cannot be in the UBIFS root directory
mytest.img is not inside /tmp/wtf/wtf1, but mkfs.ubifs fails because /tmp/wtf is not readable. It seems that implementation of in_path(..) in mkfs.ubifs.c is not quite correct to handle this type of situations.
If you are wondering, my /home is not readable, and this prevents me from building any ubifs image inside of /home/user.
Thanks in advance.
I think the fact that i created that example directories in /tmp is misleading. This is not a tmpfs problem.
I observe the same problem with any other directory (namely, with my /home, which is not reabable).
When one of the directories in "-d" hierarchy is not readable, mkfs.ubifs will fail all the time, thinking that the output file is located in UBIFS root directory.
Quoted 17 lines · kyak
Hi,
Consider the following sequence of commands:
cd ~
mkdir -p/tmp/wtf/wtf1
chmod u-r/tmp/wtf
mkfs.ubifs -m 4096 -e 516096 -c 4095 -d/tmp/wtf/wtf1-o mytest.img
Error: output file cannot be in the UBIFS root directorymytest.img is not inside
/tmp/wtf/wtf1, but mkfs.ubifs fails because/tmp/wtfis not readable. It seems that implementation ofin_path(..)inmkfs.ubifs.cis not quite correct to handle this type of situations.If you are wondering, my /home is not readable, and this prevents me from building any ubifs image inside of
/home/user.Thanks in advance.
Quoted 4 lines · kyak
I observe the same problem with any other directory (namely, with my /home, which is not reabable).
When one of the directories in "-d" hierarchy is not readable, mkfs.ubifs will fail all the time, thinking that the output file is located in UBIFS root directory.
I can agree with you that the error message looks wrong for this case, but what is the point of attempting to create a file system image from a directory tree which is not readable?
/Ricard
Quoted 28 lines · kyak
Quoted 16 lines
Hi,
Consider the following sequence of commands:
cd ~
mkdir -p/tmp/wtf/wtf1
chmod u-r/tmp/wtf
mkfs.ubifs -m 4096 -e 516096 -c 4095 -d/tmp/wtf/wtf1-o mytest.img
Error: output file cannot be in the UBIFS root directorymytest.img is not inside
/tmp/wtf/wtf1, but mkfs.ubifs fails because/tmp/wtfis not readable.
It seems that implementation ofin_path(..)inmkfs.ubifs.cis not quite correct to handle this type of situations.Quoted 5 lines
If you are wondering, my /home is not readable, and this prevents me from building any ubifs image inside of
/home/user.Thanks in advance.
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Signature · 3 lines
Ricard Wolf Wanderlöf ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30
If a directory is not readable it only means that you can't list its contents. But it doesn't mean that you can't list contents of directories below that directory.
Once again, here is a simple (my) use case. My /home is not readable (i can't list its contents), and this prevents me from building any ubifs image inside of /home/user (which is readable).
I really hope i made myself clear this time.
Quoted 46 lines · Ricard Wanderlof
Quoted 4 lines · kyak
I observe the same problem with any other directory (namely, with my /home, which is not reabable).
When one of the directories in "-d" hierarchy is not readable, mkfs.ubifs will fail all the time, thinking that the output file is located in UBIFS root directory.
I can agree with you that the error message looks wrong for this case, but what is the point of attempting to create a file system image from a directory tree which is not readable?
/Ricard
Quoted 28 lines · kyak
Quoted 16 lines
Hi,
Consider the following sequence of commands:
cd ~
mkdir -p/tmp/wtf/wtf1
chmod u-r/tmp/wtf
mkfs.ubifs -m 4096 -e 516096 -c 4095 -d/tmp/wtf/wtf1-o mytest.img
Error: output file cannot be in the UBIFS root directorymytest.img is not inside
/tmp/wtf/wtf1, but mkfs.ubifs fails because/tmp/wtfis not readable.
It seems that implementation ofin_path(..)inmkfs.ubifs.cis not quite correct to handle this type of situations.Quoted 5 lines
If you are wondering, my /home is not readable, and this prevents me from building any ubifs image inside of
/home/user.Thanks in advance.
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/Signature · 3 lines
Ricard Wolf Wanderlöf ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30
Quoted 9 lines · kyak
If a directory is not readable it only means that you can't list its contents. But it doesn't mean that you can't list contents of directories below that directory.
Once again, here is a simple (my) use case. My /home is not readable (i can't list its contents), and this prevents me from building any ubifs image inside of
/home/user(which is readable).I really hope i made myself clear this time.
Definitely. I see your point now. This must be a definite bug in in_path().
One problem though is that when in_path() traverses the tree upwards, and encounters a directory which it can't read it can't complete its job. On the other hand, it shouldn't have to do that, it really only needs to see that the output file is not below the top level of the input tree. Or am I missing a case here?
/Ricard
Signature · 3 lines
Ricard Wolf Wanderlöf ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30
Quoted 4 lines · Ricard Wanderlof
Definitely. I see your point now. This must be a definite bug in
in_path().One problem though is that when
in_path()traverses the tree upwards, and encounters a directory which it can't read it can't complete its job. On the other hand, it shouldn't have to do that, it really only needs to see that the output file is not below the top level of the input tree. Or am I missing a case here?
Yes, it only needs to check if the output file is above the top level
of the input tree. But I guess it's not that easy - first things that come into my mind are symbolic links and mount --bind.
Thanks Artem, your patch (http://lists.infradead.org/pipermail/linux-mtd/2012-October/044477.html) has fixed my problem as well.
Quoted 9 lines · kyak
Quoted 4 lines · Ricard Wanderlof
Definitely. I see your point now. This must be a definite bug in
in_path().One problem though is that when
in_path()traverses the tree upwards, and encounters a directory which it can't read it can't complete its job. On the other hand, it shouldn't have to do that, it really only needs to see that the output file is not below the top level of the input tree. Or am I missing a case here?Yes, it only needs to check if the output file is above the top level
of the input tree. But I guess it's not that easy - first things that come into my mind are symbolic links and mount --bind.
Quoted 3 lines · kyak
Thanks Artem, your patch
(http://lists.infradead.org/pipermail/linux-mtd/2012-October/044477.html)
has fixed my problem as well.
Good!
Quoted 3 lines
Quoted 3 lines
Yes, it only needs to check if the output file is above the top level of the input tree. But I guess it's not that easy - first things that come into my mind are symbolic links and mount --bind.
This patch should take care of symbolic links - realpath should resolve them. WRT bind-mounts - well, I consider this an unlikely case and it is not a big deal if we do not detect this. mkfs.ubifs will fail somewhere else, I guess, then.
But of course, I will not object if someone improves the check and submits a patch.
Signature · 2 lines
Best Regards, Artem Bityutskiy