Commit Graph
220 Commits
Author SHA1 Message Date
Simon McVittie c8216c90ed backport-autocleanups: Hide autocleanups for types we don't have
If you're building on a really old GLib, you might not have GTask,
GSubprocess or g_markup_parse_context_unref(), among others. This gets
libglnx compiling (and apparently working) on GLib versions as old
as 2.32.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-11-11 18:32:06 +00:00
Simon McVittie 46ba6b4187 backports: Add a backport of g_clear_pointer()
This will be necessary if targeting GLib versions older than 2.34,
such as GLib 2.32 in Ubuntu 12.04 and the Steam Runtime.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-11-11 18:32:06 +00:00
Colin Walters 9d0711fe1d Merge branch 'testlib-automake' into 'master'
build-sys: Add libglnx-testlib.c to Automake

See merge request GNOME/libglnx!12
2019-11-04 23:29:00 +00:00
Colin Walters 1503eaaac3 build-sys: Add libglnx-testlib.c to Automake
It was introduced in a previous commit but only added to `meson.build`.
2019-11-04 22:22:16 +00:00
Colin Walters 23f43faeab Merge branch 'reopen-rdonly' into 'master'
fdio: Add glnx_tmpfile_reopen_rdonly()

See merge request GNOME/libglnx!11
2019-11-04 19:14:24 +00:00
Colin Walters 0cf0955acc fdio: Add glnx_tmpfile_reopen_rdonly()
For fs-verity.
2019-11-04 17:49:00 +00:00
Colin Walters 41ecc5441f Merge branch 'meson-older-compilers' into 'master'
Add Meson build system and Gitlab-CI

See merge request GNOME/libglnx!8
2019-10-11 11:57:33 +00:00
Colin Walters 2eeb8a7512 Merge branch 'anonymous-tmpfile-dir' into 'master'
Add glnx_open_anonymous_tmpfile_full() allowing you to specify the directory

See merge request GNOME/libglnx!10
2019-10-11 11:45:05 +00:00
Alexander Larsson e8233c6356 Add glnx_open_anonymous_tmpfile_full() allowing you to specify the directory
This is useful if you need the file to be on a particular filesystem.
In particular, flatpak wants this to make tempfiles on /tmp for things
we need to write during flatpak run, such as the libseccomp output fd.

We've had "flatpak run" stop working in low disk situations without this,
so its nice to be able to fix it.
2019-10-09 14:56:11 +02:00
Colin Walters 15c0646880 Merge branch 'us-temp-failure-retry' into 'master'
macros: Add TEMP_FAILURE_RETRY for musl

See merge request GNOME/libglnx!9
2019-09-17 09:24:39 +00:00
Alex Kiernan 460400c19c macros: Add TEMP_FAILURE_RETRY for musl
TEMP_FAILURE_RETRY is glibc specific, add a definition for musl.

See https://github.com/ostreedev/ostree/issues/731

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
2019-09-09 14:33:54 +01:00
Jonathan Lebon 8f34033b25 Merge branch 'uchar' into 'master'
missing: Remove unused <uchar.h>

See merge request GNOME/libglnx!6
2019-05-13 18:45:53 +00:00
Simon McVittie 4fca08e268 CI: Target a Fedora stable release
As suggested by @jlebon on libglnx!8.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-05-13 19:02:12 +01:00
Simon McVittie 738ee7ace3 Make the Meson build work on older compilers
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-05-10 16:53:15 +01:00
Simon McVittie 744bd1824f meson: Define HAVE_DECL_FOO to 0 if foo isn't declared
This matches what Autotools would do, and what our header is expecting.
It silences -Wundef.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-05-10 16:52:11 +01:00
Will Thompson 170b105b5f Add GitLab CI
This only uses Meson because it's not straightforward to do a standalone
build with the Autotools goop.
2019-05-02 19:14:50 +01:00
Simon McVittie 04c11c7390 Run the fdio test in its own temporary directory
The temporary directory will be deleted on success, but will remain
intact on failure.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-05-02 19:14:50 +01:00
Will Thompson 5920f9f3fc Document using this as a Meson subproject 2019-05-02 19:14:50 +01:00
Simon McVittie 80779a3dec missing: Remove unused <uchar.h>
This doesn't exist on some very old platforms. In the original file
in systemd, it was here for char32_t and char16_t, which we don't use.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-05-02 14:59:59 +01:00
Will Thompson 0f53dc35e4 Add meson.build files 2019-03-28 16:09:32 +00:00
Colin Walters e16bdc7ef9 Merge branch 'shutil-rm-rf-errprefix' into 'master'
shutil: Prefix error with path in rm_rf()

