[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]