All of lore.kernel.org
 help / color / mirror / Atom feed
From: Romain Naour <romain.naour@openwide.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/2] util-linux: define mkostemp for uClibc
Date: Sun, 06 Apr 2014 14:37:05 +0200	[thread overview]
Message-ID: <53414A71.5090404@openwide.fr> (raw)
In-Reply-To: <20140406114505.3446f546@skate>

Hi Thomas,

Le 06/04/2014 11:45, Thomas Petazzoni a ?crit :
> Dear Romain Naour,
>
> On Sun,  6 Apr 2014 11:29:13 +0200, Romain Naour wrote:
>
>> diff --git a/package/util-linux/util-linux-004-define-mkostemp-for-uClibc.patch b/package/util-linux/util-linux-004-define-mkostemp-for-uClibc.patch
>> new file mode 100644
>> index 0000000..7b49d37
>> --- /dev/null
>> +++ b/package/util-linux/util-linux-004-define-mkostemp-for-uClibc.patch
>> @@ -0,0 +1,29 @@
>> +From d339af8fdc4b28175d6986d870f6735a9c2e90a3 Mon Sep 17 00:00:00 2001
>> +From: Romain Naour <romain.naour@openwide.fr>
>> +Date: Sun, 6 Apr 2014 01:48:58 +0200
>> +Subject: [PATCH 1/1] c.h: define mkostemp for uClibc
>> +
>> +uclibc does not implement mkostemp GNU extension
>> +
>> +Signed-off-by: Romain Naour <romain.naour@openwide.fr>
>> +---
>> + include/c.h | 5 +++++
>> + 1 file changed, 5 insertions(+)
>> +
>> +diff --git a/include/c.h b/include/c.h
>> +index 4a9bf3d..3ba51c1 100644
>> +--- a/include/c.h
>> ++++ b/include/c.h
>> +@@ -300,4 +300,9 @@ static inline int usleep(useconds_t usec)
>> + # define SEEK_HOLE	4
>> + #endif
>> +
>> ++#ifdef __UCLIBC__
>> ++/* uclibc does not implement mkostemp GNU extension */
>> ++#define mkostemp(x,y) mkstemp(x)
>> ++#endif
> Thanks for the patch. However, I believe there are two problems here:
>
>   1/ mkostemp() *can* exist with uClibc: the master branch of uClibc,
>      which we use for some architectures (ARC and Xtensa) do have
>      mkostemp(). Therefore, there should instead be a test in
>      configure.ac like AC_CHECK_FUNCS([mkostemp]) and then make your
>      code conditional on #ifndef HAVE_MKOSTEMP.

Ok, I didn't notice that mkostemp() is available with latest uClibc, thanks.

>
>   2/ The other problem is that in util-linux, mkostemp is used as
>      follows:
>
>       fd = mkostemp(n, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC);
>
>      In your implementation, you discard the flags entirely, by using
>      mkstemp(). mkstemp() will pass O_RDWR|O_CREAT|O_EXCL, but not
>      O_CLOEXEC, which means that the file descriptor will no longer be
>      closed automatically upon exec(). Though, looking at
>      http://git.kernel.org/cgit/utils/util-linux/util-linux.git/commit/?id=b1fa3e2234fab95960eaa8499384000f189def13,
>      they have switched to using O_CLOEXEC with no specific reason.
>      Maybe I'm just worrying too much. But a solution might be to do
>      something like:
>
> #ifndef HAVE_MKOSTEMP
> static inline int mkostemp(char *template, int flags)
> {
> 	int fd;
> 	fd = mkstemp(template);
> 	if (flags & O_CLOEXEC && fd >= 0)
> 		fcntl(fd, F_SETFD, FD_CLOEXEC);
> 	return fd;
> }
> #endif
>
> (Completely untested, not even compiled)
>
> Don't know if we want to worry about this though.
>

I had a build failure with the toolchain used by the autobuilder:
ctng-i386-pentium4-uclibc.tar.bz2
That why I added this patch.

Patch is on the way.

Best regards,
Romain

  reply	other threads:[~2014-04-06 12:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-06  9:29 [Buildroot] [PATCH 1/2] util-linux: unshare: include libmount.h to provide missing MS_* defines Romain Naour
2014-04-06  9:29 ` [Buildroot] [PATCH 2/2] util-linux: define mkostemp for uClibc Romain Naour
2014-04-06  9:45   ` Thomas Petazzoni
2014-04-06 12:37     ` Romain Naour [this message]
2014-04-06 12:10 ` [Buildroot] [PATCH 1/2] util-linux: unshare: include libmount.h to provide missing MS_* defines Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53414A71.5090404@openwide.fr \
    --to=romain.naour@openwide.fr \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.