summaryrefslogtreecommitdiff
path: root/src/libotutil
Commit message (Collapse)AuthorAgeFilesLines
...
* lib/gpg: Switch to GLib autocleanups for gpgme typesColin Walters2017-08-022-5/+3
| | | | | | | | Prep for dropping `GLNX_DEFINE_CLEANUP_FUNCTION` from libglnx in favor of using GLib's `G_DEFINE_AUTO_CLEANUP_FREE_FUNC()`. Closes: #1042 Approved by: jlebon
* lib: Add a helper to convert struct stat → GFileInfoColin Walters2017-06-292-18/+0
| | | | | | | | | | | It's more natural for a few calling places. Prep for patches to go the other way, which in turn are prep for adding a commit filter v2 that takes `struct stat`. `ot_gfile_type_for_mode()` was only used in this function, so inline it here. Closes: #974 Approved by: jlebon
* libutil: Add a helper for O_TMPFILE + mmap()Colin Walters2017-06-292-0/+32
| | | | | | | | | | | | | I added `glnx_open_anonymous_tmpfile()`, but then later noticed that the usage of this was really to be combined with `mmap()`, and we had two versions of that in the delta code. Add a helper. (Bigger picture...how is this different from glibc's "mmap() of /dev/zero" approach for large chunks? One advantage is the storage can be "swapped" to `/var/tmp`, but still deleted automatically, rather than requiring swap space) Closes: #973 Approved by: jlebon
* Port to GLnxTmpfileColin Walters2017-06-272-83/+1
| | | | | | | | | | | | | | | | | | | | | There's lots of mechanically replacing `OtTmpFile` with `GLnxTmpfile`; the biggest changes are in the commit path. Symlink commits are now very clearly separated from regular files. Symlinks are `OtCleanupUnlinkat`, and regular files are `GLnxTmpfile`. The commit codepath separates those as `_ostree_repo_commit_path_final()` and `_ostree_repo_commit_tmpf_final()`. A nice aspect of all of this is that they both *consume* the temporary on success. This avoids an extra spurious `unlink()` call. One of the biggest bits of code motion is in `commit_loose_regfile_object()`, which no longer needs to care about symlinks. For the most parth though it's just removing conditionals. Update submodule: libglnx Closes: #958 Approved by: jlebon
* lib: Hoist unlinkat() cleanup API to fsutil, use in pullColin Walters2017-06-261-0/+28
| | | | | | | | | | | | | | | | The pull code also could make use of this in both the metadata and content paths. I changed it to own the tempfile malloc (just like `GLnxTmpFile`), since there's no reason to have different lifetimes for the filename and the file, and that way we only have one variable rather than two. The content path turns out to be a special case though, where at least for mirroring archives, we directly pass the file *path* down into `_ostree_repo_commit_loose_final()`. This is prep for `GLnxTmpFile` porting. Closes: #957 Approved by: jlebon
* lib/util: Some style conversionColin Walters2017-05-302-51/+13
| | | | | | | | I saw a few instances of `glnx_set_error_from_errno() + return FALSE`, and fixed them and did a bit of style conversion. Closes: #895 Approved by: jlebon
* tree-wide: Add+run spatch to use glnx_throw()Colin Walters2017-05-262-15/+5
| | | | | | | I had to run a sed job to add whitespace after, but otherwise this was easy. Closes: #890 Approved by: jlebon
* Add stub for new libglnx tmpfile API, port simpler callers to itColin Walters2017-05-232-0/+79
| | | | | | | | | | | | | It's hard right now to do a full port to the new libglnx tmpfile API since there are complex cases in the commit path which deal with symlinks as well. Let's make things more gradual by introducing the important part (struct with autocleanup) here in libotutil, port what we can. This will make a future complete port easier. Closes: #871 Approved by: jlebon
* lib: Add "open dfd iter handling noent" helper, port tree-wideColin Walters2017-05-162-0/+32
| | | | | | | | | Follow up to a previous patch that addressed a double-close; I realized we already had a helper for doing "open dfd iter, do nothing if we get ENOENT". Raise it to libotuil, and port all consumers. Closes: #863 Approved by: jlebon
* utils/checksum: Port to new code styleColin Walters2017-05-091-40/+18
| | | | | | | Just happened to be reading this code, it's an easy port. Closes: #842 Approved by: jlebon
* repo: Delete the last use of GFile tmp_dirColin Walters2017-05-012-6/+1
| | | | | | | | | | The keyring isn't large, so let's just fall back to copying it rather than requiring `renameat()`. Prep for `ostree_repo_open_at()`. Closes: #821 Approved by: jlebon
* lib/util: Delete some leftover pre-libglnx directory opening functionsColin Walters2017-04-252-33/+0
| | | | | | | These were migrated into libglnx; port the few callers to use that. Closes: #808 Approved by: jlebon
* repo: Optimize bare-user content object reads a bitColin Walters2017-04-192-79/+0
| | | | | | | | | | | | | | | | | | | `perf record ostree checkout ...` for a bare-user repo was telling me we were spending a good 13% of our time in the depchain of `ot_lgexattrat()`. The problem here is that traversing the `/proc` path turns out to be somewhat expensive - there are LSM (SELinux) checks, etc. For regular files, opening and just getting the xattr, then closing is still quite cheap. For symlinks, we'll always need to open anyways. This appears to shave about ~0.1 seconds off of a checkout of `fedora-atomic/25/x86_64/docker-host` on my workstation. Oh, and this was the last user of `ot_lgexattrat()` so we can kill it, which is nice - the xattr code should really live in libglnx. Closes: #796 Approved by: jlebon
* libutil: Delete some unused error handling APIsColin Walters2017-03-302-18/+0
| | | | | | | The first one is better as `err`, the second might as well just call `err` too. Closes: #767 Approved by: jlebon
* libutil: Delete some unused checksum helper APIColin Walters2017-03-302-53/+0
| | | | | | | | This code was last used in 9618232f4da325692dcf98fd6ff5b8abd9fce66c which is sooo old and outdated. Delete. Closes: #767 Approved by: jlebon
* libutil: Delete unused GVariant I/O functionsColin Walters2017-03-302-79/+0
| | | | | | | These are dead due to fd-relative porting probably. Closes: #767 Approved by: jlebon
* libutil: Delete unused threadpool wrapperColin Walters2017-03-303-83/+0
| | | | | | | | This is dead code since 9cc98041953090160dde48afa69b97c936541cdb where pull-local became just a wrapper for pull, which has its own threading. Closes: #767 Approved by: jlebon
* lib: Delete old unused GFile helpersColin Walters2017-03-302-155/+0
| | | | | | | This is all unused since the fd-relative/no-GFile porting. Delete delete delete! Closes: #767 Approved by: jlebon
* lib: Delete old GFile path helpers, and migrate single last userColin Walters2017-03-302-91/+0
| | | | | | | | | I happened to read this file and realized there's a lot of cruft left over from the time when I liked `GFile` and `malloc()`ing like 50 times just to make a pathname string. Delete it. Closes: #767 Approved by: jlebon
* sysroot/deploy: Some cleanup to decl-after-stmt/return FALSE styleColin Walters2017-03-202-0/+41
| | | | | | | | And fd-relative. I also introduced some helpers here which I'll use later in more invasive patches. Closes: #742 Approved by: jlebon
* core: Support building with OpenSSL for checksumsColin Walters2017-03-203-3/+87
| | | | | | | | | | | | | | | | | | | | | | | | | Add an OpenSSL backend to the checksum input stream, which is where we do a lot of checksumming (object commit, static deltas). The raw OpenSSL performance is [approximately double](https://gist.github.com/cgwalters/169349fd1c06fd4fb4d3a7ce33303222) on my laptop; not only does OpenSSL have e.g. hand-tuned x86_64 assembly, the current implementation uses the [Intel SHA extensions](https://en.wikipedia.org/wiki/Intel_SHA_extensions). Another reason to do this is I was idly thinking about adding [Curve25519](https://en.wikipedia.org/wiki/Curve25519) signatures (like e.g. Alpine does) instead of/in addition to GPG. The rationale for that is that GPG is pretty heavyweight, both in code footprint and the simple fact that EC keys are way smaller. I didn't benchmark ostree with this; we have bigger performance problems really like the fact we just malloc way too much. But, it's a step in the right direction I think in combination with the libcurl work where we're linking to openssl anyways. Closes: #738 Approved by: jlebon
* lib: Add a private copy of checksum-instreamColin Walters2017-03-203-0/+194
| | | | | | | | | | | | The current `OstreeChecksumInputStream` is public due to a historical mistake. I'd like to add an OpenSSL checksum backend, but that's harder without breaking this API. Let's ignore it and create a new private version, so it's easier to do the GLib/OpenSSL abstraction in one place. Closes: #738 Approved by: jlebon
* lib: Ensure an error is set in ensure_unlinked() if errno != ENOENTColin Walters2017-02-201-1/+4
| | | | | | | | | | | | | We hit this with: ``` 27411 unlink("/boot/efi/EFI/fedora/grub.cfg.new") = -1 EROFS (Read-only file system) ``` from the grub2 code. https://github.com/projectatomic/rpm-ostree/issues/633 Closes: #694 Approved by: giuseppe
* lib: Split out helper function to create GPG contextColin Walters2016-11-172-0/+36
| | | | | | | In prep for future work. Closes: #575 Approved by: giuseppe
* lib: Define and use cleanup functions for gpgmeColin Walters2016-11-171-0/+6
| | | | | | | Just a cleanup in preparation for future work. Closes: #575 Approved by: giuseppe
* Define an initializer for GVariant{Builder,Dict}Colin Walters2016-10-272-2/+8
| | | | | | | | So we build warning-free on GLib (< 2.50, >= 2.50). This is a band aid until we hard-require >= 2.50. Closes: #547 Approved by: jlebon
* otutil: Note that ot_log_structured takes a printf formatColin Walters2016-10-271-1/+1
| | | | | | | This notably fixes compilation with CLang. Closes: #548 Approved by: jlebon
* tree-wide: Remove unused variables detected by CLangColin Walters2016-10-271-3/+0
| | | | | | | | | | CLang finds these, whereas GCC treats having `__attribute__((cleanup))` as a use. This obsoletes https://github.com/ostreedev/ostree/pull/411 Closes: #548 Approved by: jlebon
* sysroot: Drop an unnecessary fsyncColin Walters2016-09-142-71/+0
| | | | | | | | | | | | | While looking at a slow update issue (which I'm guessing is unpredictable I/O latency in an OpenStack instance), I noticed in one of the traces we were inside a fsync here. Dropping the fsync here is just another of a long series of unwinding them - we `syncfs()` the sysroot fd and `/boot` and we have a big `sync()` anyways. Closes: #508 Approved by: jlebon
* sysroot: Port origin writing code to fd-relativeColin Walters2016-09-142-35/+0
| | | | | | | | Just preparatory cleanup for a next patch which makes the fsyncing configurable. Closes: #509 Approved by: giuseppe
* Final excision of libgsystem dependencyColin Walters2016-08-094-3/+46
| | | | | | | | | | | | | | Lots and lots of preparation led to this moment - when nothing apparent changes for users! Woo! But seriously, having the extra dependency is a minor annoyance, and in the big picture I think the libgsystem idea was wrong - we need to land things in GLib, and use git submodules for API-unstable or Linux-specific sharing. For a lot of OSTree, the libgsystem `GFile*` orientation was also wrong, we really want fd-relative. Closes: #444 Approved by: jlebon
* lib: Use libglnx file replace API more consistentlyColin Walters2016-08-041-88/+6
| | | | | | | | | | We have a better API now, drop use of the internal helper, which also depended on libgsystem. This required bumping libglnx to pull in a fix. Closes: #429 Approved by: giuseppe
* lib: Use g_file_enumerator_iterate() if available, with fallbackColin Walters2016-06-212-0/+74
| | | | | | | | | | | | Import `gs_file_enumerator_iterate()` for the next six months or so...after RHEL 7.3 is released I'm strongly considering hard requiring 2.46 or so. Likely at some point we should figure out how to share more "glib backport" code with NetworkManager at least. Closes: #341 Approved by: jlebon
* lib: Use sd_journal directly (optionally)Colin Walters2016-06-213-0/+195
| | | | | | | | | | | | | | This was the last caller of libgsystem that isn't `gs_file_get_path_cached()`. I think the use case ostree has where the same code can be called via command line and via a shared library *and* via a daemon is rather unusual, so let's just copy the code for logging from libgsystem into here. For example rpm-ostree hard depends on a daemon mode, so it'll just use `sd_journal` directly. Closes: #341 Approved by: jlebon
* lib: Port some manual close() cleanups to be glnx_fd_closeColin Walters2016-06-131-9/+3
| | | | | | | | | Just noticed this while reading some code, we didn't have many manual `out: close()` bits left, this pushes us over the edge to autocleanup almost everywhere. Closes: #332 Approved by: jlebon
* libotutil: Fix leak of VariantMapDataAlexander Larsson2016-06-101-0/+1
| | | | | Closes: #333 Approved by: giuseppe
* lib: Add a helper for mmap->bytes with openat(), use it in repoColin Walters2016-06-092-0/+25
| | | | | | | | | This kills another GSystem consumer...I think down the line I'd like to do something like "detect whether file is > 1k if so, mmap, otherwise just readall()" so we can use this helper in more places. Closes: #319 Approved by: jlebon
* lib: Add `_ALLOW_NOENT` flag to internal variant mapping APIColin Walters2016-06-092-5/+19
| | | | | | | | | | | | | | We have a lot of "allow_noent" type wrapper functions since a common pattern is to allow files to not exist, but still throw cleanly on other issues. This is another instance of that, and cleans up duplicated error handling code. Part of this is prep for moving away from `GFile` consumers. Closes: #319 Approved by: jlebon
* glnx porting: Drop last uses of gs_file_get_basename_cached()Colin Walters2016-06-091-2/+2
| | | | | | | I apparently missed a few uses in the previous porting. Closes: #319 Approved by: jlebon
* lib: Drop GFile variant mapping API for fd-relativeColin Walters2016-06-012-46/+0
| | | | | | | | | | | | | In addition to generic fd relative porting, this is a necessary preparatory step for libglnx porting, because when I tried to use `g_mapped_file_new` I hit an issue with it using a different error domain from GIO. Thankfully libglnx consistently uses the GIO error domain, and here we're now using it for the `open()` call. Closes: #317 Approved by: jlebon
* lib: Change ot_util_variant_map helpers to consistently sink refsColin Walters2016-06-011-3/+2
| | | | | | | | | | | | | | | This is similar to changes Krzesimir has been doing recently - we really don't need the ergonomics of floating refs since we have autocleanups. We should continue to change most of our code to sink refs. Specifically here it was pretty broken that the `_map()` API was sinking but the other two weren't, and this broke some refactoring I was trying to do later. Closes: #317 Approved by: jlebon
* libglnx porting: Port callers of gs_file_unlink to just unlink()Colin Walters2016-05-301-17/+4
| | | | | | | In the second case it's actually less code too. Closes: #312 Approved by: giuseppe
* libglnx porting: Port "load utf8 file" contents API callersColin Walters2016-05-301-1/+2
| | | | | Closes: #312 Approved by: giuseppe
* libotutil: Plug a leakKrzesimir Nowak2016-05-241-1/+4
| | | | | | | | There's no need to allocate the variant builder on a heap, so allocate it on the stack and avoid a memory leak at the same time. Closes: #307 Approved by: cgwalters
* small cleanupsJonathan Lebon2016-04-081-2/+2
| | | | | | | | | - Revert 'cannot' --> 'can not' (it's the exception!) - Remove duplicate function - Squelch compiler warnings Closes: #248 Approved by: cgwalters
* OstreeSePolicy: add ostree_sepolicy_get_csum()Jonathan Lebon2016-03-252-10/+11
| | | | | | | | | | This can be used as a fingerprint to determine whether two OstreeSePolicy objects are equivalent. Also add documentation for ostree_sepolicy_get_name(). Closes: #219 Approved by: cgwalters
* libglnx porting: Use glnx_opendirat()Colin Walters2016-03-231-3/+4
| | | | | This unfortunately adds *more* `gs_file_get_path_cached()`, but we'll fix that all in one go.
* libglnx porting: Use glnx_set_error_from_errnoColin Walters2016-03-233-12/+14
| | | | | | | | | :warning: There is a notable spiked pit trap here around `posix_fallocate()` and `errno`. This has bit other projects, see e.g. https://github.com/systemd/systemd/commit/7bb87460e691d30c1a7fd23a1a8240776957e05f Otherwise the port was straightforward.
* libotutil: new function ot_openat_ignore_enoentGiuseppe Scrivano2016-03-152-0/+30
| | | | | | Refactor some common code Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* gpg: Use gpg_strerror_r for threadsafetyColin Walters2016-02-221-2/+7
| | | | These APIs are rather painful...this is why GError exists.