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

[Xen-devel] [PATCH] tools/libxl: remove O_CLOEXEC in xl_cmdimpl.c

Hi all,
Some old linux kernel such as 2.6.18 which rhel5u5 natively used haven't 
defined O_CLOEXEC, so remove O_CLOEXEC in xl_cmdimpl.c

Signed-off-by: Yongjie Ren <yongjie.ren@xxxxxxxxx>

diff -r eca057e4475c tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri Jun 17 08:08:13 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Tue Jun 21 14:37:03 2011 +0800
@@ -199,11 +199,16 @@
     fl.l_whence = SEEK_SET;
     fl.l_start = 0;
     fl.l_len = 0;
-    fd_lock = open(lockfile, O_WRONLY|O_CREAT|O_CLOEXEC, S_IWUSR);
+    fd_lock = open(lockfile, O_WRONLY|O_CREAT, S_IWUSR);
     if (fd_lock < 0) {
         fprintf(stderr, "cannot open the lockfile %s errno=%d\n", lockfile, 
         return ERROR_FAIL;
+    if (fcntl(fd_lock, F_SETFD, FD_CLOEXEC) < 0) {
+        close(fd_lock);
+        fprintf(stderr, "cannot set cloexec to lockfile %s errno=%d\n", 
lockfile, errno);
+        return ERROR_FAIL;
+    }
     rc = fcntl(fd_lock, F_SETLKW, &fl);
     if (rc < 0 && errno == EINTR)

Best Regards,
     Yongjie Ren    (Jay)

-----Original Message-----
From: Ian Jackson [mailto:Ian.Jackson@xxxxxxxxxxxxx] 
Sent: Monday, June 20, 2011 10:29 PM
To: Vincent Hanquez; Ren, Yongjie
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-devel] make tools ERROR in latest xen-unstable.hg [and 1 more 

Ren, Yongjie writes ("[Xen-devel] make tools ERROR in latest xen-unstable.hg"):
> Hi all,
> In our test, xen-unstable build fails. When running 'make tools', I got the 
> following error. Do you have the same issue ? 
> xl_cmdimpl.c: In function 'acquire_lock':
> xl_cmdimpl.c:202: error: 'O_CLOEXEC' undeclared (first use in this function)
> xl_cmdimpl.c:202: error: (Each undeclared identifier is reported only once
> xl_cmdimpl.c:202: error: for each function it appears in.)

Thanks for the report.

Vincent Hanquez writes ("Re: [Xen-devel] make tools ERROR in latest 
> I'm not in a position to submit a patch right now, otherwise i would
> have done so already. So i expect someone else will do it; And the
> best scenario would be the reporter of the bug, that can actually
> test the fix to actually do it (specially with guided instructions
> on how to fix it).

Thanks for the diagnosis etc.  Quite so.

Yongjie Ren, would you care to propose such a patch ?  It shouldn't be
too hard.  Remove O_CLOEXEC and add a call to fcntl F_SETFD
FD_CLOEXEC; there's an example in libxl_bootloader.c.


Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.