[libvirt] [PATCH] lxc: fix mknod file type

Hi, This patch fixes the 2nd argument of mknod syscall. The argument should include a file type, i.e., S_IFCHR in this case, otherwise created files will be regular files. Thanks, ozaki-r Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
From 60009b725da855f131e8272f0397455ae27bafc3 Mon Sep 17 00:00:00 2001 From: Ryota Ozaki <ozaki.ryota@gmail.com> Date: Wed, 6 May 2009 03:47:04 +0900 Subject: [PATCH] lxc: fix mknod file type
This patch fixes the 2nd argument of mknod syscall. The argument should include a file type, i.e., S_IFCHR in this case, otherwise created files will be regular files. --- src/lxc_container.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lxc_container.c b/src/lxc_container.c index 3946b84..c30daec 100644 --- a/src/lxc_container.c +++ b/src/lxc_container.c @@ -440,7 +440,7 @@ static int lxcContainerPopulateDevices(void) /* Populate /dev/ with a few important bits */ for (i = 0 ; i < ARRAY_CARDINALITY(devs) ; i++) { dev_t dev = makedev(devs[i].maj, devs[i].min); - if (mknod(devs[i].path, 0, dev) < 0 || + if (mknod(devs[i].path, S_IFCHR, dev) < 0 || chmod(devs[i].path, devs[i].mode)) { virReportSystemError(NULL, errno, _("failed to make device %s"), @@ -457,7 +457,7 @@ static int lxcContainerPopulateDevices(void) } } else { dev_t dev = makedev(LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX); - if (mknod("/dev/ptmx", 0, dev) < 0 || + if (mknod("/dev/ptmx", S_IFCHR, dev) < 0 || chmod("/dev/ptmx", 0666)) { virReportSystemError(NULL, errno, "%s", _("failed to make device /dev/ptmx")); -- 1.6.0.6

On Wed, May 06, 2009 at 04:01:32AM +0900, Ryota Ozaki wrote:
Hi,
This patch fixes the 2nd argument of mknod syscall. The argument should include a file type, i.e., S_IFCHR in this case, otherwise created files will be regular files.
Wierd. I guess no one has anything that uses this becasue current code is clearly useless / broken. ACK Daniel
From 60009b725da855f131e8272f0397455ae27bafc3 Mon Sep 17 00:00:00 2001 From: Ryota Ozaki <ozaki.ryota@gmail.com> Date: Wed, 6 May 2009 03:47:04 +0900 Subject: [PATCH] lxc: fix mknod file type
This patch fixes the 2nd argument of mknod syscall. The argument should include a file type, i.e., S_IFCHR in this case, otherwise created files will be regular files. --- src/lxc_container.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc_container.c b/src/lxc_container.c index 3946b84..c30daec 100644 --- a/src/lxc_container.c +++ b/src/lxc_container.c @@ -440,7 +440,7 @@ static int lxcContainerPopulateDevices(void) /* Populate /dev/ with a few important bits */ for (i = 0 ; i < ARRAY_CARDINALITY(devs) ; i++) { dev_t dev = makedev(devs[i].maj, devs[i].min); - if (mknod(devs[i].path, 0, dev) < 0 || + if (mknod(devs[i].path, S_IFCHR, dev) < 0 || chmod(devs[i].path, devs[i].mode)) { virReportSystemError(NULL, errno, _("failed to make device %s"), @@ -457,7 +457,7 @@ static int lxcContainerPopulateDevices(void) } } else { dev_t dev = makedev(LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX); - if (mknod("/dev/ptmx", 0, dev) < 0 || + if (mknod("/dev/ptmx", S_IFCHR, dev) < 0 || chmod("/dev/ptmx", 0666)) { virReportSystemError(NULL, errno, "%s", _("failed to make device /dev/ptmx")); -- 1.6.0.6
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Hi Daniel, On Wed, May 6, 2009 at 7:31 PM, Daniel P. Berrange <berrange@redhat.com> wrote:
On Wed, May 06, 2009 at 04:01:32AM +0900, Ryota Ozaki wrote:
Hi,
This patch fixes the 2nd argument of mknod syscall. The argument should include a file type, i.e., S_IFCHR in this case, otherwise created files will be regular files.
Wierd. I guess no one has anything that uses this becasue current code is clearly useless / broken.
I think so unfortunately ;< Actually lxc does not work in my system with cgroups enabled. lxc code probably remains some other bugs. Thanks, ozaki-r
ACK
Daniel
From 60009b725da855f131e8272f0397455ae27bafc3 Mon Sep 17 00:00:00 2001 From: Ryota Ozaki <ozaki.ryota@gmail.com> Date: Wed, 6 May 2009 03:47:04 +0900 Subject: [PATCH] lxc: fix mknod file type
This patch fixes the 2nd argument of mknod syscall. The argument should include a file type, i.e., S_IFCHR in this case, otherwise created files will be regular files. --- src/lxc_container.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc_container.c b/src/lxc_container.c index 3946b84..c30daec 100644 --- a/src/lxc_container.c +++ b/src/lxc_container.c @@ -440,7 +440,7 @@ static int lxcContainerPopulateDevices(void) /* Populate /dev/ with a few important bits */ for (i = 0 ; i < ARRAY_CARDINALITY(devs) ; i++) { dev_t dev = makedev(devs[i].maj, devs[i].min); - if (mknod(devs[i].path, 0, dev) < 0 || + if (mknod(devs[i].path, S_IFCHR, dev) < 0 || chmod(devs[i].path, devs[i].mode)) { virReportSystemError(NULL, errno, _("failed to make device %s"), @@ -457,7 +457,7 @@ static int lxcContainerPopulateDevices(void) } } else { dev_t dev = makedev(LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX); - if (mknod("/dev/ptmx", 0, dev) < 0 || + if (mknod("/dev/ptmx", S_IFCHR, dev) < 0 || chmod("/dev/ptmx", 0666)) { virReportSystemError(NULL, errno, "%s", _("failed to make device /dev/ptmx")); -- 1.6.0.6
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Hi, On Thu, May 7, 2009 at 7:39 AM, Ryota Ozaki <ozaki.ryota@gmail.com> wrote:
Hi Daniel,
On Wed, May 6, 2009 at 7:31 PM, Daniel P. Berrange <berrange@redhat.com> wrote:
On Wed, May 06, 2009 at 04:01:32AM +0900, Ryota Ozaki wrote:
Hi,
This patch fixes the 2nd argument of mknod syscall. The argument should include a file type, i.e., S_IFCHR in this case, otherwise created files will be regular files.
Wierd. I guess no one has anything that uses this becasue current code is clearly useless / broken.
I think so unfortunately ;< Actually lxc does not work in my system with cgroups enabled. lxc code probably remains some other bugs.
oops, I've found a bug in the previous patch. Please replace with the following patch. Thanks, ozaki-r
From c7feec6bb13833669ae4d04694d6c83f5a9fdd05 Mon Sep 17 00:00:00 2001 From: Ryota Ozaki <ozaki.ryota@gmail.com> Date: Thu, 7 May 2009 09:41:15 +0900 Subject: [PATCH] lxc: fix mknod file type
This patch fixes the 2nd argument of mknod syscall. The argument should include a file type, i.e., S_IFCHR in this case, otherwise created files will be regular files. --- src/lxc_container.c | 4 ++-- src/lxc_controller.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lxc_container.c b/src/lxc_container.c index 3946b84..c30daec 100644 --- a/src/lxc_container.c +++ b/src/lxc_container.c @@ -440,7 +440,7 @@ static int lxcContainerPopulateDevices(void) /* Populate /dev/ with a few important bits */ for (i = 0 ; i < ARRAY_CARDINALITY(devs) ; i++) { dev_t dev = makedev(devs[i].maj, devs[i].min); - if (mknod(devs[i].path, 0, dev) < 0 || + if (mknod(devs[i].path, S_IFCHR, dev) < 0 || chmod(devs[i].path, devs[i].mode)) { virReportSystemError(NULL, errno, _("failed to make device %s"), @@ -457,7 +457,7 @@ static int lxcContainerPopulateDevices(void) } } else { dev_t dev = makedev(LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX); - if (mknod("/dev/ptmx", 0, dev) < 0 || + if (mknod("/dev/ptmx", S_IFCHR, dev) < 0 || chmod("/dev/ptmx", 0666)) { virReportSystemError(NULL, errno, "%s", _("failed to make device /dev/ptmx")); diff --git a/src/lxc_controller.c b/src/lxc_controller.c index 3f9add2..a59053c 100644 --- a/src/lxc_controller.c +++ b/src/lxc_controller.c @@ -75,6 +75,7 @@ static int lxcSetContainerResources(virDomainDefPtr def) {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM}, {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM}, {'c', LXC_DEV_MAJ_TTY, LXC_DEV_MIN_CONSOLE}, + {'c', LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX}, {0, 0, 0}}; if (virCgroupHaveSupport() != 0) -- 1.6.0.6

On Thu, May 07, 2009 at 09:48:57AM +0900, Ryota Ozaki wrote:
Hi,
On Thu, May 7, 2009 at 7:39 AM, Ryota Ozaki <ozaki.ryota@gmail.com> wrote:
Hi Daniel,
On Wed, May 6, 2009 at 7:31 PM, Daniel P. Berrange <berrange@redhat.com> wrote:
On Wed, May 06, 2009 at 04:01:32AM +0900, Ryota Ozaki wrote:
Hi,
This patch fixes the 2nd argument of mknod syscall. The argument should include a file type, i.e., S_IFCHR in this case, otherwise created files will be regular files.
Wierd. I guess no one has anything that uses this becasue current code is clearly useless / broken.
I think so unfortunately ;< Actually lxc does not work in my system with cgroups enabled. lxc code probably remains some other bugs.
oops, I've found a bug in the previous patch. Please replace with the following patch.
Thanks, I've committed this patch now. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (2)
-
Daniel P. Berrange
-
Ryota Ozaki