Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importd: fix build failure with missing O_TMPFILE (branch yem/o-tmpfile) #4052

Merged
merged 3 commits into from Aug 30, 2016
Merged

importd: fix build failure with missing O_TMPFILE (branch yem/o-tmpfile) #4052

merged 3 commits into from Aug 30, 2016

Conversation

yann-morin-1998
Copy link
Contributor

@yann-morin-1998 yann-morin-1998 commented Aug 28, 2016

Hello!

Here are two fixes to get importd build with older toolchains on all
architectures:

  • importd was not including missing.h to get fallback defines,
  • a fallback for O_TMPFILE was only provided on i386 and x86_64.

The solution for the second issue was to define O_TMPFILE for all
archs, using values defined in the kernel, rather than defining it only
for x86.

Additionally, basic/fileio was guarding out any use of O_TMPFILE,
because it was not including missing.h either. Doing so, we can drop
the guards around O_TMPFILE.

Regards,
Yann E. MORIN.

@@ -25,6 +25,7 @@
#include <libgen.h>
#undef basename

#include "missing.h"
#include "sd-daemon.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please place missing.h among the block of local includes, i.e. further down, and we try to keep them in alphabetical order.

(the sd-xyz.h headers are our public API, and we generally try to avoid importing local before public stuff)

@poettering
Copy link
Member

note we don't use Signed-of-by: in systemd, that's a kernel thing, see CODING_STYLE.

Patch looks okish, but please fix the few superficial issues I commented on, thanks!

@poettering poettering added the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Aug 29, 2016
O_TMPFILE may be missing from the system headers, so use our fallback
definition.

---
Changes v1 -> v2:
  - move include with local includes
Currently, a missing __O_TMPFILE was only defined for i386 and x86_64,
leaving any other architectures with an "old" toolchain fail miserably
at build time:
    src/import/export-raw.c: In function 'reflink_snapshot':
    src/import/export-raw.c:271:26: error: 'O_TMPFILE' undeclared (first use in this function)
             new_fd = open(d, O_TMPFILE|O_CLOEXEC|O_NOCTTY|O_RDWR, 0600);
                              ^

__O_TMPFILE (and O_TMPFILE) are available since glibc 2.19. However, a
lot of existing toolchains are still using glibc-2.18, and some even
before that, and it is not really possible to update those toolchains.

Instead of defining it only for i386 and x86_64, define __O_TMPFILE
with the specific values for those archs where it is different from the
generic value. Use the values as found in the Linux kernel (v4.8-rc3,
current as of time of commit).

---
Note: tested on ARM (build+run), with glibc-2.18 and linux headers 3.12.
Untested on other archs, though (I have no board to test this).

Changes v1 -> v2:
  - add a comment specifying some are hexa, others are octal.
fileio makes use of O_TMPFILE when it is available.

We now always have O_TMPFILE, defined in missing.h if missing
from the toolchain headers.

Have fileio include missing.h and drop the guards around the
use of O_TMPFILE.
@poettering poettering merged commit 4a13100 into systemd:master Aug 30, 2016
@yann-morin-1998
Copy link
Contributor Author

Thanks for merging! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks
Development

Successfully merging this pull request may close these issues.

None yet

2 participants