Commit Graph

236 Commits

Author SHA1 Message Date
Colin Walters
5ef78bb9d9 Merge branch 'err-prefix-xattr' into 'master'
xattrs: Add better error prefixing

See merge request GNOME/libglnx!19
2020-09-10 19:36:38 +00:00
Colin Walters
de5d2ec85c xattrs: Add better error prefixing
Related to
https://github.com/coreos/coreos-assembler/issues/1703

This should help debug things like this in the future.
2020-09-10 18:59:56 +00:00
Colin Walters
84b981a2ef Merge branch 'fix-wrpseudo-grammar' into 'master'
libglnx.m4: Fix grammar in help string

See merge request GNOME/libglnx!17
2020-06-16 20:08:21 +00:00
Colin Walters
cd5a57e8dd Merge branch 'pr/cfr-nfs' into 'master'
glnx-fdio: handle EOPNOTSUPP for copy_file_range

See merge request GNOME/libglnx!18
2020-06-16 19:55:25 +00:00
Jonathan Lebon
7e3a19958e glnx-fdio: handle EOPNOTSUPP for copy_file_range
When using `copy_file_range` to target a source and dest on the same NFS
mount on some older kernel versions, it's possible that we can get
`EOPNOTSUPP` e.g. if the NFS server doesn't support server-side copy.

We hit this in the FCOS release pipeline where we run `ostree
pull-local` to pull content between two repos on the same mount from
inside an OpenShift cluster on top of RHEL7.

Nowadays, it seems like the kernel itself falls back to a more generic
version of `copy_file_range()` at least. Though to be compatible with
older kernels, let's add `EOPNOTSUPP` to the list of errors we interpret
as "cfr possibly available, but can't be done for this specific
operation".
2020-06-16 14:42:13 -04:00
Matthew Leeds
3f38e98a39 libglnx.m4: Fix grammar in help string 2020-06-11 16:28:19 -07:00
Simon McVittie
3c285a7b3a Merge branch 'wip/smcv/const-struct-stat' into 'master'
fdio: Be const-correct for struct stat

See merge request GNOME/libglnx!16
2020-06-09 17:19:36 +00:00
Simon McVittie
dbed5c58db fdio: Be const-correct for struct stat
We don't modify this struct (if non-NULL), so it can be const. In
particular, this is helpful if calling glnx_file_copy_at() from
nftw() to implement the equivalent of `cp -a --reflink=auto`.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-03 17:51:19 +01:00
Simon McVittie
fc9073e7a8 Merge branch 'readme-libgsystem' into 'master'
README: update link to libgsystem

See merge request GNOME/libglnx!15
2020-06-03 16:47:49 +00:00
Simon McVittie
bf851fbe08 Merge branch 'auto-temp-dir-leak' into 'master'
_GLNX_TEST_SCOPED_TEMP_DIR: Fix memory and fd leak

See merge request GNOME/libglnx!14
2020-03-15 18:23:36 +00:00
Simon McVittie
c316e517ab Merge branch 'auto-temp-dir-unused' into 'master'
_GLNX_TEST_SCOPED_TEMP_DIR: Mark variable as G_GNUC_UNUSED

See merge request GNOME/libglnx!13
2020-03-15 18:23:19 +00:00
Will Thompson
70988f0287 README: update link to libgsystem
I was curious.
2019-12-02 16:00:36 +00:00
Simon McVittie
a652ede20b _GLNX_TEST_SCOPED_TEMP_DIR: Fix memory and fd leak
This doesn't really matter, since it only happens when our process is
about to exit anyway, but it makes it easier to use AddressSanitizer
and similar tools.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-11-11 19:29:28 +00:00
Simon McVittie
bc9c31f785 _GLNX_TEST_SCOPED_TEMP_DIR: Mark variable as G_GNUC_UNUSED
Otherwise, clang diagnoses it as unused. It is - deliberately - only
allocated and cleaned up, with no other use.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-11-11 18:37:38 +00:00
Simon McVittie
5f3d352aa4 Merge branch 'older-glibs' into 'master'
Build successfully on GLib 2.32

See merge request GNOME/libglnx!7
2019-11-11 18:36:08 +00:00
Simon McVittie
3063c69515 Make tests cope with older GLib
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-11-11 18:32:06 +00:00
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] 5187dd2c40
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