See merge request GNOME/libglnx!4
2018-12-07 15:07:45 +00:00
Colin Walters b1cb19b6b2 shutil: Prefix error with path in rm_rf()
First, let's ensure the filename is prefixed consistently.
Second, add the entrypoint as a prefix when recursing.

This is best practice to help debugging.  Motivated by
https://discussion.fedoraproject.org/t/boot-partition-of-silverblue-is-without-space/771/9
2018-12-07 14:55:11 +00:00
Colin Walters 1e9b30838e README: Update Contributing 2018-11-30 16:27:19 -05:00
Colin Walters 13e7b4fdc7 Merge branch 'replace-contents-umask' into 'master'
Fix docs for glnx_file_replace_contents()

See merge request GNOME/libglnx!3
2018-11-30 21:24:41 +00:00
Owen W. Taylor c2dbe1811b Fix docs for glnx_file_replace_contents()
The docs for `glnx_file_replace_contents[_with_perms]` say that the default mode
is 0666 - umask, but it's actually 0644. Because there's no thread-safe way of
finding out the current umask without grubbing around in /proc/self/status,
simply make the docs reflect reality.
2018-11-30 16:22:51 -05:00
Colin Walters 470af8763f Merge branch 'renameat2-stdio' into 'master'
libglnx.m4: Include stdio.h for renameat2

See merge request GNOME/libglnx!2
2018-07-13 13:00:20 +00:00
Colin Walters 7be25521cf libglnx.m4: Include stdio.h for renameat2
glibc added it upstream:
https://sourceware.org/git/?p=glibc.git;a=commit;h=d6da5cb6a8e0e8a9ce92b7d951a254cf325248d7

But we need the right header.
Ref: https://github.com/flatpak/flatpak/issues/1890
2018-07-11 14:56:32 -04:00
Philip Withnall e1a78cf2f5 Merge branch 'backport-autoptr-support' into 'master'
Add g_autoptr support for GAsyncResult,GMount,GVolumeMonitor

See merge request GNOME/libglnx!1
2018-05-29 09:28:38 +00:00
Matthew Leeds 00ad6ee739 Add g_autoptr support for GAsyncResult,GMount,GVolumeMonitor 2018-05-28 20:20:52 -07:00
Colin Walters 97b5c08d2f console: Drop newline on glnx_console_lock
This was inherited from some other code; perhaps the idea
was to ensure the console is in a consistent state before starting
a progress bar, but it causes extra newlines which is distracting.
2018-05-08 14:40:12 -07:00
Jonathan Lebon 03e16afa7f missing-syscalls: Use different name for copy_file_range
In glibc 2.27, a wrapper for `copy_file_range` was added[1]. The
function is now always defined, either using a userspace fallback or
just returning `ENOSYS` if the kernel doesn't support it. This throws
off our preprocessor conditionals. Work around this by just renaming our
implementation differently. This is similar to what systemd did[2].

Hit this when trying to build on F28, which rebased to glibc 2.27.

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=bad7a0c81f501fbbcc79af9eaa4b8254441c4a1f
[2] https://github.com/systemd/systemd/commit/5187dd2c403caf92d09f3491e41f1ceb3f10491f
2018-05-04 14:52:04 -04:00
Aurelien Jarno 0c82203cd4 Include sys/mman.h when checking for memfd_create
glibc 2.27 added support for memfd_create. Unfortunately flatpak-builder,
or rather the included libglnx library, also has such a function to
wrap the corresponding syscall. It correctly tries to detect it in
the configure script to disabled the wrapper in case glibc provides
it. However it doesn't work due to a missing include.

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=890722
2018-02-19 10:34:45 +01:00
Jonathan Lebon 6f1ee5db14 console: make stdout_is_tty() public
Share its static var goodness with clients. This will be used in
rpm-ostree from various places which sometimes do use a `GLnxConsole`
and sometimes don't, so it's more convenient to make it its own
function.
2018-01-10 17:58:14 +00:00
Colin Walters 96b1fd9578 console: Avoid rendering too quickly
For TTYs, it slows things down pointlessly. For non-TTYs like Jenkins jobs, it
creates a ton of output that obscures useful information.
2017-12-12 15:31:45 -05:00
Colin Walters 985ed1c861 console: Drop unused current_text/current_percent
The idea was clearly to avoid useless updates, but we never actually *set* these
values. Drop the code for now to avoid confusion, I'll reimplement this in a
better way.
2017-12-12 15:24:42 -05:00
Colin Walters bb7dd4dd08 console: Limit progress bar to 20 columns max
IMO, it looks bad to have a really big progress bar. I personally usually work
on a 27" monitor with maximized terminals.
2017-12-12 15:24:42 -05:00
Colin Walters a8f96bd5f7 console: Add an "n items" API
It's often really useful to see the counts, not just the percentage.
2017-12-12 15:24:42 -05:00
Colin Walters 31ef1961ec fdio: Include libgen.h again for dirname()
rpm-ostree at least uses `dirname()` and relied on the `#include <libgen.h>`
that we had previously.
2017-12-12 14:22:39 -05:00
Ray Strode 03b48a3934 fdio: implement glnx_basename from scratch
At the top of glnx-fdio.h there's this comment:

