diff mbox series

[kvmtool] init: fix sysfs mount arguments

Message ID 20190117114500.9702-1-dmonakhov@openvz.org (mailing list archive)
State New, archived
Headers show
Series [kvmtool] init: fix sysfs mount arguments | expand

Commit Message

Dmitry Monakhov Jan. 17, 2019, 11:45 a.m. UTC
From: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>

It is not good idea to pass empty 'source' argument to  mount(2) because libmount complains about
incorrect /proc/self/mountinfo structure. This affect many applications such as findmnt, umount and etc.
Let's add fake source argument to sysfs mount command as we do with all other filesystems.

#TESTCASE_BEGIN:
## findmount will complain like this 'findmnt: /proc/self/mountinfo: parse error at line 4 -- ignored'
echo "/bin/findmnt" > ./test.sh
./lkvm setup init-mount-test
./lkvm run -d init-mount-test --sandbox test.sh
rm -rf ~/.lkvm/init-mount-test
#TESTCASE_END
---
 guest/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Andre Przywara Jan. 28, 2019, 9:57 a.m. UTC | #1
On Thu, 17 Jan 2019 11:45:00 +0000
Dmitry Monakhov <dmonakhov@openvz.org> wrote:

Hi,

> From: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
> 
> It is not good idea to pass empty 'source' argument to  mount(2)
> because libmount complains about incorrect /proc/self/mountinfo
> structure. This affect many applications such as findmnt, umount and
> etc. Let's add fake source argument to sysfs mount command as we do
> with all other filesystems.

Yes, makes sense.

> #TESTCASE_BEGIN:
> ## findmount will complain like this 'findmnt: /proc/self/mountinfo:
> parse error at line 4 -- ignored' echo "/bin/findmnt" > ./test.sh
> ./lkvm setup init-mount-test
> ./lkvm run -d init-mount-test --sandbox test.sh
> rm -rf ~/.lkvm/init-mount-test
> #TESTCASE_END
> ---
>  guest/init.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/guest/init.c b/guest/init.c
> index 46e3fa4..22fe765 100644
> --- a/guest/init.c
> +++ b/guest/init.c
> @@ -32,8 +32,8 @@ static void do_mounts(void)
>  {
>  #ifndef CONFIG_GUEST_PRE_INIT
>  	mount("hostfs", "/host", "9p", MS_RDONLY,
> "trans=virtio,version=9p2000.L"); -#endif
> -	mount("", "/sys", "sysfs", 0, NULL);
> +#endif	

That adds a stray tab at the end of the line. The diff should just be
the mount line.

Otherwise:

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre.

> +	mount("sysfs", "/sys", "sysfs", 0, NULL);
>  	mount("proc", "/proc", "proc", 0, NULL);
>  	mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);
>  	mkdir("/dev/pts", 0755);
Will Deacon Feb. 1, 2019, 10:59 a.m. UTC | #2
Hi Dmitry,

On Thu, Jan 17, 2019 at 11:45:00AM +0000, Dmitry Monakhov wrote:
> From: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
> 
> It is not good idea to pass empty 'source' argument to  mount(2) because libmount complains about
> incorrect /proc/self/mountinfo structure. This affect many applications such as findmnt, umount and etc.
> Let's add fake source argument to sysfs mount command as we do with all other filesystems.
> 
> #TESTCASE_BEGIN:
> ## findmount will complain like this 'findmnt: /proc/self/mountinfo: parse error at line 4 -- ignored'
> echo "/bin/findmnt" > ./test.sh
> ./lkvm setup init-mount-test
> ./lkvm run -d init-mount-test --sandbox test.sh
> rm -rf ~/.lkvm/init-mount-test
> #TESTCASE_END
> ---
>  guest/init.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Please can I have your Signed-off-by so that I can merge this?

Thanks,

Will
Dmitry Monakhov Feb. 1, 2019, 2:25 p.m. UTC | #3
Will Deacon <will.deacon@arm.com> writes:

> Hi Dmitry,
>
> On Thu, Jan 17, 2019 at 11:45:00AM +0000, Dmitry Monakhov wrote:
>> From: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
>> 
>> It is not good idea to pass empty 'source' argument to  mount(2) because libmount complains about
>> incorrect /proc/self/mountinfo structure. This affect many applications such as findmnt, umount and etc.
>> Let's add fake source argument to sysfs mount command as we do with all other filesystems.
>> 
>> #TESTCASE_BEGIN:
>> ## findmount will complain like this 'findmnt: /proc/self/mountinfo: parse error at line 4 -- ignored'
>> echo "/bin/findmnt" > ./test.sh
>> ./lkvm setup init-mount-test
>> ./lkvm run -d init-mount-test --sandbox test.sh
>> rm -rf ~/.lkvm/init-mount-test
>> #TESTCASE_END
>> ---
>>  guest/init.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> Please can I have your Signed-off-by so that I can merge this?
Definitely yes. Thank you.
>
> Thanks,
>
> Will
diff mbox series

Patch

diff --git a/guest/init.c b/guest/init.c
index 46e3fa4..22fe765 100644
--- a/guest/init.c
+++ b/guest/init.c
@@ -32,8 +32,8 @@  static void do_mounts(void)
 {
 #ifndef CONFIG_GUEST_PRE_INIT
 	mount("hostfs", "/host", "9p", MS_RDONLY, "trans=virtio,version=9p2000.L");
-#endif
-	mount("", "/sys", "sysfs", 0, NULL);
+#endif	
+	mount("sysfs", "/sys", "sysfs", 0, NULL);
 	mount("proc", "/proc", "proc", 0, NULL);
 	mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);
 	mkdir("/dev/pts", 0755);