All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: Max Filippov <jcmvbkbc@gmail.com>
Cc: buildroot <buildroot@buildroot.org>
Subject: Re: [Buildroot] package/coreutils mkfifo -m exit status
Date: Sun, 26 Dec 2021 12:23:51 +0100	[thread overview]
Message-ID: <20211226122351.425d0579@windsurf> (raw)
In-Reply-To: <CAMo8Bf+N5zOkAXgOGRYe4cJkBitactfuajB1SEoLLuwqZfCQ2g@mail.gmail.com>

Hello Max,

On Sun, 26 Dec 2021 01:51:47 -0800
Max Filippov <jcmvbkbc@gmail.com> wrote:

> I've noticed that when I run
> mkfifo -m 600 fifo-name
> from package/coreutils on a linux system it always indicates an error
> in the exit code.
> 
> Debugging showed that lchmod function call at
> https://github.com/coreutils/coreutils/blob/v9.0/src/mkfifo.c#L178
> returns error because when the package is configured with
> gl_cv_func_fstatat_zero_flag=no the following fstatat code in lchmod
> https://github.com/coreutils/gnulib/blob/9aca7b67333fd0a90bf56104325ce96199644451/lib/lchmod.c#L65
> always returns error with EINVAL in errno.
> 
> Removing gl_cv_func_fstatat_zero_flag=no from the package/coreutils
> config environment fixes that issue for me, but I couldn't find any
> explanation as to why it was added. I can send a patch if this
> is an acceptable fix, please let me know.

I took my extreme situation caving equipment, and went into the deep
dark cave of the gnulib code.

In the dark dark age of commit 531e3287a33c005edeeba10b0ab0910c6686e049
(https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=531e3287a33c005edeeba10b0ab0910c6686e049)
this gl_cv_func_fstatat_zero_flag was added to handle an obscure bug on
AIX 7.1, where fstatat() would return an error if the flags argument is
zero.

An AC_RUN_IFELSE() check was verifying this, and setting this
gl_cv_func_fstatat_zero_flag variable was necessary to make ./configure
pass. However setting it to "no" was a mistake, because it did imply
that yes fstatat() was broken with a zero flag, which was never the
case on Linux.

A bit later in commit c098d6b8a714de15c81ee72f86f9b7c268554682
(https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=c098d6b8a714de15c81ee72f86f9b7c268554682),
this logic was improved so that setting gl_cv_func_fstatat_zero_flag
was no longer needed when cross-compiling: it would automatically
assume the bug is present.

Further later, in commit 24a579b40979e51868e07b56ea307c1b2c12bcff
(https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=24a579b40979e51868e07b56ea307c1b2c12bcff),
this was improved even more to only assume that fstatat() was broken on
AIX systems when cross-compiling, making the right guess automatically.

So when we force gl_cv_func_fstatat_zero_flag=no in Buildroot today, we
prevent HAVE_WORKING_FSTATAT_ZERO_FLAG from being set.

So, clearly dropping gl_cv_func_fstatat_zero_flag=no from Buildroot's
coreutils.mk is the right thing to do.

However, I have not been able to understand why
gl_cv_func_fstatat_zero_flag=no makes fstatat() always return an error.
The code in lib/fstatat.c is convoluted, and even looking at its Git
history, I've not been able to spot what happened.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2021-12-26 11:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-26  9:51 [Buildroot] package/coreutils mkfifo -m exit status Max Filippov
2021-12-26 11:23 ` Thomas Petazzoni [this message]
2021-12-27  7:24   ` Max Filippov
2021-12-27  8:54     ` 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=20211226122351.425d0579@windsurf \
    --to=thomas.petazzoni@bootlin.com \
    --cc=buildroot@buildroot.org \
    --cc=jcmvbkbc@gmail.com \
    /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.