/* When we include libgen.h because we need
 * dirname() we immediately undefine
 * basename() since libgen.h defines it as
 * a macro to the XDG version which is really
 * broken. */

and then it does #undef basename to try to
gain access to non-default basename implementation.

The problem is that this trick doesn't work on
some systems:

./libglnx/glnx-fdio.h: In function 'glnx_basename':
./libglnx/glnx-fdio.h:46:11: error: 'basename'
undeclared (first use in this function)
   return (basename) (path);

Anyway, basename() is like 3 lines of code to
implement, so this commit just does that instead
of relying on glibc for it.
2017-11-14 10:05:23 -05:00
Will Thompson 016ea9168b errors: don't use 'static inline' on varargs functions
This caused GCC 6.3.0 -Winline to complain:

    ../../../ext/libglnx/glnx-errors.h:169:1: warning: function
        ‘glnx_throw_errno_prefix’ can never be inlined because it uses
        variable argument lists [-Winline]
     glnx_throw_errno_prefix (GError **error, const char *fmt, ...)
     ^~~~~~~~~~~~~~~~~~~~~~~
    ../../../ext/libglnx/glnx-errors.h:169:1: warning: inlining failed
        in call to ‘glnx_throw_errno_prefix’: function not inlinable
        [-Winline]
2017-11-02 17:14:06 +00:00
Colin Walters b36606b366 missing-syscall: #include config.h
Followup to previous commit; this helps me build libostree
with `-Werror=undef`.
2017-11-02 11:30:53 -04:00
Will Thompson 4577dc826a Add missing configure check for copy_file_range
Without this, including glnx-missing-syscall.h raises this warning:

    ../ext/libglnx/glnx-missing-syscall.h:121:6: warning: "HAVE_DECL_COPY_FILE_RANGE" is not defined [-Wundef]
     #if !HAVE_DECL_COPY_FILE_RANGE
          ^~~~~~~~~~~~~~~~~~~~~~~~~
2017-11-02 14:55:17 +00:00
Colin Walters d15a379007 tree-wide: Some new style porting
Use decl-after-stmt where applicable.
2017-10-24 08:43:26 -04:00
Colin Walters 771d7a01d1 tree-wide: Use glnx_autofd and glnx_close_fd()
Port to `glnx_autofd` tree wide, and add one missed `glnx_close_fd()` use in the
tmpfile code.
2017-10-16 18:06:53 -04:00
Colin Walters e627524af9 fdio: Avoid ?: syntax for fstatat_allow_noent()
`g-ir-scanner` is unaware of this GNUC extension and complains.
Saw that while building ostree.

While we're here, fix up a few other things:

 - Tell the compiler the stat buffer is unused (I didn't see
   a warning, just doing this on general principle)
 - Return from `glnx_throw_errno_prefix()` directly; we do
   preserve errno there, let's feel free to rely on it.
2017-10-11 17:07:54 -04:00
Jonathan Lebon b923a950af tests: drop unused variable 2017-10-11 20:03:12 +00:00
Jonathan Lebon 5362f6bc3f fdio: allow NULL for fstatat_allow_noent stbuf
Often, the caller doesn't actually care about the details of the stat
struct itself, but just whether the entry exists or not. It does work
to just pass `NULL` directly to glibc in a quick test, but given that
the argument is tagged as `__nonnull` and that the documentation does
not explicitly specify this is supported, let's do this safely.
2017-10-06 21:45:55 +00:00
Colin Walters 97cd6a6c1d Add glnx_fd_close() and glnx_autofd
I'd like to have the checks for `EBADF` as well as the
"assign to -1" in more places.  The cleanup function we
had for `glnx_fd_close` is actually what we want.

Let's rename the cleanup macro to `glnx_autofd` to better match
other autocleanups like `g_autofree`.

Then we can use `glnx_fd_close()` as a replacement for plain Unix `close()`. I
left the `glnx_close_fd` macro, but it's obviously confusing now with the
former. We'll eventually remove it.
2017-10-06 10:14:57 -04:00
Colin Walters dea16cd8be fdio: Squash compiler warning from previous commit
Oops.
2017-10-05 14:45:40 -04:00
Colin Walters b72906dbe0 fdio: Generate tmpname for RENAME_EXCHANGE fallback
I was using this in rpm-ostree and glanced at the code. This was clearly the
intent, but isn't a full fix. See code comments for more details.
2017-10-02 10:09:02 -04:00