diff options
author | Colin Walters <walters@verbum.org> | 2017-06-28 13:41:52 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-06-29 14:46:18 +0000 |
commit | 6f2ea23e8a96cf7dddadf0eae1b4f831db88d67f (patch) | |
tree | f3c472ab9e35f2029738d152f52f2763ceed878f /src/libostree/ostree-repo-static-delta-compilation.c | |
parent | 9d10bdfd0d90d6ea6a31bbd89243f3b23ff51e8d (diff) | |
download | ostree-6f2ea23e8a96cf7dddadf0eae1b4f831db88d67f.tar.gz |
libutil: Add a helper for O_TMPFILE + mmap()
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
Diffstat (limited to 'src/libostree/ostree-repo-static-delta-compilation.c')
-rw-r--r-- | src/libostree/ostree-repo-static-delta-compilation.c | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c index 8a1bb1d2..851f3fcb 100644 --- a/src/libostree/ostree-repo-static-delta-compilation.c +++ b/src/libostree/ostree-repo-static-delta-compilation.c @@ -437,31 +437,15 @@ get_unpacked_unlinked_content (OstreeRepo *repo, GCancellable *cancellable, GError **error) { - g_auto(GLnxTmpfile) tmpf = { 0, }; - g_autoptr(GBytes) ret_content = NULL; g_autoptr(GInputStream) istream = NULL; - g_autoptr(GOutputStream) out = NULL; - - if (!glnx_open_anonymous_tmpfile (O_RDWR | O_CLOEXEC, &tmpf, error)) - return FALSE; if (!ostree_repo_load_file (repo, checksum, &istream, NULL, NULL, cancellable, error)) return FALSE; - out = g_unix_output_stream_new (tmpf.fd, FALSE); - if (g_output_stream_splice (out, istream, G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, - cancellable, error) < 0) + *out_content = ot_map_anonymous_tmpfile_from_content (istream, cancellable, error); + if (!*out_content) return FALSE; - - { g_autoptr(GMappedFile) mfile = g_mapped_file_new_from_fd (tmpf.fd, FALSE, error); - if (!mfile) - return FALSE; - ret_content = g_mapped_file_get_bytes (mfile); - } - - if (out_content) - *out_content = g_steal_pointer (&ret_content); return TRUE; } |