- Jun 14, 2017
-
-
Colin Walters authored
I originally tried to get this into GLib: https://bugzilla.gnome.org/show_bug.cgi?id=783751 But that looks like it's going to fail due to MSVC. Let's add it here at least so I can start using it tomorrow and not wait for the MSVC team to catch up. I renamed `glnx-alloca.h` to `glnx-macros.h` as a more natural collective home for things from systemd's `macro.h`. Finally, I used a Coccinelle spatch similar to the one referenced in the above BZ to patch our uses.
-
- Jun 13, 2017
-
-
Colin Walters authored
The glibc `posix_fallocate()` implementation has a bad fallback, and further we need to handle `EOPNOTSUPP` for musl. https://github.com/flatpak/flatpak/issues/802
-
- May 19, 2017
-
-
Alexander Larsson authored
Add an `initialized` member which means we work by default in structs allocated with `g_new0` etc. and don't need a special initializer. This also fixes a bug where we need to support `src_dfd == -1` or `AT_FDCWD`. This fixes flatpak which uses AT_FDCWD. Modified-by:
Colin Walters <walters@verbum.org>
-
- May 15, 2017
-
-
Colin Walters authored
The core problem with the previous tmpfile code is we don't have an autocleanup that calls `unlinkat` in the non-`O_TMPFILE` case. And even if we did, it'd be awkward still since the `glnx_link_tmpfile_at()` call *consumes* the tmpfile. Fix this by introducing a struct with a cleanup macro. This simplifies a number of the callers in libostree - a notable case is where we had two arrays, one of fds, one of paths. It makes other places in libostree a bit more complex, but that's because some of the commit code paths want to deal with temporary *symlinks* too. Most callers are better though - in libglnx itself, `glnx_file_copy_at()` now correctly unlinks on failure for example.
-
- Apr 28, 2017
-
-
Colin Walters authored
NOTE: This changes the error handling API of `glnx_loop_write()` to be "old school POSIX" instead of "systemd". In ostree in a few places we use `g_output_stream_splice()`. I thought this would use `splice()`, but actually it doesn't today. They also, if a cancellable is provided, end up dropping into `poll()` for every read and write. (In addition to copying data to/from userspace). My opinion on this is - for *local files* that's dumb. In the big picture, you really only need cancellation when copying gigabytes. Down the line, we could perhaps add a `glnx_copy_bytes_cancellable()` that only did that check e.g. every gigabyte of copied data. And when we do that we should use `g_cancellable_set_error_if_cancelled()` rather than a `poll()` with the regular file FD, since regular files are *always* readable and writable. For my use case with rpm-ostree though, we don't have gigabyte sized files, and seeing all of the `poll()` calls in strace is annoying. So let's have the non-cancellable file copying API that's modern and uses both reflink and `sendfile()` if available, in that order. My plan at some point once this is tested more is to migrate this code into GLib. Note that in order to keep our APIs consistent, I switched the systemd-imported code to "old school POSIX" error conventions. Otherwise we'd have *3* (POSIX, systemd, and GError) and particularly given the first two are easily confused, it'd be a recipe for bugs.
-
- Apr 21, 2017
-
-
Philip Withnall authored
Add two inline wrappers around fstat() and fstatat() which handle retrying on EINTR and return other errors using GError, to be consistent with other glnx functions. Signed-off-by:
Philip Withnall <withnall@endlessm.com>
-
- Mar 02, 2017
-
-
Colin Walters authored
I want the `RENAME_EXCHANGE` version for rpm-ostree, to atomically swap `/usr/share/rpm` (a directory) with a new verison. While we're here we might as well expose `RENAME_NOREPLACE` in case something else wants it. These both have fallbacks to the non-atomic version. Closes: https://github.com/GNOME/libglnx/pull/36
-
- Oct 25, 2016
-
-
Colin Walters authored
I wanted to add a new one, and realized it was wrong. Luckily, I think we were safe until now, since the set of bits for `(0, 1, 2)` is actually distinct. Although, hm, callers specifying `GLNX_FILE_COPY_OVERWRITE` may have not actually been getting that.
-
- Jul 01, 2016
-
-
Colin Walters authored
We had a bug previously where we failed to clean up a temporary file in an error path. This is a classic case where the new `O_TMPFILE` API in Linux is nicer. To implement this, as usual we start with some original bits from systemd. But in this case I ended up having to heavily modify it because systemd doesn't support "link into place and overwrite". They don't actually use their tempfile code much at all in fact - as far as I can tell, just in the coredump code. Whereas in many apps, ostree included, a very common use case is atomically updating an existing file, which is `glnx_file_replace_contents_at()`, including subtleties like doing an `fdatasync()` if the file already existed. Implementing this then is slightly weird since we need to link() the file into place, then rename() after. It's still better though because if we e.g. hit `ENOSPC` halfway through, we'll clean up the file automatically. We still do keep the mode where we error out if the file exists. Finally, the ostree core though does have a more unusual case where we want to ignore EEXIST (allow concurrent object writers), so add support for that now. Note: One really confusing bug I had here was that `O_TMPFILE` ignores the provided mode, and this caused ostree to write refs that weren't world readable. Rework things so we always call `fchmod()`, but as a consequence we're no longer honoring umask in the default case. I doubt anyone will care, and if they do we should probably fix ostree to consistently use a mode inherited from the repo or something.
-
- May 03, 2016
-
-
Colin Walters authored
Migrated from libgsystem's `gs_stream_fstat()`. It's a small function but I end up using it in OSTree a fair bit.
-
- Jan 11, 2016
-
-
Colin Walters authored
I plan to use this in rpm-ostree. Sad how many times this gets reinvented. Should probably stick a copy in `glib-unix.h` or so.
-
- Apr 09, 2015
-
-
Colin Walters authored
This will be used for OSTree too.
-
Colin Walters authored
Sort of similar to `g_file_replace_contents()` but `*at()`. Will be used for further conversion of OSTree to `*at()`.
-
- Apr 07, 2015
-
-
Colin Walters authored
Most callers already included `string.h` which is why I didn't see this earlier.
-
- Apr 01, 2015
-
-
Colin Walters authored
See https://github.com/GNOME/ostree/pull/78
-
- Mar 05, 2015
-
-
Colin Walters authored
We have to wrap the glibc version to ensure we get the right version, otherwise depending on the variance of includes we may end up crashing if we get the POSIX version.
-
- Mar 03, 2015
-
-
Colin Walters authored
This will allow deleting some code from OSTree for the config file merging. We're reusing some code from systemd, which a nice modern clean codebase, and among other things this gets us BTRFS reflinking (if available) again.
-
- Feb 20, 2015
-
-
Colin Walters authored
We don't have this really in GLib, unfortunately. We do want GCancellable, but we also want to operate on raw fds where possible. The "read a file and validate as UTF-8" is a common use case of mine, and this combines that with openat().
-
- Feb 15, 2015
-
-
Colin Walters authored
-
- Feb 14, 2015
-
-
Colin Walters authored
This module is a new successor to libgsystem. It currently contains a backport of the GLib cleanup macros, but soon more Linux-specific code will be added.
-