summaryrefslogtreecommitdiff
path: root/glnx-shutil.c
Commit message (Collapse)AuthorAgeFilesLines
* Declare copyright and licensing using REUSESimon McVittie2022-02-191-0/+1
| | | | | | | | | | | | | | To fill in some gaps, I've had to make some assumptions: * trivial changes (such as checking for an additional function or header file in libglnx.m4) are assumed to not be copyrightable * Will Thompson and Matthew Leeds are assumed to be contributing on behalf of Endless Mobile Inc. * files with no explicit licensing information are assumed to be under the license found in COPYING Reference: https://reuse.software/ Signed-off-by: Simon McVittie <smcv@debian.org>
* Include libglnx-config.h instead of config.hSimon McVittie2021-06-281-1/+1
| | | | | | | | | | | | | | | | | | | This avoids colliding with a config.h generated by a parent Meson project. In the Meson build system, we generate libglnx-config.h by doing our own checks, so we want to avoid it colliding. In the Autotools build system, we assume that the parent project will generate its own config.h that contains the results of LIBGLNX_CONFIGURE, and create a forwarding header libglnx-config.h in the $(top_builddir) (so that it is next to config.h). Note that after updating libglnx in an Autotools non-recursive-Make project (libostree, flatpak, flatpak-builder) it will be necessary to re-run autogen.sh. Signed-off-by: Simon McVittie <smcv@collabora.com>
* shutil: Prefix error with path in rm_rf()Colin Walters2018-12-071-16/+24
| | | | | | | | 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
* tree-wide: Some new style portingColin Walters2017-10-241-5/+4
| | | | Use decl-after-stmt where applicable.
* tree-wide: Use glnx_autofd and glnx_close_fd()Colin Walters2017-10-161-1/+1
| | | | | Port to `glnx_autofd` tree wide, and add one missed `glnx_close_fd()` use in the tmpfile code.
* shutil: Fix assertion failure in glnx_shutil_mkdir_p_at()Philip Withnall2017-09-261-1/+10
| | | | | | | | | | | | | | If the directory for @dfd is deleted after being opened, glnx_shutil_mkdir_p_at() would fail with an assertion failure. Fix that, and make it return an ENOENT error instead. Add a unit test. Signed-off-by: Philip Withnall <withnall@endlessm.com> Reviewed-by: Colin Walters <walters@verbum.org> Reviewed-by: Jonathan Lebon <jlebon@redhat.com> https://github.com/ostreedev/ostree/issues/1215
* dirfd: Add glnx_ensure_dir()Colin Walters2017-07-201-0/+2
| | | | | | | Another one where we have a lot of inlines in ostree at least. Not the same as `glnx_shutil_mkdir_p_at()` since in these cases we don't want automatic intermediate dirs, and it's cheaper to just call `mkdirat()` and handle `EEXIST` rather than do a `stat()` first.
* dirfd: Have dfd iter _take_fd() take a pointer and do a stealColin Walters2017-05-311-2/+1
| | | | | | | | | | | | | | This avoids callers having to use `glnx_steal_fd()` on their own; in general, I think we should implement move semantics like this at the callee level. Another reason to do this is there's a subtle problem with doing: ``` somefunction (steal_value (&v), ..., error); ``` in that if `somefunction` throws, it may not have taken ownership of the value. At least `glnx_dirfd_iterator_init_take_fd()` didn't.
* Port most code (except fdio) to new styleColin Walters2017-04-251-55/+21
| | | | There's a lot more fdio code, starting with some of the easier ones.
* glnx-shutil: Add glnx_shutil_mkdir_p_at_open()Philip Withnall2017-04-211-0/+37
| | | | | | | | | This is a variant of glnx_shutil_mkdir_p_at() which opens the given directory and returns a dirfd to it. Currently, the implementation cannot be race-free (due to a kernel bug), but it could eventually be made race-free. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* shutil: Use new API to iterate ensuring d_typeColin Walters2016-07-291-40/+1
| | | | This drops a lot of duplicate code.
* shutil: Drop unnecessary new block scopeColin Walters2015-04-081-5/+4
|
* shutil: Add mkdir -p APIColin Walters2015-04-071-0/+98
| | | | | | | | | 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.
* Add glnx_dirfd_canonicalize()Colin Walters2015-03-171-1/+3
| | | | We want to honor `-1 == AT_FDCWD`.
* Import directory iteration, errno handling, and shutil from libgsystemColin Walters2015-02-151-0/+188