It's quite common to iterate over a directory recursively, only caring
about the file type, but not other bits returned by `stat()`.
Good file systems fill in `dt_type`, but not all do. This function
papers over that in userspace conveniently.
rpm-ostree is going through some awkwardness trying to
support being run both inside and outside of a container.
For now, let's drop all recursive container usage. There is still
some value in readding this in the future - for example, downloading
packages requires networking, but `%post` scripts do not. But we
should really solve that when we return to running unprivileged or the
like.
In Fedora rawhide, dracut switched from `/usr/sbin` to `/usr/bin`,
which broke rpm-ostree's hardcoding of the path.
There was no real reason to hardcode it (assume our `$PATH` is sane
and secure), so in order to help support that, this change in libglnx
will automatically search $PATH if the input is not absolute.
(This is a sane default for a process spawning library IMO)
It can be used without initialization if condition causing a "goto
error" fails before buf is initialized.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
There are some cases where we want to copy with just a filename,
so let's be convenient in that case and do stat for the caller.
This will be used by an ostree commit.
There are a lot of APIs that still only take absolute paths, such as
librpm (and everything above it). I plan to use this in rpm-ostree to
convert temporary directories that I'm accessing fd-relative back into
absolutes until such time as fd-relative APIs are plumbed through the
stack more.
Doing nothing isn't super useful; if you're using e.g. rpm-ostree in
Jenkins you want to see *something* from the "live tail".
This is a basic line-per-change implementation.
Closes: https://github.com/GNOME/libglnx/pull/6
For extra fun, both of these functions have different error handling
schemes. `posix_fallocate` does *not* set `errno` because... I'm not
sure. Maybe POSIX was trying a new function design?
`loop_write` uses the systemd error handling style which returns
`-errno`, so we need to set errno back so that the macro can propagate
it into the `GError`.
I looked at the systemd code but it didn't have a variant of
mkdir_parents that used `*at()`. This is a fresh implementation, with
the risk that entails.
However I am changing libgsystem to call it now for testing, and
libgsystem APIs are covered by ostree usage at least.
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.
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.