Updated version 2017.8 from 'upstream/2017.8'

with Debian dir 6a1618383e
This commit is contained in:
Simon McVittie 2017-07-18 22:18:13 +01:00
commit 54dc7ed473
158 changed files with 12692 additions and 2420 deletions

View File

@ -40,7 +40,12 @@ libostree_public_headers = \
if ENABLE_EXPERIMENTAL_API if ENABLE_EXPERIMENTAL_API
libostree_public_headers += \ libostree_public_headers += \
src/libostree/ostree-ref.h \
src/libostree/ostree-remote.h \ src/libostree/ostree-remote.h \
src/libostree/ostree-repo-finder.h \
src/libostree/ostree-repo-finder-avahi.h \
src/libostree/ostree-repo-finder-config.h \
src/libostree/ostree-repo-finder-mount.h \
$(NULL) $(NULL)
endif endif

View File

@ -94,6 +94,7 @@ libostree_1_la_SOURCES = \
src/libostree/ostree-linuxfsutil.c \ src/libostree/ostree-linuxfsutil.c \
src/libostree/ostree-diff.c \ src/libostree/ostree-diff.c \
src/libostree/ostree-mutable-tree.c \ src/libostree/ostree-mutable-tree.c \
src/libostree/ostree-ref.c \
src/libostree/ostree-remote.c \ src/libostree/ostree-remote.c \
src/libostree/ostree-remote-private.h \ src/libostree/ostree-remote-private.h \
src/libostree/ostree-repo.c \ src/libostree/ostree-repo.c \
@ -149,10 +150,32 @@ libostree_1_la_SOURCES += \
src/libostree/ostree-tls-cert-interaction.h \ src/libostree/ostree-tls-cert-interaction.h \
$(NULL) $(NULL)
endif endif
if !ENABLE_EXPERIMENTAL_API libostree_experimental_headers = \
libostree_1_la_SOURCES += \ src/libostree/ostree-ref.h \
src/libostree/ostree-remote.h \ src/libostree/ostree-remote.h \
src/libostree/ostree-repo-finder.h \
src/libostree/ostree-repo-finder-avahi.h \
src/libostree/ostree-repo-finder-config.h \
src/libostree/ostree-repo-finder-mount.h \
$(NULL) $(NULL)
if !ENABLE_EXPERIMENTAL_API
libostree_1_la_SOURCES += $(libostree_experimental_headers)
else # if ENABLE_EXPERIMENTAL_API
libostree_1_la_SOURCES += \
src/libostree/ostree-bloom.c \
src/libostree/ostree-bloom-private.h \
src/libostree/ostree-repo-finder.c \
src/libostree/ostree-repo-finder-avahi.c \
src/libostree/ostree-repo-finder-config.c \
src/libostree/ostree-repo-finder-mount.c \
$(NULL)
if USE_AVAHI
libostree_1_la_SOURCES += \
src/libostree/ostree-repo-finder-avahi-parser.c \
src/libostree/ostree-repo-finder-avahi-private.h \
$(NULL)
endif # USE_AVAHI
endif endif
symbol_files = $(top_srcdir)/src/libostree/libostree-released.sym symbol_files = $(top_srcdir)/src/libostree/libostree-released.sym
@ -180,6 +203,13 @@ libostree_1_la_CFLAGS += $(OT_DEP_LIBARCHIVE_CFLAGS)
libostree_1_la_LIBADD += $(OT_DEP_LIBARCHIVE_LIBS) libostree_1_la_LIBADD += $(OT_DEP_LIBARCHIVE_LIBS)
endif endif
if ENABLE_EXPERIMENTAL_API
if USE_AVAHI
libostree_1_la_CFLAGS += $(OT_DEP_AVAHI_CFLAGS)
libostree_1_la_LIBADD += $(OT_DEP_AVAHI_LIBS)
endif
endif
if BUILDOPT_LIBSYSTEMD if BUILDOPT_LIBSYSTEMD
libostree_1_la_CFLAGS += $(LIBSYSTEMD_CFLAGS) libostree_1_la_CFLAGS += $(LIBSYSTEMD_CFLAGS)
libostree_1_la_LIBADD += $(LIBSYSTEMD_LIBS) libostree_1_la_LIBADD += $(LIBSYSTEMD_LIBS)
@ -227,8 +257,8 @@ OSTree_1_0_gir_EXPORT_PACKAGES = ostree-1
OSTree_1_0_gir_INCLUDES = Gio-2.0 OSTree_1_0_gir_INCLUDES = Gio-2.0
OSTree_1_0_gir_CFLAGS = $(libostree_1_la_CFLAGS) OSTree_1_0_gir_CFLAGS = $(libostree_1_la_CFLAGS)
OSTree_1_0_gir_LIBS = libostree-1.la OSTree_1_0_gir_LIBS = libostree-1.la
OSTree_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=Ostree --symbol-prefix=ostree OSTree_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=Ostree --symbol-prefix=ostree $(GI_SCANNERFLAGS)
OSTree_1_0_gir_FILES = $(libostreeinclude_HEADERS) $(filter-out %-private.h %/ostree-soup-uri.h,$(libostree_1_la_SOURCES)) OSTree_1_0_gir_FILES = $(libostreeinclude_HEADERS) $(filter-out %-private.h %/ostree-soup-uri.h $(libostree_experimental_headers),$(libostree_1_la_SOURCES))
INTROSPECTION_GIRS += OSTree-1.0.gir INTROSPECTION_GIRS += OSTree-1.0.gir
gir_DATA += OSTree-1.0.gir gir_DATA += OSTree-1.0.gir
typelib_DATA += OSTree-1.0.typelib typelib_DATA += OSTree-1.0.typelib

View File

@ -32,6 +32,9 @@ ostree-remote.1 ostree-reset.1 ostree-rev-parse.1 ostree-show.1 \
ostree-summary.1 ostree-static-delta.1 ostree-summary.1 ostree-static-delta.1
if BUILDOPT_TRIVIAL_HTTPD if BUILDOPT_TRIVIAL_HTTPD
man1_files += ostree-trivial-httpd.1 man1_files += ostree-trivial-httpd.1
else
# We still want to distribute the source, even if we are not building it
EXTRA_DIST += man/ostree-trivial-httpd.xml
endif endif
if BUILDOPT_FUSE if BUILDOPT_FUSE

View File

@ -53,6 +53,10 @@ ostree_SOURCES = src/ostree/main.c \
src/ostree/parse-datetime.c \ src/ostree/parse-datetime.c \
$(NULL) $(NULL)
if ENABLE_EXPERIMENTAL_API
ostree_SOURCES += src/ostree/ot-builtin-find-remotes.c
endif
# Admin subcommand # Admin subcommand
ostree_SOURCES += \ ostree_SOURCES += \
src/ostree/ot-admin-builtin-init-fs.c \ src/ostree/ot-admin-builtin-init-fs.c \

View File

@ -67,7 +67,7 @@ _installed_or_uninstalled_test_scripts = \
tests/test-help.sh \ tests/test-help.sh \
tests/test-libarchive.sh \ tests/test-libarchive.sh \
tests/test-parent.sh \ tests/test-parent.sh \
tests/test-pull-archive-z.sh \ tests/test-pull-archive.sh \
tests/test-pull-commit-only.sh \ tests/test-pull-commit-only.sh \
tests/test-pull-depth.sh \ tests/test-pull-depth.sh \
tests/test-pull-mirror-summary.sh \ tests/test-pull-mirror-summary.sh \
@ -78,6 +78,7 @@ _installed_or_uninstalled_test_scripts = \
tests/test-pull-repeated.sh \ tests/test-pull-repeated.sh \
tests/test-pull-untrusted.sh \ tests/test-pull-untrusted.sh \
tests/test-pull-override-url.sh \ tests/test-pull-override-url.sh \
tests/test-pull-localcache.sh \
tests/test-local-pull.sh \ tests/test-local-pull.sh \
tests/test-local-pull-depth.sh \ tests/test-local-pull-depth.sh \
tests/test-gpg-signed-commit.sh \ tests/test-gpg-signed-commit.sh \
@ -108,9 +109,22 @@ _installed_or_uninstalled_test_scripts = \
tests/test-switchroot.sh \ tests/test-switchroot.sh \
tests/test-pull-contenturl.sh \ tests/test-pull-contenturl.sh \
tests/test-pull-mirrorlist.sh \ tests/test-pull-mirrorlist.sh \
tests/test-summary-update.sh \
tests/test-summary-view.sh \ tests/test-summary-view.sh \
$(NULL) $(NULL)
if ENABLE_EXPERIMENTAL_API
_installed_or_uninstalled_test_scripts += \
tests/test-find-remotes.sh \
tests/test-fsck-collections.sh \
tests/test-init-collections.sh \
tests/test-prune-collections.sh \
tests/test-refs-collections.sh \
tests/test-remote-add-collections.sh \
tests/test-summary-collections.sh \
$(NULL)
endif
if BUILDOPT_FUSE if BUILDOPT_FUSE
_installed_or_uninstalled_test_scripts += tests/test-rofiles-fuse.sh _installed_or_uninstalled_test_scripts += tests/test-rofiles-fuse.sh
else else
@ -193,6 +207,18 @@ _installed_or_uninstalled_test_programs = tests/test-varint tests/test-ot-unix-u
tests/test-gpg-verify-result tests/test-checksum tests/test-lzma tests/test-rollsum \ tests/test-gpg-verify-result tests/test-checksum tests/test-lzma tests/test-rollsum \
tests/test-basic-c tests/test-sysroot-c tests/test-pull-c tests/test-basic-c tests/test-sysroot-c tests/test-pull-c
if ENABLE_EXPERIMENTAL_API
test_programs += \
tests/test-bloom \
tests/test-repo-finder-config \
tests/test-repo-finder-mount \
$(NULL)
if USE_AVAHI
test_programs += tests/test-repo-finder-avahi
endif
endif
# An interactive tool # An interactive tool
noinst_PROGRAMS += tests/test-rollsum-cli noinst_PROGRAMS += tests/test-rollsum-cli
@ -204,7 +230,7 @@ common_tests_cflags = $(ostree_bin_shared_cflags) $(OT_INTERNAL_GIO_UNIX_CFLAGS)
common_tests_ldadd = $(ostree_bin_shared_ldadd) $(OT_INTERNAL_GIO_UNIX_LIBS) common_tests_ldadd = $(ostree_bin_shared_ldadd) $(OT_INTERNAL_GIO_UNIX_LIBS)
noinst_LTLIBRARIES += libostreetest.la noinst_LTLIBRARIES += libostreetest.la
libostreetest_la_SOURCES = tests/libostreetest.c libostreetest_la_SOURCES = tests/libostreetest.c tests/test-mock-gio.c tests/test-mock-gio.h
libostreetest_la_CFLAGS = $(common_tests_cflags) -I $(srcdir)/tests libostreetest_la_CFLAGS = $(common_tests_cflags) -I $(srcdir)/tests
libostreetest_la_LIBADD = $(common_tests_ldadd) libostreetest_la_LIBADD = $(common_tests_ldadd)
@ -219,6 +245,24 @@ tests_test_rollsum_SOURCES = src/libostree/ostree-rollsum.c tests/test-rollsum.c
tests_test_rollsum_CFLAGS = $(TESTS_CFLAGS) $(OT_DEP_ZLIB_CFLAGS) tests_test_rollsum_CFLAGS = $(TESTS_CFLAGS) $(OT_DEP_ZLIB_CFLAGS)
tests_test_rollsum_LDADD = $(bupsplitpath) $(TESTS_LDADD) $(OT_DEP_ZLIB_LIBS) tests_test_rollsum_LDADD = $(bupsplitpath) $(TESTS_LDADD) $(OT_DEP_ZLIB_LIBS)
tests_test_bloom_SOURCES = src/libostree/ostree-bloom.c tests/test-bloom.c
tests_test_bloom_CFLAGS = $(TESTS_CFLAGS)
tests_test_bloom_LDADD = $(TESTS_LDADD)
if USE_AVAHI
tests_test_repo_finder_avahi_SOURCES = src/libostree/ostree-repo-finder-avahi-parser.c tests/test-repo-finder-avahi.c
tests_test_repo_finder_avahi_CFLAGS = $(TESTS_CFLAGS)
tests_test_repo_finder_avahi_LDADD = $(TESTS_LDADD)
endif
tests_test_repo_finder_config_SOURCES = tests/test-repo-finder-config.c
tests_test_repo_finder_config_CFLAGS = $(TESTS_CFLAGS)
tests_test_repo_finder_config_LDADD = $(TESTS_LDADD)
tests_test_repo_finder_mount_SOURCES = tests/test-repo-finder-mount.c
tests_test_repo_finder_mount_CFLAGS = $(TESTS_CFLAGS)
tests_test_repo_finder_mount_LDADD = $(TESTS_LDADD)
tests_test_mutable_tree_CFLAGS = $(TESTS_CFLAGS) tests_test_mutable_tree_CFLAGS = $(TESTS_CFLAGS)
tests_test_mutable_tree_LDADD = $(TESTS_LDADD) tests_test_mutable_tree_LDADD = $(TESTS_LDADD)

View File

@ -29,7 +29,7 @@ AM_CPPFLAGS += -DDATADIR='"$(datadir)"' -DLIBEXECDIR='"$(libexecdir)"' \
-DOSTREE_COMPILATION \ -DOSTREE_COMPILATION \
-DG_LOG_DOMAIN=\"OSTree\" \ -DG_LOG_DOMAIN=\"OSTree\" \
-DOSTREE_GITREV='"$(OSTREE_GITREV)"' \ -DOSTREE_GITREV='"$(OSTREE_GITREV)"' \
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40 \ -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_50 \
-DSOUP_VERSION_MIN_REQUIRED=SOUP_VERSION_2_40 -DSOUP_VERSION_MAX_ALLOWED=SOUP_VERSION_2_48 -DSOUP_VERSION_MIN_REQUIRED=SOUP_VERSION_2_40 -DSOUP_VERSION_MAX_ALLOWED=SOUP_VERSION_2_48
AM_CFLAGS += -std=gnu99 $(WARN_CFLAGS) AM_CFLAGS += -std=gnu99 $(WARN_CFLAGS)
AM_DISTCHECK_CONFIGURE_FLAGS += \ AM_DISTCHECK_CONFIGURE_FLAGS += \

File diff suppressed because it is too large Load Diff

View File

@ -131,7 +131,12 @@ POST_UNINSTALL = :
build_triplet = @build@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
@ENABLE_EXPERIMENTAL_API_TRUE@am__append_1 = \ @ENABLE_EXPERIMENTAL_API_TRUE@am__append_1 = \
@ENABLE_EXPERIMENTAL_API_TRUE@ src/libostree/ostree-ref.h \
@ENABLE_EXPERIMENTAL_API_TRUE@ src/libostree/ostree-remote.h \ @ENABLE_EXPERIMENTAL_API_TRUE@ src/libostree/ostree-remote.h \
@ENABLE_EXPERIMENTAL_API_TRUE@ src/libostree/ostree-repo-finder.h \
@ENABLE_EXPERIMENTAL_API_TRUE@ src/libostree/ostree-repo-finder-avahi.h \
@ENABLE_EXPERIMENTAL_API_TRUE@ src/libostree/ostree-repo-finder-config.h \
@ENABLE_EXPERIMENTAL_API_TRUE@ src/libostree/ostree-repo-finder-mount.h \
@ENABLE_EXPERIMENTAL_API_TRUE@ $(NULL) @ENABLE_EXPERIMENTAL_API_TRUE@ $(NULL)
subdir = apidoc subdir = apidoc
@ -257,6 +262,8 @@ OBJEXT = @OBJEXT@
OSTREE_FEATURES = @OSTREE_FEATURES@ OSTREE_FEATURES = @OSTREE_FEATURES@
OTOOL = @OTOOL@ OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@ OTOOL64 = @OTOOL64@
OT_DEP_AVAHI_CFLAGS = @OT_DEP_AVAHI_CFLAGS@
OT_DEP_AVAHI_LIBS = @OT_DEP_AVAHI_LIBS@
OT_DEP_CURL_CFLAGS = @OT_DEP_CURL_CFLAGS@ OT_DEP_CURL_CFLAGS = @OT_DEP_CURL_CFLAGS@
OT_DEP_CURL_LIBS = @OT_DEP_CURL_LIBS@ OT_DEP_CURL_LIBS = @OT_DEP_CURL_LIBS@
OT_DEP_E2P_CFLAGS = @OT_DEP_E2P_CFLAGS@ OT_DEP_E2P_CFLAGS = @OT_DEP_E2P_CFLAGS@

View File

@ -14,7 +14,7 @@
<div class="titlepage"> <div class="titlepage">
<div> <div>
<div><table class="navigation" id="top" width="100%" cellpadding="2" cellspacing="0"><tr><th valign="middle"><p class="title">OSTree API references</p></th></tr></table></div> <div><table class="navigation" id="top" width="100%" cellpadding="2" cellspacing="0"><tr><th valign="middle"><p class="title">OSTree API references</p></th></tr></table></div>
<div><p class="releaseinfo">for OSTree 2017.7</p></div> <div><p class="releaseinfo">for OSTree 2017.8</p></div>
</div> </div>
<hr> <hr>
</div> </div>

View File

@ -1130,6 +1130,22 @@ filesystem and write content, possibly multiple times.</p>
<p>Once the <a class="link" href="ostree-In-memory-modifiable-filesystem-tree.html#OstreeMutableTree" title="OstreeMutableTree"><span class="type">OstreeMutableTree</span></a> is complete, write all of its metadata <p>Once the <a class="link" href="ostree-In-memory-modifiable-filesystem-tree.html#OstreeMutableTree" title="OstreeMutableTree"><span class="type">OstreeMutableTree</span></a> is complete, write all of its metadata
with <a class="link" href="ostree-Content-addressed-object-store.html#ostree-repo-write-mtree" title="ostree_repo_write_mtree ()"><code class="function">ostree_repo_write_mtree()</code></a>, and finally create a commit with with <a class="link" href="ostree-Content-addressed-object-store.html#ostree-repo-write-mtree" title="ostree_repo_write_mtree ()"><code class="function">ostree_repo_write_mtree()</code></a>, and finally create a commit with
<a class="link" href="ostree-Content-addressed-object-store.html#ostree-repo-write-commit" title="ostree_repo_write_commit ()"><code class="function">ostree_repo_write_commit()</code></a>.</p> <a class="link" href="ostree-Content-addressed-object-store.html#ostree-repo-write-commit" title="ostree_repo_write_commit ()"><code class="function">ostree_repo_write_commit()</code></a>.</p>
<div class="refsect3">
<a name="id-1.2.3.5.7"></a><h4>Collection IDs</h4>
<p>A collection ID is a globally unique identifier which, if set, is used to
identify refs from a repository which are mirrored elsewhere, such as in
mirror repositories or peer to peer networks.</p>
<p>This is separate from the <code class="literal">collection-id</code> configuration key for a remote, which
is used to store the collection ID of the repository that remote points to.</p>
<p>The collection ID should only be set on an <a class="link" href="ostree-Content-addressed-object-store.html#OstreeRepo" title="OstreeRepo"><span class="type">OstreeRepo</span></a> if it is the canonical
collection for some refs.</p>
<p>A collection ID must be a reverse DNS name, where the domain name is under the
control of the curator of the collection, so they can demonstrate ownership
of the collection. The later elements in the reverse DNS name can be used to
disambiguate between multiple collections from the same curator. For example,
<code class="literal">org.exampleos.Main</code> and <code class="literal">org.exampleos.Apps</code>. For the complete format of
collection IDs, see <code class="function">ostree_validate_collection_id()</code>.</p>
</div>
</div> </div>
<div class="refsect1"> <div class="refsect1">
<a name="ostree-Content-addressed-object-store.functions_details"></a><h2>Functions</h2> <a name="ostree-Content-addressed-object-store.functions_details"></a><h2>Functions</h2>
@ -6325,6 +6341,9 @@ ostree_repo_pull_with_options (<em class="parameter"><code><a class="link" href=
The following are currently defined:</p> The following are currently defined:</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>refs (as): Array of string refs</p></li> <li class="listitem"><p>refs (as): Array of string refs</p></li>
<li class="listitem"><p>collection-refs (a(sss)): Array of (collection ID, ref name, checksum) tuples to pull;
mutually exclusive with <code class="literal">refs</code> and <code class="literal">override-commit-ids</code>. Checksums may be the empty
string to pull the latest commit for that ref</p></li>
<li class="listitem"><p>flags (i): An instance of <a class="link" href="ostree-Content-addressed-object-store.html#OstreeRepoPullFlags" title="enum OstreeRepoPullFlags"><span class="type">OstreeRepoPullFlags</span></a></p></li> <li class="listitem"><p>flags (i): An instance of <a class="link" href="ostree-Content-addressed-object-store.html#OstreeRepoPullFlags" title="enum OstreeRepoPullFlags"><span class="type">OstreeRepoPullFlags</span></a></p></li>
<li class="listitem"><p>subdir (s): Pull just this subdirectory</p></li> <li class="listitem"><p>subdir (s): Pull just this subdirectory</p></li>
<li class="listitem"><p>subdirs (as): Pull just these subdirectories</p></li> <li class="listitem"><p>subdirs (as): Pull just these subdirectories</p></li>
@ -6340,6 +6359,7 @@ The following are currently defined:</p>
<li class="listitem"><p>inherit-transaction (b): Don't initiate, finish or abort a transaction, useful to do multiple pulls in one transaction.</p></li> <li class="listitem"><p>inherit-transaction (b): Don't initiate, finish or abort a transaction, useful to do multiple pulls in one transaction.</p></li>
<li class="listitem"><p>http-headers (a(ss)): Additional headers to add to all HTTP requests</p></li> <li class="listitem"><p>http-headers (a(ss)): Additional headers to add to all HTTP requests</p></li>
<li class="listitem"><p>update-frequency (u): Frequency to call the async progress callback in milliseconds, if any; only values higher than 0 are valid</p></li> <li class="listitem"><p>update-frequency (u): Frequency to call the async progress callback in milliseconds, if any; only values higher than 0 are valid</p></li>
<li class="listitem"><p>localcache-repos (as): File paths for local repos to use as caches when doing remote fetches</p></li>
</ul></div> </ul></div>
<div class="refsect3"> <div class="refsect3">
<a name="ostree-repo-pull-with-options.parameters"></a><h4>Parameters</h4> <a name="ostree-repo-pull-with-options.parameters"></a><h4>Parameters</h4>
@ -6537,7 +6557,7 @@ ostree_repo_add_gpg_signature_summary (<em class="parameter"><code><a class="lin
<em class="parameter"><code>const <a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *homedir</code></em>, <em class="parameter"><code>const <a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *homedir</code></em>,
<em class="parameter"><code><a href="https://developer.gnome.org/gio/unstable/GCancellable.html#GCancellable-struct"><span class="type">GCancellable</span></a> *cancellable</code></em>, <em class="parameter"><code><a href="https://developer.gnome.org/gio/unstable/GCancellable.html#GCancellable-struct"><span class="type">GCancellable</span></a> *cancellable</code></em>,
<em class="parameter"><code><a href="https://developer.gnome.org/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> <em class="parameter"><code><a href="https://developer.gnome.org/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>Add a GPG signature to a static delta.</p> <p>Add a GPG signature to a summary file.</p>
<div class="refsect3"> <div class="refsect3">
<a name="ostree-repo-add-gpg-signature-summary.parameters"></a><h4>Parameters</h4> <a name="ostree-repo-add-gpg-signature-summary.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0"> <div class="informaltable"><table class="informaltable" width="100%" border="0">
@ -6911,6 +6931,12 @@ regular, setting the <code class="literal">ostree.summary.expires</code> key in
will aid clients in working out when to check for updates.</p> will aid clients in working out when to check for updates.</p>
<p>It is regenerated automatically after a commit if <p>It is regenerated automatically after a commit if
<code class="literal">core/commit-update-summary</code> is set.</p> <code class="literal">core/commit-update-summary</code> is set.</p>
<p>If the <code class="literal">core/collection-id</code> key is set in the configuration, it will be
included as <code class="literal">OSTREE_SUMMARY_COLLECTION_ID</code> in the summary file. Refs from the
<code class="literal">refs/mirrors</code> directory will be included in the generated summary file,
listed under the <code class="literal">OSTREE_SUMMARY_COLLECTION_MAP</code> key. Collection IDs and refs
in <code class="literal">OSTREE_SUMMARY_COLLECTION_MAP</code> are guaranteed to be in lexicographic
order.</p>
<div class="refsect3"> <div class="refsect3">
<a name="ostree-repo-regenerate-summary.parameters"></a><h4>Parameters</h4> <a name="ostree-repo-regenerate-summary.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0"> <div class="informaltable"><table class="informaltable" width="100%" border="0">

View File

@ -175,6 +175,14 @@
<a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
</td> </td>
<td class="function_name"> <td class="function_name">
<a class="link" href="ostree-Core-repository-independent-functions.html#ostree-validate-remote-name" title="ostree_validate_remote_name ()">ostree_validate_remote_name</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="ostree-Core-repository-independent-functions.html#ostree-parse-refspec" title="ostree_parse_refspec ()">ostree_parse_refspec</a> <span class="c_punctuation">()</span> <a class="link" href="ostree-Core-repository-independent-functions.html#ostree-parse-refspec" title="ostree_parse_refspec ()">ostree_parse_refspec</a> <span class="c_punctuation">()</span>
</td> </td>
</tr> </tr>
@ -979,6 +987,41 @@ is a valid ref string</p>
</div> </div>
<hr> <hr>
<div class="refsect2"> <div class="refsect2">
<a name="ostree-validate-remote-name"></a><h3>ostree_validate_remote_name ()</h3>
<pre class="programlisting"><a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
ostree_validate_remote_name (<em class="parameter"><code>const <span class="type">char</span> *remote_name</code></em>,
<em class="parameter"><code><a href="https://developer.gnome.org/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<div class="refsect3">
<a name="ostree-validate-remote-name.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>remote_name</p></td>
<td class="parameter_description"><p>A remote name</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p>Error</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="ostree-validate-remote-name.returns"></a><h4>Returns</h4>
<p> <a href="https://developer.gnome.org/glib/unstable/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <em class="parameter"><code>remote_name</code></em>
is a valid remote name</p>
</div>
<p class="since">Since: 2017.8</p>
</div>
<hr>
<div class="refsect2">
<a name="ostree-parse-refspec"></a><h3>ostree_parse_refspec ()</h3> <a name="ostree-parse-refspec"></a><h3>ostree_parse_refspec ()</h3>
<pre class="programlisting"><a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <pre class="programlisting"><a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
ostree_parse_refspec (<em class="parameter"><code>const <span class="type">char</span> *refspec</code></em>, ostree_parse_refspec (<em class="parameter"><code>const <span class="type">char</span> *refspec</code></em>,

View File

@ -37,6 +37,7 @@
<keyword type="function" name="ostree_checksum_b64_inplace_to_bytes ()" link="ostree-Core-repository-independent-functions.html#ostree-checksum-b64-inplace-to-bytes"/> <keyword type="function" name="ostree_checksum_b64_inplace_to_bytes ()" link="ostree-Core-repository-independent-functions.html#ostree-checksum-b64-inplace-to-bytes"/>
<keyword type="function" name="ostree_cmp_checksum_bytes ()" link="ostree-Core-repository-independent-functions.html#ostree-cmp-checksum-bytes"/> <keyword type="function" name="ostree_cmp_checksum_bytes ()" link="ostree-Core-repository-independent-functions.html#ostree-cmp-checksum-bytes"/>
<keyword type="function" name="ostree_validate_rev ()" link="ostree-Core-repository-independent-functions.html#ostree-validate-rev"/> <keyword type="function" name="ostree_validate_rev ()" link="ostree-Core-repository-independent-functions.html#ostree-validate-rev"/>
<keyword type="function" name="ostree_validate_remote_name ()" link="ostree-Core-repository-independent-functions.html#ostree-validate-remote-name" since="2017.8"/>
<keyword type="function" name="ostree_parse_refspec ()" link="ostree-Core-repository-independent-functions.html#ostree-parse-refspec"/> <keyword type="function" name="ostree_parse_refspec ()" link="ostree-Core-repository-independent-functions.html#ostree-parse-refspec"/>
<keyword type="function" name="ostree_object_type_to_string ()" link="ostree-Core-repository-independent-functions.html#ostree-object-type-to-string"/> <keyword type="function" name="ostree_object_type_to_string ()" link="ostree-Core-repository-independent-functions.html#ostree-object-type-to-string"/>
<keyword type="function" name="ostree_object_type_from_string ()" link="ostree-Core-repository-independent-functions.html#ostree-object-type-from-string"/> <keyword type="function" name="ostree_object_type_from_string ()" link="ostree-Core-repository-independent-functions.html#ostree-object-type-from-string"/>

View File

@ -1481,6 +1481,10 @@ OSTREE_RELEASE_VERSION, macro in ostree-version
</dt> </dt>
<dd></dd> <dd></dd>
<dt> <dt>
<a class="link" href="ostree-Core-repository-independent-functions.html#ostree-validate-remote-name" title="ostree_validate_remote_name ()">ostree_validate_remote_name</a>, function in <a class="link" href="ostree-Core-repository-independent-functions.html" title="Core repository-independent functions">Core repository-independent functions</a>
</dt>
<dd></dd>
<dt>
<a class="link" href="ostree-Core-repository-independent-functions.html#ostree-validate-rev" title="ostree_validate_rev ()">ostree_validate_rev</a>, function in <a class="link" href="ostree-Core-repository-independent-functions.html" title="Core repository-independent functions">Core repository-independent functions</a> <a class="link" href="ostree-Core-repository-independent-functions.html#ostree-validate-rev" title="ostree_validate_rev ()">ostree_validate_rev</a>, function in <a class="link" href="ostree-Core-repository-independent-functions.html" title="Core repository-independent functions">Core repository-independent functions</a>
</dt> </dt>
<dd></dd> <dd></dd>

View File

@ -1,3 +1,18 @@
<SECTION>
<FILE>ostree-ref</FILE>
OstreeCollectionRef
ostree_collection_ref_new
ostree_collection_ref_dup
ostree_collection_ref_free
ostree_collection_ref_hash
ostree_collection_ref_equal
OstreeCollectionRefv
ostree_collection_ref_dupv
ostree_collection_ref_freev
<SUBSECTION Standard>
ostree_collection_ref_get_type
</SECTION>
<SECTION> <SECTION>
<FILE>ostree-remote</FILE> <FILE>ostree-remote</FILE>
OstreeRemote OstreeRemote
@ -5,3 +20,67 @@ ostree_remote_ref
ostree_remote_unref ostree_remote_unref
ostree_remote_get_name ostree_remote_get_name
</SECTION> </SECTION>
<SECTION>
<FILE>ostree-repo-experimental</FILE>
ostree_repo_find_remotes_async
ostree_repo_find_remotes_finish
ostree_repo_pull_from_remotes_async
ostree_repo_pull_from_remotes_finish
ostree_repo_resolve_keyring_for_collection
</SECTION>
<SECTION>
<FILE>ostree-repo-finder</FILE>
OstreeRepoFinder
ostree_repo_finder_resolve_async
ostree_repo_finder_resolve_finish
ostree_repo_finder_resolve_all_async
ostree_repo_finder_resolve_all_finish
OstreeRepoFinderResult
ostree_repo_finder_result_new
ostree_repo_finder_result_dup
ostree_repo_finder_result_free
ostree_repo_finder_result_compare
OstreeRepoFinderResultv
ostree_repo_finder_result_freev
<SUBSECTION Standard>
ostree_repo_finder_get_type
ostree_repo_finder_result_get_type
</SECTION>
<SECTION>
<FILE>ostree-repo-finder-avahi</FILE>
OstreeRepoFinderAvahi
ostree_repo_finder_avahi_new
ostree_repo_finder_avahi_start
ostree_repo_finder_avahi_stop
<SUBSECTION Standard>
ostree_repo_finder_avahi_get_type
</SECTION>
<SECTION>
<FILE>ostree-repo-finder-config</FILE>
OstreeRepoFinderConfig
ostree_repo_finder_config_new
<SUBSECTION Standard>
ostree_repo_finder_config_get_type
</SECTION>
<SECTION>
<FILE>ostree-repo-finder-mount</FILE>
OstreeRepoFinderMount
ostree_repo_finder_mount_new
<SUBSECTION Standard>
ostree_repo_finder_mount_get_type
</SECTION>
<SECTION>
<FILE>ostree-misc-experimental</FILE>
ostree_repo_get_collection_id
ostree_repo_set_collection_id
ostree_validate_collection_id
ostree_repo_list_collection_refs
ostree_repo_set_collection_ref_immediate
ostree_repo_transaction_set_collection_ref
</SECTION>

View File

@ -118,6 +118,7 @@ ostree_checksum_b64_inplace_from_bytes
ostree_checksum_b64_inplace_to_bytes ostree_checksum_b64_inplace_to_bytes
ostree_cmp_checksum_bytes ostree_cmp_checksum_bytes
ostree_validate_rev ostree_validate_rev
ostree_validate_remote_name
ostree_parse_refspec ostree_parse_refspec
ostree_object_type_to_string ostree_object_type_to_string
ostree_object_type_from_string ostree_object_type_from_string

View File

@ -1,7 +1,9 @@
ostree_async_progress_get_type ostree_async_progress_get_type
ostree_bloom_get_type
ostree_bootconfig_parser_get_type ostree_bootconfig_parser_get_type
ostree_chain_input_stream_get_type ostree_chain_input_stream_get_type
ostree_checksum_input_stream_get_type ostree_checksum_input_stream_get_type
ostree_collection_ref_get_type
ostree_deployment_get_type ostree_deployment_get_type
ostree_diff_item_get_type ostree_diff_item_get_type
ostree_gpg_verify_result_get_type ostree_gpg_verify_result_get_type
@ -10,6 +12,11 @@ ostree_remote_get_type
ostree_repo_commit_modifier_get_type ostree_repo_commit_modifier_get_type
ostree_repo_devino_cache_get_type ostree_repo_devino_cache_get_type
ostree_repo_file_get_type ostree_repo_file_get_type
ostree_repo_finder_avahi_get_type
ostree_repo_finder_config_get_type
ostree_repo_finder_get_type
ostree_repo_finder_mount_get_type
ostree_repo_finder_result_get_type
ostree_repo_get_type ostree_repo_get_type
ostree_repo_transaction_stats_get_type ostree_repo_transaction_stats_get_type
ostree_sepolicy_get_type ostree_sepolicy_get_type

View File

@ -1 +1 @@
2017.7 2017.8

View File

@ -3,6 +3,9 @@
/* Define if we are enabling ostree trivial-httpd entrypoint */ /* Define if we are enabling ostree trivial-httpd entrypoint */
#undef BUILDOPT_ENABLE_TRIVIAL_HTTPD_CMDLINE #undef BUILDOPT_ENABLE_TRIVIAL_HTTPD_CMDLINE
/* Define if doing a development build */
#undef BUILDOPT_IS_DEVEL_BUILD
/* Define if systemd and libmount */ /* Define if systemd and libmount */
#undef BUILDOPT_LIBSYSTEMD_AND_LIBMOUNT #undef BUILDOPT_LIBSYSTEMD_AND_LIBMOUNT
@ -18,6 +21,9 @@
/* Define to 1 if you have the `archive_read_support_filter_all' function. */ /* Define to 1 if you have the `archive_read_support_filter_all' function. */
#undef HAVE_ARCHIVE_READ_SUPPORT_FILTER_ALL #undef HAVE_ARCHIVE_READ_SUPPORT_FILTER_ALL
/* Define if we have avahi-client.pc and avahi-glib.pc */
#undef HAVE_AVAHI
/* Define to 1 if you have the declaration of `', and to 0 if you don't. */ /* Define to 1 if you have the declaration of `', and to 0 if you don't. */
#undef HAVE_DECL_ #undef HAVE_DECL_

195
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for libostree 2017.7. # Generated by GNU Autoconf 2.69 for libostree 2017.8.
# #
# Report bugs to <walters@verbum.org>. # Report bugs to <walters@verbum.org>.
# #
@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='libostree' PACKAGE_NAME='libostree'
PACKAGE_TARNAME='libostree' PACKAGE_TARNAME='libostree'
PACKAGE_VERSION='2017.7' PACKAGE_VERSION='2017.8'
PACKAGE_STRING='libostree 2017.7' PACKAGE_STRING='libostree 2017.8'
PACKAGE_BUGREPORT='walters@verbum.org' PACKAGE_BUGREPORT='walters@verbum.org'
PACKAGE_URL='' PACKAGE_URL=''
@ -672,6 +672,10 @@ USE_LIBMOUNT_FALSE
USE_LIBMOUNT_TRUE USE_LIBMOUNT_TRUE
OT_DEP_LIBMOUNT_LIBS OT_DEP_LIBMOUNT_LIBS
OT_DEP_LIBMOUNT_CFLAGS OT_DEP_LIBMOUNT_CFLAGS
USE_AVAHI_FALSE
USE_AVAHI_TRUE
OT_DEP_AVAHI_LIBS
OT_DEP_AVAHI_CFLAGS
USE_OPENSSL_FALSE USE_OPENSSL_FALSE
USE_OPENSSL_TRUE USE_OPENSSL_TRUE
OT_DEP_OPENSSL_LIBS OT_DEP_OPENSSL_LIBS
@ -932,6 +936,7 @@ with_libarchive
with_selinux with_selinux
with_smack with_smack
with_openssl with_openssl
with_avahi
with_libmount with_libmount
enable_rofiles_fuse enable_rofiles_fuse
with_dracut with_dracut
@ -980,6 +985,8 @@ OT_DEP_SELINUX_CFLAGS
OT_DEP_SELINUX_LIBS OT_DEP_SELINUX_LIBS
OT_DEP_OPENSSL_CFLAGS OT_DEP_OPENSSL_CFLAGS
OT_DEP_OPENSSL_LIBS OT_DEP_OPENSSL_LIBS
OT_DEP_AVAHI_CFLAGS
OT_DEP_AVAHI_LIBS
OT_DEP_LIBMOUNT_CFLAGS OT_DEP_LIBMOUNT_CFLAGS
OT_DEP_LIBMOUNT_LIBS OT_DEP_LIBMOUNT_LIBS
BUILDOPT_FUSE_CFLAGS BUILDOPT_FUSE_CFLAGS
@ -1526,7 +1533,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures libostree 2017.7 to adapt to many kinds of systems. \`configure' configures libostree 2017.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1596,7 +1603,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of libostree 2017.7:";; short | recursive ) echo "Configuration of libostree 2017.8:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1667,6 +1674,7 @@ Optional Packages:
--without-selinux Do not use SELinux --without-selinux Do not use SELinux
--with-smack Enable smack --with-smack Enable smack
--with-openssl Enable use of OpenSSL libcrypto (checksums) --with-openssl Enable use of OpenSSL libcrypto (checksums)
--without-avahi Do not use Avahi
--without-libmount Do not use libmount --without-libmount Do not use libmount
--with-dracut Install dracut module (default: no) --with-dracut Install dracut module (default: no)
--with-mkinitcpio Install mkinitcpio module (default: no) --with-mkinitcpio Install mkinitcpio module (default: no)
@ -1748,6 +1756,10 @@ Some influential environment variables:
C compiler flags for OT_DEP_OPENSSL, overriding pkg-config C compiler flags for OT_DEP_OPENSSL, overriding pkg-config
OT_DEP_OPENSSL_LIBS OT_DEP_OPENSSL_LIBS
linker flags for OT_DEP_OPENSSL, overriding pkg-config linker flags for OT_DEP_OPENSSL, overriding pkg-config
OT_DEP_AVAHI_CFLAGS
C compiler flags for OT_DEP_AVAHI, overriding pkg-config
OT_DEP_AVAHI_LIBS
linker flags for OT_DEP_AVAHI, overriding pkg-config
OT_DEP_LIBMOUNT_CFLAGS OT_DEP_LIBMOUNT_CFLAGS
C compiler flags for OT_DEP_LIBMOUNT, overriding pkg-config C compiler flags for OT_DEP_LIBMOUNT, overriding pkg-config
OT_DEP_LIBMOUNT_LIBS OT_DEP_LIBMOUNT_LIBS
@ -1827,7 +1839,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
libostree configure 2017.7 libostree configure 2017.8
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -2242,7 +2254,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by libostree $as_me 2017.7, which was It was created by libostree $as_me 2017.8, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -3110,7 +3122,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='libostree' PACKAGE='libostree'
VERSION='2017.7' VERSION='2017.8'
# Some tools Automake needs. # Some tools Automake needs.
@ -5844,9 +5856,9 @@ test -n "$YACC" || YACC="yacc"
YEAR_VERSION=2017 YEAR_VERSION=2017
RELEASE_VERSION=7 RELEASE_VERSION=8
PACKAGE_VERSION=2017.7 PACKAGE_VERSION=2017.8
@ -16431,6 +16443,155 @@ else
fi fi
AVAHI_DEPENDENCY="avahi-client >= 0.6.31 avahi-glib >= 0.6.31"
# Check whether --with-avahi was given.
if test "${with_avahi+set}" = set; then :
withval=$with_avahi; :
else
with_avahi=maybe
fi
if test x$with_avahi != xno ; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $AVAHI_DEPENDENCY" >&5
$as_echo_n "checking for $AVAHI_DEPENDENCY... " >&6; }
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$AVAHI_DEPENDENCY\""; } >&5
($PKG_CONFIG --exists --print-errors "$AVAHI_DEPENDENCY") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
have_avahi=yes
else
have_avahi=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_avahi" >&5
$as_echo "$have_avahi" >&6; }
if test x$have_avahi = xno && test x$with_avahi != xmaybe ; then :
as_fn_error $? "Avahi is enabled but could not be found" "$LINENO" 5
fi
if test x$have_avahi = xyes; then :
$as_echo "#define HAVE_AVAHI 1" >>confdefs.h
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OT_DEP_AVAHI" >&5
$as_echo_n "checking for OT_DEP_AVAHI... " >&6; }
if test -n "$OT_DEP_AVAHI_CFLAGS"; then
pkg_cv_OT_DEP_AVAHI_CFLAGS="$OT_DEP_AVAHI_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$AVAHI_DEPENDENCY\""; } >&5
($PKG_CONFIG --exists --print-errors "$AVAHI_DEPENDENCY") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_OT_DEP_AVAHI_CFLAGS=`$PKG_CONFIG --cflags "$AVAHI_DEPENDENCY" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$OT_DEP_AVAHI_LIBS"; then
pkg_cv_OT_DEP_AVAHI_LIBS="$OT_DEP_AVAHI_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$AVAHI_DEPENDENCY\""; } >&5
($PKG_CONFIG --exists --print-errors "$AVAHI_DEPENDENCY") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_OT_DEP_AVAHI_LIBS=`$PKG_CONFIG --libs "$AVAHI_DEPENDENCY" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test $pkg_failed = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
OT_DEP_AVAHI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$AVAHI_DEPENDENCY" 2>&1`
else
OT_DEP_AVAHI_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$AVAHI_DEPENDENCY" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$OT_DEP_AVAHI_PKG_ERRORS" >&5
as_fn_error $? "Package requirements ($AVAHI_DEPENDENCY) were not met:
$OT_DEP_AVAHI_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables OT_DEP_AVAHI_CFLAGS
and OT_DEP_AVAHI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details." "$LINENO" 5
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
Alternatively, you may set the environment variables OT_DEP_AVAHI_CFLAGS
and OT_DEP_AVAHI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
To get pkg-config, see <http://pkg-config.freedesktop.org/>.
See \`config.log' for more details" "$LINENO" 5; }
else
OT_DEP_AVAHI_CFLAGS=$pkg_cv_OT_DEP_AVAHI_CFLAGS
OT_DEP_AVAHI_LIBS=$pkg_cv_OT_DEP_AVAHI_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
fi
with_avahi=yes
else
with_avahi=no
fi
else
with_avahi=no
fi
if test x$with_avahi != xno; then OSTREE_FEATURES="$OSTREE_FEATURES avahi"; fi
if test $with_avahi != no; then
USE_AVAHI_TRUE=
USE_AVAHI_FALSE='#'
else
USE_AVAHI_TRUE='#'
USE_AVAHI_FALSE=
fi
LIBMOUNT_DEPENDENCY="mount >= 2.23.0" LIBMOUNT_DEPENDENCY="mount >= 2.23.0"
@ -17094,10 +17255,14 @@ else
fi fi
if test -z "$BUILDOPT_IS_DEVEL_BUILD_TRUE"; then : if test -z "$BUILDOPT_IS_DEVEL_BUILD_TRUE"; then :
release_build_type=devel
$as_echo "#define BUILDOPT_IS_DEVEL_BUILD 1" >>confdefs.h
release_build_type=devel
else else
release_build_type=release release_build_type=release
fi fi
OSTREE_FEATURES="$OSTREE_FEATURES $release_build_type"
ac_config_files="$ac_config_files Makefile apidoc/Makefile src/libostree/ostree-1.pc src/libostree/ostree-version.h" ac_config_files="$ac_config_files Makefile apidoc/Makefile src/libostree/ostree-1.pc src/libostree/ostree-version.h"
@ -17338,6 +17503,10 @@ if test -z "${USE_OPENSSL_TRUE}" && test -z "${USE_OPENSSL_FALSE}"; then
as_fn_error $? "conditional \"USE_OPENSSL\" was never defined. as_fn_error $? "conditional \"USE_OPENSSL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5 Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi fi
if test -z "${USE_AVAHI_TRUE}" && test -z "${USE_AVAHI_FALSE}"; then
as_fn_error $? "conditional \"USE_AVAHI\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${USE_LIBMOUNT_TRUE}" && test -z "${USE_LIBMOUNT_FALSE}"; then if test -z "${USE_LIBMOUNT_TRUE}" && test -z "${USE_LIBMOUNT_FALSE}"; then
as_fn_error $? "conditional \"USE_LIBMOUNT\" was never defined. as_fn_error $? "conditional \"USE_LIBMOUNT\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@ -17787,7 +17956,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by libostree $as_me 2017.7, which was This file was extended by libostree $as_me 2017.8, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -17853,7 +18022,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
libostree config.status 2017.7 libostree config.status 2017.8
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -4,7 +4,7 @@ dnl update libostree-released.sym from libostree-devel.sym, and update the check
dnl in test-symbols.sh, and also set is_release_build=yes below. Then make dnl in test-symbols.sh, and also set is_release_build=yes below. Then make
dnl another post-release commit to bump the version, and set is_release_build=no. dnl another post-release commit to bump the version, and set is_release_build=no.
m4_define([year_version], [2017]) m4_define([year_version], [2017])
m4_define([release_version], [7]) m4_define([release_version], [8])
m4_define([package_version], [year_version.release_version]) m4_define([package_version], [year_version.release_version])
AC_INIT([libostree], [package_version], [walters@verbum.org]) AC_INIT([libostree], [package_version], [walters@verbum.org])
is_release_build=yes is_release_build=yes
@ -320,6 +320,31 @@ if test x$with_openssl != xno; then OSTREE_FEATURES="$OSTREE_FEATURES openssl";
AM_CONDITIONAL(USE_OPENSSL, test $with_openssl != no) AM_CONDITIONAL(USE_OPENSSL, test $with_openssl != no)
dnl end openssl dnl end openssl
dnl Avahi dependency for finding repos
AVAHI_DEPENDENCY="avahi-client >= 0.6.31 avahi-glib >= 0.6.31"
AC_ARG_WITH(avahi,
AS_HELP_STRING([--without-avahi], [Do not use Avahi]),
:, with_avahi=maybe)
AS_IF([ test x$with_avahi != xno ], [
AC_MSG_CHECKING([for $AVAHI_DEPENDENCY])
PKG_CHECK_EXISTS($AVAHI_DEPENDENCY, have_avahi=yes, have_avahi=no)
AC_MSG_RESULT([$have_avahi])
AS_IF([ test x$have_avahi = xno && test x$with_avahi != xmaybe ], [
AC_MSG_ERROR([Avahi is enabled but could not be found])
])
AS_IF([ test x$have_avahi = xyes], [
AC_DEFINE([HAVE_AVAHI], 1, [Define if we have avahi-client.pc and avahi-glib.pc])
PKG_CHECK_MODULES(OT_DEP_AVAHI, $AVAHI_DEPENDENCY)
with_avahi=yes
], [
with_avahi=no
])
], [ with_avahi=no ])
if test x$with_avahi != xno; then OSTREE_FEATURES="$OSTREE_FEATURES avahi"; fi
AM_CONDITIONAL(USE_AVAHI, test $with_avahi != no)
dnl This is what is in RHEL7.2 right now, picking it arbitrarily dnl This is what is in RHEL7.2 right now, picking it arbitrarily
LIBMOUNT_DEPENDENCY="mount >= 2.23.0" LIBMOUNT_DEPENDENCY="mount >= 2.23.0"
@ -460,7 +485,11 @@ AS_IF([test x$enable_experimental_api = xyes],
) )
AM_CONDITIONAL([ENABLE_EXPERIMENTAL_API],[test x$enable_experimental_api = xyes]) AM_CONDITIONAL([ENABLE_EXPERIMENTAL_API],[test x$enable_experimental_api = xyes])
AM_CONDITIONAL([BUILDOPT_IS_DEVEL_BUILD],[test x$is_release_build != xyes]) AM_CONDITIONAL([BUILDOPT_IS_DEVEL_BUILD],[test x$is_release_build != xyes])
AM_COND_IF([BUILDOPT_IS_DEVEL_BUILD], release_build_type=devel, release_build_type=release) AM_COND_IF([BUILDOPT_IS_DEVEL_BUILD],
AC_DEFINE([BUILDOPT_IS_DEVEL_BUILD], [1], [Define if doing a development build])
release_build_type=devel,
release_build_type=release)
OSTREE_FEATURES="$OSTREE_FEATURES $release_build_type"
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile Makefile

View File

@ -22,7 +22,7 @@ EXTRA_DIST += \
$(NULL) $(NULL)
libglnx_la_SOURCES = \ libglnx_la_SOURCES = \
$(libglnx_srcpath)/glnx-alloca.h \ $(libglnx_srcpath)/glnx-macros.h \
$(libglnx_srcpath)/glnx-backport-autocleanups.h \ $(libglnx_srcpath)/glnx-backport-autocleanups.h \
$(libglnx_srcpath)/glnx-backport-autoptr.h \ $(libglnx_srcpath)/glnx-backport-autoptr.h \
$(libglnx_srcpath)/glnx-backports.h \ $(libglnx_srcpath)/glnx-backports.h \
@ -52,7 +52,7 @@ libglnx_la_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
libglnx_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^glnx_" -no-undefined -export-dynamic libglnx_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^glnx_" -no-undefined -export-dynamic
libglnx_la_LIBADD = $(libglnx_libs) libglnx_la_LIBADD = $(libglnx_libs)
libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors test-libglnx-macros
TESTS += $(libglnx_tests) TESTS += $(libglnx_tests)
check_PROGRAMS += $(libglnx_tests) check_PROGRAMS += $(libglnx_tests)
@ -67,3 +67,7 @@ test_libglnx_fdio_LDADD = $(libglnx_libs) libglnx.la
test_libglnx_errors_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-errors.c test_libglnx_errors_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-errors.c
test_libglnx_errors_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags) test_libglnx_errors_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_errors_LDADD = $(libglnx_libs) libglnx.la test_libglnx_errors_LDADD = $(libglnx_libs) libglnx.la
test_libglnx_macros_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-macros.c
test_libglnx_macros_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_macros_LDADD = $(libglnx_libs) libglnx.la

View File

@ -22,7 +22,7 @@ EXTRA_DIST += \
$(NULL) $(NULL)
libglnx_la_SOURCES = \ libglnx_la_SOURCES = \
libglnx/glnx-alloca.h \ libglnx/glnx-macros.h \
libglnx/glnx-backport-autocleanups.h \ libglnx/glnx-backport-autocleanups.h \
libglnx/glnx-backport-autoptr.h \ libglnx/glnx-backport-autoptr.h \
libglnx/glnx-backports.h \ libglnx/glnx-backports.h \
@ -52,7 +52,7 @@ libglnx_la_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
libglnx_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^glnx_" -no-undefined -export-dynamic libglnx_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^glnx_" -no-undefined -export-dynamic
libglnx_la_LIBADD = $(libglnx_libs) libglnx_la_LIBADD = $(libglnx_libs)
libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors test-libglnx-macros
TESTS += $(libglnx_tests) TESTS += $(libglnx_tests)
check_PROGRAMS += $(libglnx_tests) check_PROGRAMS += $(libglnx_tests)
@ -67,3 +67,7 @@ test_libglnx_fdio_LDADD = $(libglnx_libs) libglnx.la
test_libglnx_errors_SOURCES = libglnx/tests/test-libglnx-errors.c test_libglnx_errors_SOURCES = libglnx/tests/test-libglnx-errors.c
test_libglnx_errors_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags) test_libglnx_errors_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_errors_LDADD = $(libglnx_libs) libglnx.la test_libglnx_errors_LDADD = $(libglnx_libs) libglnx.la
test_libglnx_macros_SOURCES = libglnx/tests/test-libglnx-macros.c
test_libglnx_macros_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_macros_LDADD = $(libglnx_libs) libglnx.la

View File

@ -1,47 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2014,2015 Colin Walters <walters@verbum.org>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#pragma once
#include <stdlib.h>
#include <glib.h>
G_BEGIN_DECLS
/* Taken from https://github.com/systemd/systemd/src/basic/string-util.h
* at revision v228-666-gcf6c8c4
*/
#define glnx_strjoina(a, ...) \
({ \
const char *_appendees_[] = { a, __VA_ARGS__ }; \
char *_d_, *_p_; \
int _len_ = 0; \
unsigned _i_; \
for (_i_ = 0; _i_ < G_N_ELEMENTS(_appendees_) && _appendees_[_i_]; _i_++) \
_len_ += strlen(_appendees_[_i_]); \
_p_ = _d_ = alloca(_len_ + 1); \
for (_i_ = 0; _i_ < G_N_ELEMENTS(_appendees_) && _appendees_[_i_]; _i_++) \
_p_ = stpcpy(_p_, _appendees_[_i_]); \
*_p_ = 0; \
_d_; \
})
G_END_DECLS

View File

@ -99,24 +99,19 @@ glnx_dirfd_iterator_init_at (int dfd,
GLnxDirFdIterator *out_dfd_iter, GLnxDirFdIterator *out_dfd_iter,
GError **error) GError **error)
{ {
gboolean ret = FALSE;
glnx_fd_close int fd = -1; glnx_fd_close int fd = -1;
if (!glnx_opendirat (dfd, path, follow, &fd, error)) if (!glnx_opendirat (dfd, path, follow, &fd, error))
goto out; return FALSE;
if (!glnx_dirfd_iterator_init_take_fd (fd, out_dfd_iter, error)) if (!glnx_dirfd_iterator_init_take_fd (&fd, out_dfd_iter, error))
goto out; return FALSE;
fd = -1; /* Transfer ownership */
ret = TRUE; return TRUE;
out:
return ret;
} }
/** /**
* glnx_dirfd_iterator_init_take_fd: * glnx_dirfd_iterator_init_take_fd:
* @dfd: File descriptor - ownership is taken * @dfd: File descriptor - ownership is taken, and the value is set to -1
* @dfd_iter: A directory iterator * @dfd_iter: A directory iterator
* @error: Error * @error: Error
* *
@ -124,28 +119,20 @@ glnx_dirfd_iterator_init_at (int dfd,
* iteration. * iteration.
*/ */
gboolean gboolean
glnx_dirfd_iterator_init_take_fd (int dfd, glnx_dirfd_iterator_init_take_fd (int *dfd,
GLnxDirFdIterator *dfd_iter, GLnxDirFdIterator *dfd_iter,
GError **error) GError **error)
{ {
gboolean ret = FALSE;
GLnxRealDirfdIterator *real_dfd_iter = (GLnxRealDirfdIterator*) dfd_iter; GLnxRealDirfdIterator *real_dfd_iter = (GLnxRealDirfdIterator*) dfd_iter;
DIR *d = NULL; DIR *d = fdopendir (*dfd);
d = fdopendir (dfd);
if (!d) if (!d)
{ return glnx_throw_errno_prefix (error, "fdopendir");
glnx_set_prefix_error_from_errno (error, "%s", "fdopendir");
goto out;
}
real_dfd_iter->fd = dfd; real_dfd_iter->fd = glnx_steal_fd (dfd);
real_dfd_iter->d = d; real_dfd_iter->d = d;
real_dfd_iter->initialized = TRUE; real_dfd_iter->initialized = TRUE;
ret = TRUE; return TRUE;
out:
return ret;
} }
/** /**
@ -165,31 +152,25 @@ glnx_dirfd_iterator_next_dent (GLnxDirFdIterator *dfd_iter,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE;
GLnxRealDirfdIterator *real_dfd_iter = (GLnxRealDirfdIterator*) dfd_iter; GLnxRealDirfdIterator *real_dfd_iter = (GLnxRealDirfdIterator*) dfd_iter;
g_return_val_if_fail (out_dent, FALSE); g_return_val_if_fail (out_dent, FALSE);
g_return_val_if_fail (dfd_iter->initialized, FALSE); g_return_val_if_fail (dfd_iter->initialized, FALSE);
if (g_cancellable_set_error_if_cancelled (cancellable, error)) if (g_cancellable_set_error_if_cancelled (cancellable, error))
goto out; return FALSE;
do do
{ {
errno = 0; errno = 0;
*out_dent = readdir (real_dfd_iter->d); *out_dent = readdir (real_dfd_iter->d);
if (*out_dent == NULL && errno != 0) if (*out_dent == NULL && errno != 0)
{ return glnx_throw_errno_prefix (error, "readdir");
glnx_set_prefix_error_from_errno (error, "%s", "fdopendir");
goto out;
}
} while (*out_dent && } while (*out_dent &&
(strcmp ((*out_dent)->d_name, ".") == 0 || (strcmp ((*out_dent)->d_name, ".") == 0 ||
strcmp ((*out_dent)->d_name, "..") == 0)); strcmp ((*out_dent)->d_name, "..") == 0));
ret = TRUE; return TRUE;
out:
return ret;
} }
/** /**

View File

@ -55,7 +55,7 @@ typedef struct GLnxDirFdIterator GLnxDirFdIterator;
gboolean glnx_dirfd_iterator_init_at (int dfd, const char *path, gboolean glnx_dirfd_iterator_init_at (int dfd, const char *path,
gboolean follow, gboolean follow,
GLnxDirFdIterator *dfd_iter, GError **error); GLnxDirFdIterator *dfd_iter, GError **error);
gboolean glnx_dirfd_iterator_init_take_fd (int dfd, GLnxDirFdIterator *dfd_iter, GError **error); gboolean glnx_dirfd_iterator_init_take_fd (int *dfd, GLnxDirFdIterator *dfd_iter, GError **error);
gboolean glnx_dirfd_iterator_next_dent (GLnxDirFdIterator *dfd_iter, gboolean glnx_dirfd_iterator_next_dent (GLnxDirFdIterator *dfd_iter,
struct dirent **out_dent, struct dirent **out_dent,
GCancellable *cancellable, GCancellable *cancellable,

View File

@ -37,7 +37,6 @@
#include <glnx-fdio.h> #include <glnx-fdio.h>
#include <glnx-dirfd.h> #include <glnx-dirfd.h>
#include <glnx-alloca.h>
#include <glnx-errors.h> #include <glnx-errors.h>
#include <glnx-xattrs.h> #include <glnx-xattrs.h>
#include <glnx-backport-autoptr.h> #include <glnx-backport-autoptr.h>
@ -65,7 +64,7 @@ glnx_renameat2_noreplace (int olddirfd, const char *oldpath,
#ifndef ENABLE_WRPSEUDO_COMPAT #ifndef ENABLE_WRPSEUDO_COMPAT
if (renameat2 (olddirfd, oldpath, newdirfd, newpath, RENAME_NOREPLACE) < 0) if (renameat2 (olddirfd, oldpath, newdirfd, newpath, RENAME_NOREPLACE) < 0)
{ {
if (errno == EINVAL || errno == ENOSYS) if (G_IN_SET(errno, EINVAL, ENOSYS))
{ {
/* Fall through */ /* Fall through */
} }
@ -119,7 +118,7 @@ glnx_renameat2_exchange (int olddirfd, const char *oldpath,
return 0; return 0;
else else
{ {
if (errno == ENOSYS || errno == EINVAL) if (G_IN_SET(errno, ENOSYS, EINVAL))
{ {
/* Fall through */ /* Fall through */
} }
@ -146,17 +145,51 @@ glnx_renameat2_exchange (int olddirfd, const char *oldpath,
return 0; return 0;
} }
/* Deallocate a tmpfile, closing the fd and deleting the path, if any. This is
* normally called by default by the autocleanup attribute, but you can also
* invoke this directly.
*/
void
glnx_tmpfile_clear (GLnxTmpfile *tmpf)
{
/* Support being passed NULL so we work nicely in a GPtrArray */
if (!tmpf)
return;
if (!tmpf->initialized)
return;
if (tmpf->fd == -1)
return;
(void) close (tmpf->fd);
/* If ->path is set, we're likely aborting due to an error. Clean it up */
if (tmpf->path)
{
(void) unlinkat (tmpf->src_dfd, tmpf->path, 0);
g_free (tmpf->path);
}
tmpf->initialized = FALSE;
}
/* Allocate a temporary file, using Linux O_TMPFILE if available.
* The result will be stored in @out_tmpf, which is caller allocated
* so you can store it on the stack in common scenarios.
*
* Note that with O_TMPFILE, the file mode will be `000`; you likely
* want to chmod it before calling glnx_link_tmpfile_at().
*
* The directory fd @dfd must live at least as long as the output @out_tmpf.
*/
gboolean gboolean
glnx_open_tmpfile_linkable_at (int dfd, glnx_open_tmpfile_linkable_at (int dfd,
const char *subpath, const char *subpath,
int flags, int flags,
int *out_fd, GLnxTmpfile *out_tmpf,
char **out_path,
GError **error) GError **error)
{ {
glnx_fd_close int fd = -1; glnx_fd_close int fd = -1;
int count; int count;
dfd = glnx_dirfd_canonicalize (dfd);
/* Don't allow O_EXCL, as that has a special meaning for O_TMPFILE */ /* Don't allow O_EXCL, as that has a special meaning for O_TMPFILE */
g_return_val_if_fail ((flags & O_EXCL) == 0, FALSE); g_return_val_if_fail ((flags & O_EXCL) == 0, FALSE);
@ -168,13 +201,14 @@ glnx_open_tmpfile_linkable_at (int dfd,
* in full. */ * in full. */
#if defined(O_TMPFILE) && !defined(DISABLE_OTMPFILE) && !defined(ENABLE_WRPSEUDO_COMPAT) #if defined(O_TMPFILE) && !defined(DISABLE_OTMPFILE) && !defined(ENABLE_WRPSEUDO_COMPAT)
fd = openat (dfd, subpath, O_TMPFILE|flags, 0600); fd = openat (dfd, subpath, O_TMPFILE|flags, 0600);
if (fd == -1 && !(errno == ENOSYS || errno == EISDIR || errno == EOPNOTSUPP)) if (fd == -1 && !(G_IN_SET(errno, ENOSYS, EISDIR, EOPNOTSUPP)))
return glnx_throw_errno_prefix (error, "open(O_TMPFILE)"); return glnx_throw_errno_prefix (error, "open(O_TMPFILE)");
if (fd != -1) if (fd != -1)
{ {
*out_fd = fd; out_tmpf->initialized = TRUE;
fd = -1; out_tmpf->src_dfd = dfd; /* Copied; caller must keep open */
*out_path = NULL; out_tmpf->fd = glnx_steal_fd (&fd);
out_tmpf->path = NULL;
return TRUE; return TRUE;
} }
/* Fallthrough */ /* Fallthrough */
@ -182,7 +216,7 @@ glnx_open_tmpfile_linkable_at (int dfd,
{ g_autofree char *tmp = g_strconcat (subpath, "/tmp.XXXXXX", NULL); { g_autofree char *tmp = g_strconcat (subpath, "/tmp.XXXXXX", NULL);
const guint count_max = 100; const guint count_max = 100;
for (count = 0; count < count_max; count++) for (count = 0; count < count_max; count++)
{ {
glnx_gen_temp_name (tmp); glnx_gen_temp_name (tmp);
@ -197,9 +231,10 @@ glnx_open_tmpfile_linkable_at (int dfd,
} }
else else
{ {
*out_fd = fd; out_tmpf->initialized = TRUE;
fd = -1; out_tmpf->src_dfd = dfd; /* Copied; caller must keep open */
*out_path = g_steal_pointer (&tmp); out_tmpf->fd = glnx_steal_fd (&fd);
out_tmpf->path = g_steal_pointer (&tmp);
return TRUE; return TRUE;
} }
} }
@ -209,11 +244,33 @@ glnx_open_tmpfile_linkable_at (int dfd,
return FALSE; return FALSE;
} }
/* A variant of `glnx_open_tmpfile_linkable_at()` which doesn't support linking.
* Useful for true temporary storage. The fd will be allocated in /var/tmp to
* ensure maximum storage space.
*/
gboolean gboolean
glnx_link_tmpfile_at (int dfd, glnx_open_anonymous_tmpfile (int flags,
GLnxTmpfile *out_tmpf,
GError **error)
{
if (!glnx_open_tmpfile_linkable_at (AT_FDCWD, "/var/tmp", flags, out_tmpf, error))
return FALSE;
if (out_tmpf->path)
{
(void) unlinkat (out_tmpf->src_dfd, out_tmpf->path, 0);
g_clear_pointer (&out_tmpf->path, g_free);
}
out_tmpf->anonymous = TRUE;
out_tmpf->src_dfd = -1;
return TRUE;
}
/* Use this after calling glnx_open_tmpfile_linkable_at() to give
* the file its final name (link into place).
*/
gboolean
glnx_link_tmpfile_at (GLnxTmpfile *tmpf,
GLnxLinkTmpfileReplaceMode mode, GLnxLinkTmpfileReplaceMode mode,
int fd,
const char *tmpfile_path,
int target_dfd, int target_dfd,
const char *target, const char *target,
GError **error) GError **error)
@ -221,46 +278,42 @@ glnx_link_tmpfile_at (int dfd,
const gboolean replace = (mode == GLNX_LINK_TMPFILE_REPLACE); const gboolean replace = (mode == GLNX_LINK_TMPFILE_REPLACE);
const gboolean ignore_eexist = (mode == GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST); const gboolean ignore_eexist = (mode == GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST);
g_return_val_if_fail (fd >= 0, FALSE); g_return_val_if_fail (!tmpf->anonymous, FALSE);
g_return_val_if_fail (tmpf->fd >= 0, FALSE);
g_return_val_if_fail (tmpf->src_dfd == AT_FDCWD || tmpf->src_dfd >= 0, FALSE);
/* Unlike the original systemd code, this function also supports /* Unlike the original systemd code, this function also supports
* replacing existing files. * replacing existing files.
*/ */
/* We have `tmpfile_path` for old systems without O_TMPFILE. */ /* We have `tmpfile_path` for old systems without O_TMPFILE. */
if (tmpfile_path) if (tmpf->path)
{ {
if (replace) if (replace)
{ {
/* We have a regular tempfile, we're overwriting - this is a /* We have a regular tempfile, we're overwriting - this is a
* simple renameat(). * simple renameat().
*/ */
if (renameat (dfd, tmpfile_path, target_dfd, target) < 0) if (renameat (tmpf->src_dfd, tmpf->path, target_dfd, target) < 0)
{ return glnx_throw_errno_prefix (error, "renameat");
int errsv = errno;
(void) unlinkat (dfd, tmpfile_path, 0);
errno = errsv;
return glnx_throw_errno_prefix (error, "renameat");
}
} }
else else
{ {
/* We need to use renameat2(..., NOREPLACE) or emulate it */ /* We need to use renameat2(..., NOREPLACE) or emulate it */
if (!rename_file_noreplace_at (dfd, tmpfile_path, target_dfd, target, if (!rename_file_noreplace_at (tmpf->src_dfd, tmpf->path, target_dfd, target,
ignore_eexist, ignore_eexist,
error)) error))
{ return FALSE;
(void) unlinkat (dfd, tmpfile_path, 0);
return FALSE;
}
} }
/* Now, clear the pointer so we don't try to unlink it */
g_clear_pointer (&tmpf->path, g_free);
} }
else else
{ {
/* This case we have O_TMPFILE, so our reference to it is via /proc/self/fd */ /* This case we have O_TMPFILE, so our reference to it is via /proc/self/fd */
char proc_fd_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(fd) + 1]; char proc_fd_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(tmpf->fd) + 1];
sprintf (proc_fd_path, "/proc/self/fd/%i", fd); sprintf (proc_fd_path, "/proc/self/fd/%i", tmpf->fd);
if (replace) if (replace)
{ {
@ -294,16 +347,15 @@ glnx_link_tmpfile_at (int dfd,
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS, g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
"Exhausted %u attempts to create temporary file", count); "Exhausted %u attempts to create temporary file", count);
return FALSE;
} }
if (renameat (target_dfd, tmpname_buf, target_dfd, target) < 0) if (!glnx_renameat (target_dfd, tmpname_buf, target_dfd, target, error))
{ {
/* This is currently the only case where we need to have /* This is currently the only case where we need to have
* a cleanup unlinkat() still with O_TMPFILE. * a cleanup unlinkat() still with O_TMPFILE.
*/ */
int errsv = errno;
(void) unlinkat (target_dfd, tmpname_buf, 0); (void) unlinkat (target_dfd, tmpname_buf, 0);
errno = errsv; return FALSE;
return glnx_throw_errno_prefix (error, "renameat");
} }
} }
else else
@ -895,7 +947,6 @@ glnx_file_replace_contents_with_perms_at (int dfd,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
int r;
char *dnbuf = strdupa (subpath); char *dnbuf = strdupa (subpath);
const char *dn = dirname (dnbuf); const char *dn = dirname (dnbuf);
@ -907,28 +958,18 @@ glnx_file_replace_contents_with_perms_at (int dfd,
if (mode == (mode_t) -1) if (mode == (mode_t) -1)
mode = 0644; mode = 0644;
glnx_fd_close int fd = -1; g_auto(GLnxTmpfile) tmpf = { 0, };
g_autofree char *tmpfile_path = NULL;
if (!glnx_open_tmpfile_linkable_at (dfd, dn, O_WRONLY | O_CLOEXEC, if (!glnx_open_tmpfile_linkable_at (dfd, dn, O_WRONLY | O_CLOEXEC,
&fd, &tmpfile_path, &tmpf, error))
error))
return FALSE; return FALSE;
if (len == -1) if (len == -1)
len = strlen ((char*)buf); len = strlen ((char*)buf);
/* Note that posix_fallocate does *not* set errno but returns it. */ if (!glnx_try_fallocate (tmpf.fd, 0, len, error))
if (len > 0) return FALSE;
{
r = posix_fallocate (fd, 0, len);
if (r != 0)
{
errno = r;
return glnx_throw_errno_prefix (error, "fallocate");
}
}
if (glnx_loop_write (fd, buf, len) < 0) if (glnx_loop_write (tmpf.fd, buf, len) < 0)
return glnx_throw_errno (error); return glnx_throw_errno (error);
if (!(flags & GLNX_FILE_REPLACE_NODATASYNC)) if (!(flags & GLNX_FILE_REPLACE_NODATASYNC))
@ -947,22 +988,22 @@ glnx_file_replace_contents_with_perms_at (int dfd,
if (do_sync) if (do_sync)
{ {
if (fdatasync (fd) != 0) if (fdatasync (tmpf.fd) != 0)
return glnx_throw_errno_prefix (error, "fdatasync"); return glnx_throw_errno_prefix (error, "fdatasync");
} }
} }
if (uid != (uid_t) -1) if (uid != (uid_t) -1)
{ {
if (fchown (fd, uid, gid) != 0) if (fchown (tmpf.fd, uid, gid) != 0)
return glnx_throw_errno (error); return glnx_throw_errno (error);
} }
if (fchmod (fd, mode) != 0) if (fchmod (tmpf.fd, mode) != 0)
return glnx_throw_errno (error); return glnx_throw_errno (error);
if (!glnx_link_tmpfile_at (dfd, GLNX_LINK_TMPFILE_REPLACE, if (!glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_REPLACE,
fd, tmpfile_path, dfd, subpath, error)) dfd, subpath, error))
return FALSE; return FALSE;
return TRUE; return TRUE;

View File

@ -27,6 +27,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include <sys/xattr.h> #include <sys/xattr.h>
/* From systemd/src/shared/util.h */ /* From systemd/src/shared/util.h */
/* When we include libgen.h because we need dirname() we immediately /* When we include libgen.h because we need dirname() we immediately
@ -35,6 +36,7 @@
#include <libgen.h> #include <libgen.h>
#undef basename #undef basename
#include <glnx-macros.h>
#include <glnx-errors.h> #include <glnx-errors.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -48,12 +50,26 @@ const char *glnx_basename (const char *path)
return (basename) (path); return (basename) (path);
} }
typedef struct {
gboolean initialized;
gboolean anonymous;
int src_dfd;
int fd;
char *path;
} GLnxTmpfile;
void glnx_tmpfile_clear (GLnxTmpfile *tmpf);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxTmpfile, glnx_tmpfile_clear)
gboolean
glnx_open_anonymous_tmpfile (int flags,
GLnxTmpfile *out_tmpf,
GError **error);
gboolean gboolean
glnx_open_tmpfile_linkable_at (int dfd, glnx_open_tmpfile_linkable_at (int dfd,
const char *subpath, const char *subpath,
int flags, int flags,
int *out_fd, GLnxTmpfile *out_tmpf,
char **out_path,
GError **error); GError **error);
typedef enum { typedef enum {
@ -63,10 +79,8 @@ typedef enum {
} GLnxLinkTmpfileReplaceMode; } GLnxLinkTmpfileReplaceMode;
gboolean gboolean
glnx_link_tmpfile_at (int dfd, glnx_link_tmpfile_at (GLnxTmpfile *tmpf,
GLnxLinkTmpfileReplaceMode flags, GLnxLinkTmpfileReplaceMode flags,
int fd,
const char *tmpfile_path,
int target_dfd, int target_dfd,
const char *target, const char *target,
GError **error); GError **error);
@ -160,6 +174,38 @@ int glnx_renameat2_noreplace (int olddirfd, const char *oldpath,
int glnx_renameat2_exchange (int olddirfd, const char *oldpath, int glnx_renameat2_exchange (int olddirfd, const char *oldpath,
int newdirfd, const char *newpath); int newdirfd, const char *newpath);
/**
* glnx_try_fallocate:
* @fd: File descriptor
* @size: Size
* @error: Error
*
* Wrapper for Linux fallocate(). Explicitly ignores a @size of zero.
* Also, will silently do nothing if the underlying filesystem doesn't
* support it. Use this instead of posix_fallocate(), since the glibc fallback
* is bad: https://sourceware.org/bugzilla/show_bug.cgi?id=18515
*/
static inline gboolean
glnx_try_fallocate (int fd,
off_t offset,
off_t size,
GError **error)
{
/* This is just nicer than throwing an error */
if (size == 0)
return TRUE;
if (fallocate (fd, 0, offset, size) < 0)
{
if (G_IN_SET(errno, ENOSYS, EOPNOTSUPP))
; /* Ignore */
else
return glnx_throw_errno_prefix (error, "fallocate");
}
return TRUE;
}
/** /**
* glnx_fstat: * glnx_fstat:
* @fd: FD to stat * @fd: FD to stat
@ -205,8 +251,42 @@ glnx_fstatat (int dfd,
GError **error) GError **error)
{ {
if (TEMP_FAILURE_RETRY (fstatat (dfd, path, buf, flags)) != 0) if (TEMP_FAILURE_RETRY (fstatat (dfd, path, buf, flags)) != 0)
return glnx_throw_errno (error); return glnx_throw_errno_prefix (error, "fstatat(%s)", path);
return TRUE;
}
/**
* glnx_renameat:
*
* Wrapper around renameat() which adds #GError support and ensures that it
* retries on %EINTR.
*/
static inline gboolean
glnx_renameat (int src_dfd,
const gchar *src_path,
int dest_dfd,
const gchar *dest_path,
GError **error)
{
if (TEMP_FAILURE_RETRY (renameat (src_dfd, src_path, dest_dfd, dest_path)) != 0)
return glnx_throw_errno_prefix (error, "renameat(%s, %s)", src_path, dest_path);
return TRUE;
}
/**
* glnx_unlinkat:
*
* Wrapper around unlinkat() which adds #GError support and ensures that it
* retries on %EINTR.
*/
static inline gboolean
glnx_unlinkat (int dfd,
const gchar *path,
int flags,
GError **error)
{
if (TEMP_FAILURE_RETRY (unlinkat (dfd, path, flags)) != 0)
return glnx_throw_errno_prefix (error, "unlinkat(%s)", path);
return TRUE; return TRUE;
} }

189
libglnx/glnx-macros.h Normal file
View File

@ -0,0 +1,189 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2017 Colin Walters <walters@verbum.org>
* With original source from systemd:
* Copyright 2010 Lennart Poettering
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#pragma once
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
G_BEGIN_DECLS
/* All of these are for C only. */
#ifndef __GI_SCANNER__
/* Taken from https://github.com/systemd/systemd/src/basic/string-util.h
* at revision v228-666-gcf6c8c4
*/
#define glnx_strjoina(a, ...) \
({ \
const char *_appendees_[] = { a, __VA_ARGS__ }; \
char *_d_, *_p_; \
int _len_ = 0; \
unsigned _i_; \
for (_i_ = 0; _i_ < G_N_ELEMENTS(_appendees_) && _appendees_[_i_]; _i_++) \
_len_ += strlen(_appendees_[_i_]); \
_p_ = _d_ = alloca(_len_ + 1); \
for (_i_ = 0; _i_ < G_N_ELEMENTS(_appendees_) && _appendees_[_i_]; _i_++) \
_p_ = stpcpy(_p_, _appendees_[_i_]); \
*_p_ = 0; \
_d_; \
})
#ifndef G_IN_SET
/* Infrastructure for `G_IN_SET`; this code is copied from
* systemd's macro.h - please treat that version as canonical
* and submit patches first to systemd.
*/
#define _G_INSET_CASE_F(X) case X:
#define _G_INSET_CASE_F_1(CASE, X) _G_INSET_CASE_F(X)
#define _G_INSET_CASE_F_2(CASE, X, ...) CASE(X) _G_INSET_CASE_F_1(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_3(CASE, X, ...) CASE(X) _G_INSET_CASE_F_2(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_4(CASE, X, ...) CASE(X) _G_INSET_CASE_F_3(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_5(CASE, X, ...) CASE(X) _G_INSET_CASE_F_4(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_6(CASE, X, ...) CASE(X) _G_INSET_CASE_F_5(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_7(CASE, X, ...) CASE(X) _G_INSET_CASE_F_6(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_8(CASE, X, ...) CASE(X) _G_INSET_CASE_F_7(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_9(CASE, X, ...) CASE(X) _G_INSET_CASE_F_8(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_10(CASE, X, ...) CASE(X) _G_INSET_CASE_F_9(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_11(CASE, X, ...) CASE(X) _G_INSET_CASE_F_10(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_12(CASE, X, ...) CASE(X) _G_INSET_CASE_F_11(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_13(CASE, X, ...) CASE(X) _G_INSET_CASE_F_12(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_14(CASE, X, ...) CASE(X) _G_INSET_CASE_F_13(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_15(CASE, X, ...) CASE(X) _G_INSET_CASE_F_14(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_16(CASE, X, ...) CASE(X) _G_INSET_CASE_F_15(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_17(CASE, X, ...) CASE(X) _G_INSET_CASE_F_16(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_18(CASE, X, ...) CASE(X) _G_INSET_CASE_F_17(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_19(CASE, X, ...) CASE(X) _G_INSET_CASE_F_18(CASE, __VA_ARGS__)
#define _G_INSET_CASE_F_20(CASE, X, ...) CASE(X) _G_INSET_CASE_F_19(CASE, __VA_ARGS__)
#define _G_INSET_GET_CASE_F(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,NAME,...) NAME
#define _G_INSET_FOR_EACH_MAKE_CASE(...) \
_G_INSET_GET_CASE_F(__VA_ARGS__,_G_INSET_CASE_F_20,_G_INSET_CASE_F_19,_G_INSET_CASE_F_18,_G_INSET_CASE_F_17,_G_INSET_CASE_F_16,_G_INSET_CASE_F_15,_G_INSET_CASE_F_14,_G_INSET_CASE_F_13,_G_INSET_CASE_F_12,_G_INSET_CASE_F_11, \
_G_INSET_CASE_F_10,_G_INSET_CASE_F_9,_G_INSET_CASE_F_8,_G_INSET_CASE_F_7,_G_INSET_CASE_F_6,_G_INSET_CASE_F_5,_G_INSET_CASE_F_4,_G_INSET_CASE_F_3,_G_INSET_CASE_F_2,_G_INSET_CASE_F_1) \
(_G_INSET_CASE_F,__VA_ARGS__)
/* Note: claiming the name here even though it isn't upstream yet
* https://bugzilla.gnome.org/show_bug.cgi?id=783751
*/
/**
* G_IN_SET:
* @x: Integer (or smaller) sized value
* @...: Elements to compare
*
* It's quite common to test whether or not `char` values or Unix @errno (among) others
* are members of a small set. Normally one has to choose to either use `if (x == val || x == otherval ...)`
* or a `switch` statement. This macro is useful to reduce duplication in the first case,
* where one can write simply `if (G_IN_SET (x, val, otherval))`, and avoid the verbosity
* that the `switch` statement requires.
*/
#define G_IN_SET(x, ...) \
({ \
gboolean _g_inset_found = FALSE; \
/* If the build breaks in the line below, you need to extend the case macros */ \
static G_GNUC_UNUSED char _static_assert__macros_need_to_be_extended[20 - sizeof((int[]){__VA_ARGS__})/sizeof(int)]; \
switch(x) { \
_G_INSET_FOR_EACH_MAKE_CASE(__VA_ARGS__) \
_g_inset_found = TRUE; \
break; \
default: \
break; \
} \
_g_inset_found; \
})
#endif /* ifndef G_IN_SET */
#define _GLNX_CONCAT(a, b) a##b
#define _GLNX_CONCAT_INDIRECT(a, b) _GLNX_CONCAT(a, b)
#define _GLNX_MAKE_ANONYMOUS(a) _GLNX_CONCAT_INDIRECT(a, __COUNTER__)
#define _GLNX_HASH_TABLE_FOREACH_IMPL_KV(guard, ht, it, kt, k, vt, v) \
gboolean guard = TRUE; \
G_STATIC_ASSERT (sizeof (kt) == sizeof (void*)); \
G_STATIC_ASSERT (sizeof (vt) == sizeof (void*)); \
for (GHashTableIter it; \
guard && ({ g_hash_table_iter_init (&it, ht), TRUE; }); \
guard = FALSE) \
for (kt k; guard; guard = FALSE) \
for (vt v; g_hash_table_iter_next (&it, (gpointer)&k, (gpointer)&v);)
/* Cleaner method to iterate over a GHashTable. I.e. rather than
*
* gpointer k, v;
* GHashTableIter it;
* g_hash_table_iter_init (&it, table);
* while (g_hash_table_iter_next (&it, &k, &v))
* {
* const char *str = k;
* GPtrArray *arr = v;
* ...
* }
*
* you can simply do
*
* GLNX_HASH_TABLE_FOREACH_IT (table, it, const char*, str, GPtrArray*, arr)
* {
* ...
* }
*
* All variables are scoped within the loop. You may use the `it` variable as
* usual, e.g. to remove an element using g_hash_table_iter_remove(&it). There
* are shorter variants for the more common cases where you do not need access
* to the iterator or to keys/values:
*
* GLNX_HASH_TABLE_FOREACH (table, const char*, str) { ... }
* GLNX_HASH_TABLE_FOREACH_V (table, MyData*, data) { ... }
* GLNX_HASH_TABLE_FOREACH_KV (table, const char*, str, MyData*, data) { ... }
*
*/
#define GLNX_HASH_TABLE_FOREACH_IT(ht, it, kt, k, vt, v) \
_GLNX_HASH_TABLE_FOREACH_IMPL_KV( \
_GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_guard_), ht, it, kt, k, vt, v)
/* Variant of GLNX_HASH_TABLE_FOREACH without having to specify an iterator. An
* anonymous iterator will be created. */
#define GLNX_HASH_TABLE_FOREACH_KV(ht, kt, k, vt, v) \
_GLNX_HASH_TABLE_FOREACH_IMPL_KV( \
_GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_guard_), ht, \
_GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_it_), kt, k, vt, v)
/* Variant of GLNX_HASH_TABLE_FOREACH_KV which omits unpacking keys. */
#define GLNX_HASH_TABLE_FOREACH_V(ht, vt, v) \
_GLNX_HASH_TABLE_FOREACH_IMPL_KV( \
_GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_guard_), ht, \
_GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_it_), \
gpointer, _GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_v_), \
vt, v)
/* Variant of GLNX_HASH_TABLE_FOREACH_KV which omits unpacking vals. */
#define GLNX_HASH_TABLE_FOREACH(ht, kt, k) \
_GLNX_HASH_TABLE_FOREACH_IMPL_KV( \
_GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_guard_), ht, \
_GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_it_), kt, k, \
gpointer, _GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_v_))
#endif /* GI_SCANNER */
G_END_DECLS

View File

@ -110,9 +110,8 @@ glnx_shutil_rm_rf_at (int dfd,
} }
else else
{ {
if (!glnx_dirfd_iterator_init_take_fd (target_dfd, &dfd_iter, error)) if (!glnx_dirfd_iterator_init_take_fd (&target_dfd, &dfd_iter, error))
return FALSE; return FALSE;
target_dfd = -1;
if (!glnx_shutil_rm_rf_children (&dfd_iter, cancellable, error)) if (!glnx_shutil_rm_rf_children (&dfd_iter, cancellable, error))
return FALSE; return FALSE;

View File

@ -23,6 +23,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <glnx-macros.h>
#include <glnx-xattrs.h> #include <glnx-xattrs.h>
#include <glnx-errors.h> #include <glnx-errors.h>
#include <glnx-local-alloc.h> #include <glnx-local-alloc.h>
@ -249,7 +250,7 @@ glnx_dfd_name_get_all_xattrs (int dfd,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
if (dfd == AT_FDCWD || dfd == -1) if (G_IN_SET(dfd, AT_FDCWD, -1))
{ {
return get_xattrs_impl (name, -1, out_xattrs, cancellable, error); return get_xattrs_impl (name, -1, out_xattrs, cancellable, error);
} }
@ -270,31 +271,22 @@ set_all_xattrs_for_path (const char *path,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; const guint n = g_variant_n_children (xattrs);
int i, n; for (guint i = 0; i < n; i++)
n = g_variant_n_children (xattrs);
for (i = 0; i < n; i++)
{ {
const guint8* name; const guint8* name;
g_autoptr(GVariant) value = NULL; g_autoptr(GVariant) value = NULL;
const guint8* value_data;
gsize value_len;
g_variant_get_child (xattrs, i, "(^&ay@ay)", g_variant_get_child (xattrs, i, "(^&ay@ay)",
&name, &value); &name, &value);
value_data = g_variant_get_fixed_array (value, &value_len, 1);
gsize value_len;
const guint8* value_data = g_variant_get_fixed_array (value, &value_len, 1);
if (lsetxattr (path, (char*)name, (char*)value_data, value_len, 0) < 0) if (lsetxattr (path, (char*)name, (char*)value_data, value_len, 0) < 0)
{ return glnx_throw_errno_prefix (error, "lsetxattr");
glnx_set_prefix_error_from_errno (error, "%s", "lsetxattr");
goto out;
}
} }
ret = TRUE; return TRUE;
out:
return ret;
} }
/** /**
@ -315,7 +307,7 @@ glnx_dfd_name_set_all_xattrs (int dfd,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
if (dfd == AT_FDCWD || dfd == -1) if (G_IN_SET(dfd, AT_FDCWD, -1))
{ {
return set_all_xattrs_for_path (name, xattrs, cancellable, error); return set_all_xattrs_for_path (name, xattrs, cancellable, error);
} }
@ -347,35 +339,22 @@ glnx_fd_set_all_xattrs (int fd,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; const guint n = g_variant_n_children (xattrs);
int i, n; for (guint i = 0; i < n; i++)
n = g_variant_n_children (xattrs);
for (i = 0; i < n; i++)
{ {
const guint8* name; const guint8* name;
const guint8* value_data;
g_autoptr(GVariant) value = NULL; g_autoptr(GVariant) value = NULL;
gsize value_len;
int res;
g_variant_get_child (xattrs, i, "(^&ay@ay)", g_variant_get_child (xattrs, i, "(^&ay@ay)",
&name, &value); &name, &value);
value_data = g_variant_get_fixed_array (value, &value_len, 1);
gsize value_len;
do const guint8* value_data = g_variant_get_fixed_array (value, &value_len, 1);
res = fsetxattr (fd, (char*)name, (char*)value_data, value_len, 0);
while (G_UNLIKELY (res == -1 && errno == EINTR)); if (TEMP_FAILURE_RETRY (fsetxattr (fd, (char*)name, (char*)value_data, value_len, 0)) < 0)
if (G_UNLIKELY (res == -1)) return glnx_throw_errno_prefix (error, "fsetxattr");
{
glnx_set_prefix_error_from_errno (error, "%s", "fsetxattr");
goto out;
}
} }
ret = TRUE; return TRUE;
out:
return ret;
} }
/** /**
@ -395,35 +374,17 @@ glnx_lgetxattrat (int dfd,
GError **error) GError **error)
{ {
char pathbuf[PATH_MAX]; char pathbuf[PATH_MAX];
GBytes *bytes = NULL;
ssize_t bytes_read, real_size;
guint8 *buf;
snprintf (pathbuf, sizeof (pathbuf), "/proc/self/fd/%d/%s", dfd, subpath); snprintf (pathbuf, sizeof (pathbuf), "/proc/self/fd/%d/%s", dfd, subpath);
do ssize_t bytes_read, real_size;
bytes_read = lgetxattr (pathbuf, attribute, NULL, 0); if (TEMP_FAILURE_RETRY (bytes_read = lgetxattr (pathbuf, attribute, NULL, 0)) < 0)
while (G_UNLIKELY (bytes_read < 0 && errno == EINTR)); return glnx_null_throw_errno_prefix (error, "lgetxattr");
if (G_UNLIKELY (bytes_read < 0))
{
glnx_set_error_from_errno (error);
goto out;
}
buf = g_malloc (bytes_read); g_autofree guint8 *buf = g_malloc (bytes_read);
do if (TEMP_FAILURE_RETRY (real_size = lgetxattr (pathbuf, attribute, buf, bytes_read)) < 0)
real_size = lgetxattr (pathbuf, attribute, buf, bytes_read); return glnx_null_throw_errno_prefix (error, "lgetxattr");
while (G_UNLIKELY (real_size < 0 && errno == EINTR));
if (G_UNLIKELY (real_size < 0))
{
glnx_set_error_from_errno (error);
g_free (buf);
goto out;
}
bytes = g_bytes_new_take (buf, real_size); return g_bytes_new_take (g_steal_pointer (&buf), real_size);
out:
return bytes;
} }
/** /**
@ -439,33 +400,16 @@ glnx_fgetxattr_bytes (int fd,
const char *attribute, const char *attribute,
GError **error) GError **error)
{ {
GBytes *bytes = NULL;
ssize_t bytes_read, real_size; ssize_t bytes_read, real_size;
guint8 *buf;
do if (TEMP_FAILURE_RETRY (bytes_read = fgetxattr (fd, attribute, NULL, 0)) < 0)
bytes_read = fgetxattr (fd, attribute, NULL, 0); return glnx_null_throw_errno_prefix (error, "fgetxattr");
while (G_UNLIKELY (bytes_read < 0 && errno == EINTR));
if (G_UNLIKELY (bytes_read < 0))
{
glnx_set_error_from_errno (error);
goto out;
}
buf = g_malloc (bytes_read); g_autofree guint8 *buf = g_malloc (bytes_read);
do if (TEMP_FAILURE_RETRY (real_size = fgetxattr (fd, attribute, buf, bytes_read)) < 0)
real_size = fgetxattr (fd, attribute, buf, bytes_read); return glnx_null_throw_errno_prefix (error, "fgetxattr");
while (G_UNLIKELY (real_size < 0 && errno == EINTR));
if (G_UNLIKELY (real_size < 0))
{
glnx_set_error_from_errno (error);
g_free (buf);
goto out;
}
bytes = g_bytes_new_take (buf, real_size); return g_bytes_new_take (g_steal_pointer (&buf), real_size);
out:
return bytes;
} }
/** /**
@ -490,18 +434,10 @@ glnx_lsetxattrat (int dfd,
GError **error) GError **error)
{ {
char pathbuf[PATH_MAX]; char pathbuf[PATH_MAX];
int res;
snprintf (pathbuf, sizeof (pathbuf), "/proc/self/fd/%d/%s", dfd, subpath); snprintf (pathbuf, sizeof (pathbuf), "/proc/self/fd/%d/%s", dfd, subpath);
do if (TEMP_FAILURE_RETRY (lsetxattr (subpath, attribute, value, len, flags)) < 0)
res = lsetxattr (subpath, attribute, value, len, flags); return glnx_throw_errno_prefix (error, "lsetxattr");
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
glnx_set_error_from_errno (error);
return FALSE;
}
return TRUE; return TRUE;
} }

View File

@ -24,7 +24,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#include <glnx-alloca.h> #include <glnx-macros.h>
#include <glnx-local-alloc.h> #include <glnx-local-alloc.h>
#include <glnx-backport-autocleanups.h> #include <glnx-backport-autocleanups.h>
#include <glnx-backports.h> #include <glnx-backports.h>

View File

@ -80,11 +80,8 @@ test_renameat2_noreplace (void)
glnx_set_error_from_errno (error); glnx_set_error_from_errno (error);
goto out; goto out;
} }
if (fstatat (destfd, "bar", &stbuf, AT_SYMLINK_NOFOLLOW) < 0) if (!glnx_fstatat (destfd, "bar", &stbuf, AT_SYMLINK_NOFOLLOW, error))
{ goto out;
glnx_set_error_from_errno (error);
goto out;
}
if (fstatat (srcfd, "foo", &stbuf, AT_SYMLINK_NOFOLLOW) == 0) if (fstatat (srcfd, "foo", &stbuf, AT_SYMLINK_NOFOLLOW) == 0)
g_assert_not_reached (); g_assert_not_reached ();

View File

@ -0,0 +1,109 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2017 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "libglnx.h"
#include <glib.h>
#include <stdlib.h>
#include <gio/gio.h>
#include <string.h>
static void
test_inset (void)
{
g_assert (G_IN_SET (7, 7));
g_assert (G_IN_SET (7, 42, 7));
g_assert (G_IN_SET (7, 7,42,3,9));
g_assert (G_IN_SET (42, 7,42,3,9));
g_assert (G_IN_SET (3, 7,42,3,9));
g_assert (G_IN_SET (9, 7,42,3,9));
g_assert (!G_IN_SET (8, 7,42,3,9));
g_assert (!G_IN_SET (-1, 7,42,3,9));
g_assert (G_IN_SET ('x', 'a', 'x', 'c'));
g_assert (!G_IN_SET ('y', 'a', 'x', 'c'));
}
static void
test_hash_table_foreach (void)
{
/* use var names all different from the macro metavars to ensure proper
* substitution */
g_autoptr(GHashTable) table = g_hash_table_new (g_str_hash, g_str_equal);
const char *keys[] = {"key1", "key2"};
const char *vals[] = {"val1", "val2"};
g_hash_table_insert (table, (gpointer)keys[0], (gpointer)vals[0]);
g_hash_table_insert (table, (gpointer)keys[1], (gpointer)vals[1]);
guint i = 0;
GLNX_HASH_TABLE_FOREACH_IT (table, it, const char*, key, const char*, val)
{
g_assert_cmpstr (key, ==, keys[i]);
g_assert_cmpstr (val, ==, vals[i]);
i++;
}
g_assert_cmpuint (i, ==, 2);
i = 0;
GLNX_HASH_TABLE_FOREACH_IT (table, it, const char*, key, const char*, val)
{
g_hash_table_iter_remove (&it);
break;
}
g_assert_cmpuint (g_hash_table_size (table), ==, 1);
g_hash_table_insert (table, (gpointer)keys[1], (gpointer)vals[1]);
g_assert_cmpuint (g_hash_table_size (table), ==, 1);
g_hash_table_insert (table, (gpointer)keys[0], (gpointer)vals[0]);
g_assert_cmpuint (g_hash_table_size (table), ==, 2);
i = 0;
GLNX_HASH_TABLE_FOREACH_KV (table, const char*, key, const char*, val)
{
g_assert_cmpstr (key, ==, keys[i]);
g_assert_cmpstr (val, ==, vals[i]);
i++;
}
g_assert_cmpuint (i, ==, 2);
i = 0;
GLNX_HASH_TABLE_FOREACH (table, const char*, key)
{
g_assert_cmpstr (key, ==, keys[i]);
i++;
}
g_assert_cmpuint (i, ==, 2);
i = 0;
GLNX_HASH_TABLE_FOREACH_V (table, const char*, val)
{
g_assert_cmpstr (val, ==, vals[i]);
i++;
}
g_assert_cmpuint (i, ==, 2);
}
int main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/inset", test_inset);
g_test_add_func ("/hash_table_foreach", test_hash_table_foreach);
return g_test_run();
}

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin cleanup .\" Title: ostree admin cleanup
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin cleanup .\" Manual: ostree admin cleanup
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin config-diff .\" Title: ostree admin config-diff
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin config-diff .\" Manual: ostree admin config-diff
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin deploy .\" Title: ostree admin deploy
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin deploy .\" Manual: ostree admin deploy
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin init-fs .\" Title: ostree admin init-fs
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin init-fs .\" Manual: ostree admin init-fs
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin instutil .\" Title: ostree admin instutil
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin instutil .\" Manual: ostree admin instutil
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin os-init .\" Title: ostree admin os-init
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin os-init .\" Manual: ostree admin os-init
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin set-origin .\" Title: ostree admin set-origin
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin set-origin .\" Manual: ostree admin set-origin
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin status .\" Title: ostree admin status
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin status .\" Manual: ostree admin status
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin switch .\" Title: ostree admin switch
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin switch .\" Manual: ostree admin switch
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin undeploy .\" Title: ostree admin undeploy
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin undeploy .\" Manual: ostree admin undeploy
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin unlock .\" Title: ostree admin unlock
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin unlock .\" Manual: ostree admin unlock
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin upgrade .\" Title: ostree admin upgrade
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin upgrade .\" Manual: ostree admin upgrade
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree admin .\" Title: ostree admin
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree admin .\" Manual: ostree admin
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree cat .\" Title: ostree cat
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree cat .\" Manual: ostree cat
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree checkout .\" Title: ostree checkout
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree checkout .\" Manual: ostree checkout
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree checksum .\" Title: ostree checksum
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree checksum .\" Manual: ostree checksum
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree commit .\" Title: ostree commit
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree commit .\" Manual: ostree commit
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree config .\" Title: ostree config
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree config .\" Manual: ostree config
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree diff .\" Title: ostree diff
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree diff .\" Manual: ostree diff
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree export .\" Title: ostree export
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree export .\" Manual: ostree export
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree fsck .\" Title: ostree fsck
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree fsck .\" Manual: ostree fsck
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree gpg-sign .\" Title: ostree gpg-sign
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree gpg-sign .\" Manual: ostree gpg-sign
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree init .\" Title: ostree init
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 07/04/2017
.\" Manual: ostree init .\" Manual: ostree init
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English
@ -41,3 +41,14 @@ Creates a new empty repository\&.
.RS 4 .RS 4
Initialize repository in given mode (bare, bare\-user, archive\-z2)\&. Default is "bare"\&. Initialize repository in given mode (bare, bare\-user, archive\-z2)\&. Default is "bare"\&.
.RE .RE
.PP
\fB\-\-collection\-id\fR=COLLECTION\-ID
.RS 4
Set the collection ID of the repository\&. Remotes in clones of this repository must configure the same value in order to pull refs which originated in this repository over peer to peer\&.
.sp
This collection ID must be persistent and globally unique\&. It is formatted as a reverse DNS name (like a D\-Bus interface)\&. It must be set to a reverse DNS domain under your control\&.
.sp
This option may be omitted (the default) to leave peer to peer distribution unsupported for the repository\&. A collection ID may be added to an existing repository in future to enable peer to peer distribution from that point onwards\&.
.sp
If the collection ID is changed for the repository in future, peer to peer distribution of refs from the repository will break for all peers who do not update their remote configuration to the new collection ID\&.
.RE

View File

@ -71,6 +71,32 @@ Boston, MA 02111-1307, USA.
Initialize repository in given mode (bare, bare-user, archive-z2). Default is "bare". Initialize repository in given mode (bare, bare-user, archive-z2). Default is "bare".
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--collection-id</option>=COLLECTION-ID</term>
<listitem><para>
Set the collection ID of the repository. Remotes in clones
of this repository must configure the same value in order to
pull refs which originated in this repository over peer to
peer.</para>
<para>This collection ID must be persistent and globally
unique. It is formatted as a reverse DNS name (like a D-Bus
interface). It must be set to a reverse DNS domain under your
control.</para>
<para>This option may be omitted (the default) to leave
peer to peer distribution unsupported for the repository. A
collection ID may be added to an existing repository in
future to enable peer to peer distribution from that point
onwards.</para>
<para>If the collection ID is changed for the repository
in future, peer to peer distribution of refs from the
repository will break for all peers who do not update their
remote configuration to the new collection ID.
</para></listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>

View File

@ -2,7 +2,7 @@
.\" Title: ostree log .\" Title: ostree log
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree log .\" Manual: ostree log
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree ls .\" Title: ostree ls
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree ls .\" Manual: ostree ls
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree prune .\" Title: ostree prune
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree prune .\" Manual: ostree prune
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree pull-local .\" Title: ostree pull-local
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree pull-local .\" Manual: ostree pull-local
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree pull .\" Title: ostree pull
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 07/04/2017
.\" Manual: ostree pull .\" Manual: ostree pull
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English
@ -44,6 +44,12 @@ Fetch only the commit metadata\&.
Do no invoke fsync()\&. Do no invoke fsync()\&.
.RE .RE
.PP .PP
\fB\-\-localcache\-repo\fR
.RS 4
Like git\*(Aqs
clone \-\-reference\&. Reuse the provided OSTree repo as a local object cache of objects when doing HTTP fetches\&. May be specified multiple times\&.
.RE
.PP
\fB\-\-untrusted\fR \fB\-\-untrusted\fR
.RS 4 .RS 4
Do not trust local sources, verify checksums and don\*(Aqt hardlink into source\&. Do not trust local sources, verify checksums and don\*(Aqt hardlink into source\&.

View File

@ -73,6 +73,16 @@ Boston, MA 02111-1307, USA.
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--localcache-repo</option></term>
<listitem><para>
Like git's <literal>clone --reference</literal>. Reuse the provided
OSTree repo as a local object cache of objects when doing HTTP fetches.
May be specified multiple times.
</para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--untrusted</option></term> <term><option>--untrusted</option></term>

View File

@ -2,7 +2,7 @@
.\" Title: ostree refs .\" Title: ostree refs
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 07/04/2017
.\" Manual: ostree refs .\" Manual: ostree refs
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English
@ -51,6 +51,21 @@ Delete refs which match PREFIX, rather than listing them\&. If you are trying to
or or
\fBostree admin cleanup\fR\&. \fBostree admin cleanup\fR\&.
.RE .RE
.PP
\fB\-\-collections\fR
.RS 4
Enable interactions with refs using the combination of their collection IDs and ref names\&. When listing refs, this changes the output format to include collection IDs, and enables listing remote mirrored refs\&.
.sp
When creating refs, the refspec value passed to the
\fB\-\-create\fR
option is treated as
COLLECTION\-ID:REF\-NAME
and a mirrored ref is created\&. (This is an abuse of the refspec syntax\&.)
.sp
When deleting refs, all refs whose collection ID equals the value of the
\fB\-\-delete\fR
argument are deleted\&.
.RE
.SH "EXAMPLE" .SH "EXAMPLE"
.PP .PP
\fB$ ostree refs\fR \fB$ ostree refs\fR

View File

@ -83,6 +83,26 @@ Boston, MA 02111-1307, USA.
you will then need to <command>ostree prune</command> or <command>ostree admin cleanup</command>. you will then need to <command>ostree prune</command> or <command>ostree admin cleanup</command>.
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--collections</option></term>
<listitem><para>
Enable interactions with refs using the combination of their
collection IDs and ref names. When listing refs, this changes
the output format to include collection IDs, and enables
listing remote mirrored refs.</para>
<para>When creating refs, the refspec value passed to the
<option>--create</option> option is treated as
<literal>COLLECTION-ID:REF-NAME</literal> and a mirrored ref
is created. (This is an abuse of the refspec syntax.)</para>
<para>When deleting refs, all refs whose collection ID equals
the value of the <option>--delete</option> argument are
deleted.
</para></listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>

View File

@ -2,7 +2,7 @@
.\" Title: ostree remote .\" Title: ostree remote
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 07/04/2017
.\" Manual: ostree remote .\" Manual: ostree remote
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English
@ -86,6 +86,11 @@ Import one or more GPG keys from a file\&.
Equivalent to Equivalent to
\fBostree remote gpg\-import \-\-keyring=FILE\fR\&. \fBostree remote gpg\-import \-\-keyring=FILE\fR\&.
.RE .RE
.PP
\fB\-\-collection\-id\fR=COLLECTION\-ID
.RS 4
Set the collection ID for the remote to a value provided by the repository owner, which allows refs from this remote to be shared peer to peer\&.
.RE
.SH "\*(AQLIST\*(AQ OPTIONS" .SH "\*(AQLIST\*(AQ OPTIONS"
.PP .PP
\fB\-u, \-\-show\-urls\fR \fB\-u, \-\-show\-urls\fR

View File

@ -137,6 +137,16 @@ Boston, MA 02111-1307, USA.
<command>ostree remote gpg-import --keyring=FILE</command>. <command>ostree remote gpg-import --keyring=FILE</command>.
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--collection-id</option>=COLLECTION-ID</term>
<listitem><para>
Set the collection ID for the remote to a value provided by
the repository owner, which allows refs from this remote to be
shared peer to peer.
</para></listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>

View File

@ -2,7 +2,7 @@
.\" Title: ostree reset .\" Title: ostree reset
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree reset .\" Manual: ostree reset
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree rev-parse .\" Title: ostree rev-parse
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree rev-parse .\" Manual: ostree rev-parse
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree show .\" Title: ostree show
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree show .\" Manual: ostree show
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree static-delta .\" Title: ostree static-delta
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree static-delta .\" Manual: ostree static-delta
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree summary .\" Title: ostree summary
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 07/04/2017
.\" Manual: ostree summary .\" Manual: ostree summary
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English
@ -42,6 +42,11 @@ file is an optional higher level form of repository metadata that describes the
\fB\-u\fR \fB\-u\fR
.RS 4 .RS 4
Update the summary file\&. Update the summary file\&.
.sp
Any additional arguments to the command are treated as additional key\(envalue pairs to be added to the summary file as additional metadata\&. They must be in the format
\fB\fIKEY\fR\fR\fB=\fR\fB\fIVALUE\fR\fR
or as two separate arguments\&. The keys must be namespaced for your organisation or repository using a dot prefix\&. The values must be in GVariant text format\&. For example,
\fBexampleos\&.end\-of\-life "@t 1445385600"\fR\&.
.RE .RE
.PP .PP
\fB\-\-gpg\-sign\fR=KEYID \fB\-\-gpg\-sign\fR=KEYID

View File

@ -73,7 +73,16 @@ Boston, MA 02111-1307, USA.
<term><option>-u</option></term> <term><option>-u</option></term>
<listitem><para> <listitem><para>
Update the summary file. Update the summary file.
</para><para>
Any additional arguments to the command
are treated as additional keyvalue pairs to be added to the
summary file as additional metadata. They must be in the format
<command><replaceable>KEY</replaceable>=<replaceable>VALUE</replaceable></command>
or as two separate arguments. The keys must be namespaced for
your organisation or repository using a dot prefix. The values
must be in GVariant text format. For example,
<command>exampleos.end-of-life "@t 1445385600"</command>.
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>

View File

@ -0,0 +1,116 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
Copyright 2011,2013 Colin Walters <walters@verbum.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-->
<refentry id="ostree">
<refentryinfo>
<title>ostree trivial-httpd</title>
<productname>OSTree</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Colin</firstname>
<surname>Walters</surname>
<email>walters@verbum.org</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>ostree trivial-httpd</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>ostree-trivial-httpd</refname>
<refpurpose>Simple webserver</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>ostree trivial-httpd</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="opt">DIR</arg>
</cmdsynopsis>
</refsynopsisdiv>
<!-- Don't entirely understand this command. Needs details, better content-->
<refsect1>
<title>Description</title>
<para>
This runs a simple webserver and keeps it running until killed. If DIR is not specified, it defaults to the current directory.
</para>
</refsect1>
<refsect1>
<title>Options</title>
<variablelist>
<varlistentry>
<term><option>--daemonize</option>,<option>-d</option></term>
<listitem><para>
Fork into background when ready.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--autoexit</option></term>
<listitem><para>
Automatically exit when directory is deleted.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--port-file</option>,<option>-p</option>="PATH"</term>
<listitem><para>
Write port number to PATH (- for standard output).
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--port</option>,<option>-P</option></term>
<listitem><para>
Use the specified TCP port to listen on.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--force-range-requests</option></term>
<listitem><para>
Force range requests by only serving half of files.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<!-- NEED EXAMPLE OUTPUT HERE!-->
<refsect1>
<title>Example</title>
<para><command>$ ostree trivial-httpd</command></para>
</refsect1>
</refentry>

View File

@ -2,7 +2,7 @@
.\" Title: ostree .\" Title: ostree
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree .\" Manual: ostree
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: ostree.repo-config .\" Title: ostree.repo-config
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 07/05/2017
.\" Manual: ostree.repo-config .\" Manual: ostree.repo-config
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English
@ -136,6 +136,11 @@ Path to file containing trusted anchors instead of the system CA database\&.
.RS 4 .RS 4
If set, pulls from this remote will fail with the configured text\&. This is intended for OS vendors which have a subscription process to access content\&. If set, pulls from this remote will fail with the configured text\&. This is intended for OS vendors which have a subscription process to access content\&.
.RE .RE
.PP
\fImin\-free\-space\-percent\fR
.RS 4
Integer percentage value (0\-99) that specifies a minimum percentage of total space (in blocks) in the underlying filesystem to keep free\&. The default value is 3\&.
.RE
.SH "/ETC/OSTREE/REMOTES\&.D" .SH "/ETC/OSTREE/REMOTES\&.D"
.PP .PP
In addition to the In addition to the

View File

@ -190,6 +190,14 @@ Boston, MA 02111-1307, USA.
<term><varname>unconfigured-state</varname></term> <term><varname>unconfigured-state</varname></term>
<listitem><para>If set, pulls from this remote will fail with the configured text. This is intended for OS vendors which have a subscription process to access content.</para></listitem> <listitem><para>If set, pulls from this remote will fail with the configured text. This is intended for OS vendors which have a subscription process to access content.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><varname>min-free-space-percent</varname></term>
<listitem><para>Integer percentage value (0-99) that specifies a minimum
percentage of total space (in blocks) in the underlying filesystem to
keep free. The default value is 3.</para></listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>

View File

@ -2,7 +2,7 @@
.\" Title: ostree.repo .\" Title: ostree.repo
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: ostree.repo .\" Manual: ostree.repo
.\" Source: OSTree .\" Source: OSTree
.\" Language: English .\" Language: English

View File

@ -2,7 +2,7 @@
.\" Title: rofiles-fuse .\" Title: rofiles-fuse
.\" Author: Colin Walters <walters@verbum.org> .\" Author: Colin Walters <walters@verbum.org>
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/19/2017 .\" Date: 06/29/2017
.\" Manual: rofiles-fuse .\" Manual: rofiles-fuse
.\" Source: rofiles-fuse .\" Source: rofiles-fuse
.\" Language: English .\" Language: English

View File

@ -408,6 +408,11 @@ global:
ostree_sysroot_query_deployments_for; ostree_sysroot_query_deployments_for;
} LIBOSTREE_2017.6; } LIBOSTREE_2017.6;
LIBOSTREE_2017.8 {
global:
ostree_validate_remote_name;
} LIBOSTREE_2017.7;
/* NOTE: Only add more content here in release commits! See the /* NOTE: Only add more content here in release commits! See the
* comments at the top of this file. * comments at the top of this file.
*/ */

View File

@ -60,7 +60,15 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeSysrootUpgrader, g_object_unref)
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (OstreeRepoCommitTraverseIter, ostree_repo_commit_traverse_iter_clear) G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (OstreeRepoCommitTraverseIter, ostree_repo_commit_traverse_iter_clear)
#ifdef OSTREE_ENABLE_EXPERIMENTAL_API #ifdef OSTREE_ENABLE_EXPERIMENTAL_API
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeCollectionRef, ostree_collection_ref_free)
G_DEFINE_AUTO_CLEANUP_FREE_FUNC (OstreeCollectionRefv, ostree_collection_ref_freev, NULL)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRemote, ostree_remote_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRemote, ostree_remote_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinder, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinderAvahi, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinderConfig, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinderMount, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinderResult, ostree_repo_finder_result_free)
G_DEFINE_AUTO_CLEANUP_FREE_FUNC (OstreeRepoFinderResultv, ostree_repo_finder_result_freev, NULL)
#endif /* OSTREE_ENABLE_EXPERIMENTAL_API */ #endif /* OSTREE_ENABLE_EXPERIMENTAL_API */
#endif #endif

View File

@ -0,0 +1,104 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright © 2017 Endless Mobile, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* - Philip Withnall <withnall@endlessm.com>
*/
#pragma once
#include <gio/gio.h>
#include <glib.h>
#include <glib-object.h>
G_BEGIN_DECLS
/**
* OstreeBloom:
*
* An implementation of a [bloom filter](https://en.wikipedia.org/wiki/Bloom_filter)
* which is suitable for building a filter and looking keys up in an existing
* filter.
*
* Since: 2017.8
*/
typedef struct _OstreeBloom OstreeBloom;
/**
* OstreeBloomHashFunc:
* @element: a pointer to the element to hash
* @k: hash function parameter
*
* Function prototype for a
* [universal hash function](https://en.wikipedia.org/wiki/Universal_hashing),
* parameterised on @k, which hashes @element to a #guint64 hash value.
*
* It is up to the implementer of the hash function whether %NULL is valid for
* @element.
*
* Since: 2017.8
*/
typedef guint64 (*OstreeBloomHashFunc) (gconstpointer element,
guint8 k);
#define OSTREE_TYPE_BLOOM (ostree_bloom_get_type ())
G_GNUC_INTERNAL
GType ostree_bloom_get_type (void);
G_GNUC_INTERNAL
OstreeBloom *ostree_bloom_new (gsize n_bytes,
guint8 k,
OstreeBloomHashFunc hash_func);
G_GNUC_INTERNAL
OstreeBloom *ostree_bloom_new_from_bytes (GBytes *bytes,
guint8 k,
OstreeBloomHashFunc hash_func);
G_GNUC_INTERNAL
OstreeBloom *ostree_bloom_ref (OstreeBloom *bloom);
G_GNUC_INTERNAL
void ostree_bloom_unref (OstreeBloom *bloom);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeBloom, ostree_bloom_unref)
G_GNUC_INTERNAL
gboolean ostree_bloom_maybe_contains (OstreeBloom *bloom,
gconstpointer element);
G_GNUC_INTERNAL
GBytes *ostree_bloom_seal (OstreeBloom *bloom);
G_GNUC_INTERNAL
void ostree_bloom_add_element (OstreeBloom *bloom,
gconstpointer element);
G_GNUC_INTERNAL
gsize ostree_bloom_get_size (OstreeBloom *bloom);
G_GNUC_INTERNAL
guint8 ostree_bloom_get_k (OstreeBloom *bloom);
G_GNUC_INTERNAL
OstreeBloomHashFunc ostree_bloom_get_hash_func (OstreeBloom *bloom);
G_GNUC_INTERNAL
guint64 ostree_str_bloom_hash (gconstpointer element,
guint8 k);
G_END_DECLS

View File

@ -0,0 +1,603 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright © 2017 Endless Mobile, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* - Philip Withnall <withnall@endlessm.com>
*/
#include "config.h"
#include <assert.h>
#include <gio/gio.h>
#include <glib.h>
#include <glib-object.h>
#include <stdint.h>
#include <string.h>
#include "ostree-bloom-private.h"
/**
* SECTION:bloom
* @title: Bloom filter
* @short_description: Bloom filter implementation supporting building and
* reading filters
* @stability: Unstable
* @include: libostree/ostree-bloom-private.h
*
* #OstreeBloom is an implementation of a bloom filter which supports writing to
* and loading from a #GBytes bit array. The caller must store metadata about
* the bloom filter (its hash function and `k` parameter value) separately, as
* the same values must be used when reading from a serialised bit array as were
* used to build the array in the first place.
*
* This is a standard implementation of a bloom filter, and background reading
* on the theory can be
* [found on Wikipedia](https://en.wikipedia.org/wiki/Bloom_filter). In
* particular, a bloom filter is parameterised by `m` and `k` parameters: the
* size of the bit array (in bits) is `m`, and the number of hash functions
* applied to each element is `k`. Bloom filters require a universal hash
* function which can be parameterised by `k`. We have #OstreeBloomHashFunc,
* with ostree_str_bloom_hash() being an implementation for strings.
*
* The serialised output from a bloom filter is guaranteed to be stable across
* versions of libostree as long as the same values for `k` and the hash
* function are used.
*
* #OstreeBloom is mutable when constructed with ostree_bloom_new(), and elements
* can be added to it using ostree_bloom_add_element(), until ostree_bloom_seal()
* is called to serialise it and make it immutable. After then, the bloom filter
* can only be queried using ostree_bloom_maybe_contains().
*
* If constructed with ostree_bloom_new_from_bytes(), the bloom filter is
* immutable from construction, and can only be queried.
*
* Reference:
* - https://en.wikipedia.org/wiki/Bloom_filter
* - https://llimllib.github.io/bloomfilter-tutorial/
*
* Since: 2017.8
*/
struct _OstreeBloom
{
guint ref_count;
gsize n_bytes;
gboolean is_mutable; /* determines which of [im]mutable_bytes is accessed */
union
{
guint8 *mutable_bytes; /* owned; mutually exclusive */
GBytes *immutable_bytes; /* owned; mutually exclusive */
};
guint8 k;
OstreeBloomHashFunc hash_func;
};
G_DEFINE_BOXED_TYPE (OstreeBloom, ostree_bloom, ostree_bloom_ref, ostree_bloom_unref)
/**
* ostree_bloom_new:
* @n_bytes: size to make the bloom filter, in bytes
* @k: number of hash functions to use
* @hash_func: universal hash function to use
*
* Create a new mutable #OstreeBloom filter, with all its bits initialised to
* zero. Set elements in the filter using ostree_bloom_add_element(), and seal
* it to return an immutable #GBytes using ostree_bloom_seal().
*
* To load an #OstreeBloom from an existing #GBytes, use
* ostree_bloom_new_from_bytes().
*
* Note that @n_bytes is in bytes, so is 8 times smaller than the parameter `m`
* which is used when describing bloom filters academically.
*
* Returns: (transfer full): a new mutable bloom filter
*
* Since: 2017.8
*/
OstreeBloom *
ostree_bloom_new (gsize n_bytes,
guint8 k,
OstreeBloomHashFunc hash_func)
{
g_autoptr(OstreeBloom) bloom = NULL;
g_return_val_if_fail (n_bytes > 0, NULL);
g_return_val_if_fail (k > 0, NULL);
g_return_val_if_fail (hash_func != NULL, NULL);
bloom = g_new0 (OstreeBloom, 1);
bloom->ref_count = 1;
bloom->is_mutable = TRUE;
bloom->mutable_bytes = g_malloc0 (n_bytes);
bloom->n_bytes = n_bytes;
bloom->k = k;
bloom->hash_func = hash_func;
return g_steal_pointer (&bloom);
}
/**
* ostree_bloom_new_from_bytes:
* @bytes: array of bytes containing the filter data
* @k: number of hash functions to use
* @hash_func: universal hash function to use
*
* Load an immutable #OstreeBloom filter from the given @bytes. Check whether
* elements are probably set in the filter using ostree_bloom_maybe_contains().
*
* To create a new mutable #OstreeBloom, use ostree_bloom_new().
*
* Note that all the bits in @bytes are loaded, so the parameter `m` for the
* filter (as commonly used in academic literature) is always a multiple of 8.
*
* Returns: (transfer full): a new immutable bloom filter
*
* Since: 2017.8
*/
OstreeBloom *
ostree_bloom_new_from_bytes (GBytes *bytes,
guint8 k,
OstreeBloomHashFunc hash_func)
{
g_autoptr(OstreeBloom) bloom = NULL;
g_return_val_if_fail (bytes != NULL, NULL);
g_return_val_if_fail (g_bytes_get_size (bytes) > 0, NULL);
g_return_val_if_fail (k > 0, NULL);
g_return_val_if_fail (hash_func != NULL, NULL);
bloom = g_new0 (OstreeBloom, 1);
bloom->ref_count = 1;
bloom->is_mutable = FALSE;
bloom->immutable_bytes = g_bytes_ref (bytes);
bloom->n_bytes = g_bytes_get_size (bytes);
bloom->k = k;
bloom->hash_func = hash_func;
return g_steal_pointer (&bloom);
}
/**
* ostree_bloom_ref:
* @bloom: an #OstreeBloom
*
* Increase the reference count of @bloom.
*
* Returns: (transfer full): @bloom
* Since: 2017.8
*/
OstreeBloom *
ostree_bloom_ref (OstreeBloom *bloom)
{
g_return_val_if_fail (bloom != NULL, NULL);
g_return_val_if_fail (bloom->ref_count >= 1, NULL);
g_return_val_if_fail (bloom->ref_count == G_MAXUINT - 1, NULL);
bloom->ref_count++;
return bloom;
}
/**
* ostree_bloom_unref:
* @bloom: (transfer full): an #OstreeBloom
*
* Decrement the reference count of @bloom. If it reaches zero, the filter
* is destroyed.
*
* Since: 2017.8
*/
void
ostree_bloom_unref (OstreeBloom *bloom)
{
g_return_if_fail (bloom != NULL);
g_return_if_fail (bloom->ref_count >= 1);
bloom->ref_count--;
if (bloom->ref_count == 0)
{
if (bloom->is_mutable)
g_clear_pointer (&bloom->mutable_bytes, g_free);
else
g_clear_pointer (&bloom->immutable_bytes, g_bytes_unref);
bloom->n_bytes = 0;
g_free (bloom);
}
}
/* @idx is in bits, not bytes. */
static inline gboolean
ostree_bloom_get_bit (OstreeBloom *bloom,
gsize idx)
{
const guint8 *bytes;
if (bloom->is_mutable)
bytes = bloom->mutable_bytes;
else
bytes = g_bytes_get_data (bloom->immutable_bytes, NULL);
g_assert (idx / 8 < bloom->n_bytes);
return (bytes[idx / 8] & (1 << (idx % 8)));
}
/* @idx is in bits, not bytes. */
static inline void
ostree_bloom_set_bit (OstreeBloom *bloom,
gsize idx)
{
g_assert (bloom->is_mutable);
g_assert (idx / 8 < bloom->n_bytes);
bloom->mutable_bytes[idx / 8] |= (1 << (idx % 8));
}
/**
* ostree_bloom_maybe_contains:
* @bloom: an #OstreeBloom
* @element: (nullable): element to check for membership
*
* Check whether @element is potentially in @bloom, or whether it definitely
* isnt. @element may be %NULL only if the hash function passed to @bloom at
* construction time supports %NULL elements.
*
* Returns: %TRUE if @element is potentially in @bloom; %FALSE if it definitely
* isnt
* Since: 2017.8
*/
gboolean
ostree_bloom_maybe_contains (OstreeBloom *bloom,
gconstpointer element)
{
guint8 i;
g_return_val_if_fail (bloom != NULL, TRUE);
g_return_val_if_fail (bloom->ref_count >= 1, TRUE);
for (i = 0; i < bloom->k; i++)
{
gsize idx;
idx = bloom->hash_func (element, i);
if (!ostree_bloom_get_bit (bloom, idx % (bloom->n_bytes * 8)))
return FALSE; /* definitely not in the set */
}
return TRUE; /* possibly in the set */
}
/**
* ostree_bloom_seal:
* @bloom: an #OstreeBloom
*
* Seal a constructed bloom filter, so that elements may no longer be added to
* it, and queries can now be performed against it. The serialised form of the
* bloom filter is returned as a bit array. Note that this does not include
* information about the filter hash function or parameters; the caller is
* responsible for serialising those separately if appropriate.
*
* It is safe to call this function multiple times.
*
* Returns: (transfer full): a #GBytes containing the immutable filter data
* Since: 2017.8
*/
GBytes *
ostree_bloom_seal (OstreeBloom *bloom)
{
g_return_val_if_fail (bloom != NULL, NULL);
g_return_val_if_fail (bloom->ref_count >= 1, NULL);
if (bloom->is_mutable)
{
bloom->is_mutable = FALSE;
bloom->immutable_bytes = g_bytes_new_take (g_steal_pointer (&bloom->mutable_bytes), bloom->n_bytes);
}
return g_bytes_ref (bloom->immutable_bytes);
}
/**
* ostree_bloom_add_element:
* @bloom: an #OstreeBloom
* @element: (nullable): element to add to the filter
*
* Add the given @element to the bloom filter, which must not yet have been
* sealed (ostree_bloom_seal()). @element may be %NULL if the hash function
* passed to @bloom at construction time supports %NULL elements.
*
* Since: 2017.8
*/
void
ostree_bloom_add_element (OstreeBloom *bloom,
gconstpointer element)
{
guint8 i;
g_return_if_fail (bloom != NULL);
g_return_if_fail (bloom->ref_count >= 1);
g_return_if_fail (bloom->is_mutable);
for (i = 0; i < bloom->k; i++)
{
gsize idx = bloom->hash_func (element, i);
ostree_bloom_set_bit (bloom, idx % (bloom->n_bytes * 8));
}
}
/**
* ostree_bloom_get_size:
* @bloom: an #OstreeBloom
*
* Get the size of the #OstreeBloom filter, in bytes, as configured at
* construction time.
*
* Returns: the bloom filters size in bytes, guaranteed to be >0
* Since: 2017.8
*/
gsize
ostree_bloom_get_size (OstreeBloom *bloom)
{
g_return_val_if_fail (bloom != NULL, 0);
return bloom->n_bytes;
}
/**
* ostree_bloom_get_k:
* @bloom: an #OstreeBloom
*
* Get the `k` value from the #OstreeBloom filter, as configured at
* construction time.
*
* Returns: the bloom filters `k` value, guaranteed to be >0
* Since: 2017.8
*/
guint8
ostree_bloom_get_k (OstreeBloom *bloom)
{
g_return_val_if_fail (bloom != NULL, 0);
return bloom->k;
}
/**
* ostree_bloom_get_hash_func:
* @bloom: an #OstreeBloom
*
* Get the #OstreeBloomHashFunc from the #OstreeBloom filter, as configured at
* construction time.
*
* Returns: the bloom filters universal hash function
* Since: 2017.8
*/
OstreeBloomHashFunc
ostree_bloom_get_hash_func (OstreeBloom *bloom)
{
g_return_val_if_fail (bloom != NULL, NULL);
return bloom->hash_func;
}
/* SipHash code adapted from https://github.com/veorq/SipHash/blob/master/siphash.c */
/*
SipHash reference C implementation
Copyright (c) 2012-2016 Jean-Philippe Aumasson
<jeanphilippe.aumasson@gmail.com>
Copyright (c) 2012-2014 Daniel J. Bernstein <djb@cr.yp.to>
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along
with
this software. If not, see
<http://creativecommons.org/publicdomain/zero/1.0/>.
*/
/* default: SipHash-2-4 */
#define cROUNDS 2
#define dROUNDS 4
#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
#define U32TO8_LE(p, v) \
(p)[0] = (uint8_t)((v)); \
(p)[1] = (uint8_t)((v) >> 8); \
(p)[2] = (uint8_t)((v) >> 16); \
(p)[3] = (uint8_t)((v) >> 24);
#define U64TO8_LE(p, v) \
U32TO8_LE((p), (uint32_t)((v))); \
U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
#define U8TO64_LE(p) \
(((uint64_t)((p)[0])) | ((uint64_t)((p)[1]) << 8) | \
((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) | \
((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) | \
((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
#define SIPROUND \
do { \
v0 += v1; \
v1 = ROTL(v1, 13); \
v1 ^= v0; \
v0 = ROTL(v0, 32); \
v2 += v3; \
v3 = ROTL(v3, 16); \
v3 ^= v2; \
v0 += v3; \
v3 = ROTL(v3, 21); \
v3 ^= v0; \
v2 += v1; \
v1 = ROTL(v1, 17); \
v1 ^= v2; \
v2 = ROTL(v2, 32); \
} while (0)
#ifdef DEBUG
#define TRACE \
do { \
printf("(%3d) v0 %08x %08x\n", (int)inlen, (uint32_t)(v0 >> 32), \
(uint32_t)v0); \
printf("(%3d) v1 %08x %08x\n", (int)inlen, (uint32_t)(v1 >> 32), \
(uint32_t)v1); \
printf("(%3d) v2 %08x %08x\n", (int)inlen, (uint32_t)(v2 >> 32), \
(uint32_t)v2); \
printf("(%3d) v3 %08x %08x\n", (int)inlen, (uint32_t)(v3 >> 32), \
(uint32_t)v3); \
} while (0)
#else
#define TRACE
#endif
static int siphash(const uint8_t *in, const size_t inlen, const uint8_t *k,
uint8_t *out, const size_t outlen) {
assert((outlen == 8) || (outlen == 16));
uint64_t v0 = 0x736f6d6570736575ULL;
uint64_t v1 = 0x646f72616e646f6dULL;
uint64_t v2 = 0x6c7967656e657261ULL;
uint64_t v3 = 0x7465646279746573ULL;
uint64_t k0 = U8TO64_LE(k);
uint64_t k1 = U8TO64_LE(k + 8);
uint64_t m;
int i;
const uint8_t *end = in + inlen - (inlen % sizeof(uint64_t));
const int left = inlen & 7;
uint64_t b = ((uint64_t)inlen) << 56;
v3 ^= k1;
v2 ^= k0;
v1 ^= k1;
v0 ^= k0;
if (outlen == 16)
v1 ^= 0xee;
for (; in != end; in += 8) {
m = U8TO64_LE(in);
v3 ^= m;
TRACE;
for (i = 0; i < cROUNDS; ++i)
SIPROUND;
v0 ^= m;
}
switch (left) {
case 7:
b |= ((uint64_t)in[6]) << 48;
case 6:
b |= ((uint64_t)in[5]) << 40;
case 5:
b |= ((uint64_t)in[4]) << 32;
case 4:
b |= ((uint64_t)in[3]) << 24;
case 3:
b |= ((uint64_t)in[2]) << 16;
case 2:
b |= ((uint64_t)in[1]) << 8;
case 1:
b |= ((uint64_t)in[0]);
break;
case 0:
break;
}
v3 ^= b;
TRACE;
for (i = 0; i < cROUNDS; ++i)
SIPROUND;
v0 ^= b;
if (outlen == 16)
v2 ^= 0xee;
else
v2 ^= 0xff;
TRACE;
for (i = 0; i < dROUNDS; ++i)
SIPROUND;
b = v0 ^ v1 ^ v2 ^ v3;
U64TO8_LE(out, b);
if (outlen == 8)
return 0;
v1 ^= 0xdd;
TRACE;
for (i = 0; i < dROUNDS; ++i)
SIPROUND;
b = v0 ^ v1 ^ v2 ^ v3;
U64TO8_LE(out + 8, b);
return 0;
}
/* End SipHash copied code. */
/**
* ostree_str_bloom_hash:
* @element: element to calculate the hash for
* @k: hash function index
*
* A universal hash function implementation for strings. It expects @element to
* be a pointer to a string (i.e. @element has type `const gchar*`), and expects
* @k to be in the range `[0, k_max)`, where `k_max` is the `k` value used to
* construct the bloom filter. The output range from this hash function could be
* any value in #guint64, and it handles input strings of any length.
*
* This function does not allow %NULL as a valid value for @element.
*
* Reference:
* - https://www.131002.net/siphash/
*
* Returns: hash of the string at @element using parameter @k
* Since: 2017.8
*/
guint64
ostree_str_bloom_hash (gconstpointer element,
guint8 k)
{
const gchar *str = element;
gsize str_len;
union
{
guint64 u64;
guint8 u8[8];
} out_le;
guint8 k_array[16];
gsize i;
str_len = strlen (str);
for (i = 0; i < G_N_ELEMENTS (k_array); i++)
k_array[i] = k;
siphash ((const guint8 *) str, str_len, k_array, out_le.u8, sizeof (out_le));
return le64toh (out_le.u64);
}

View File

@ -48,15 +48,11 @@ OstreeBootconfigParser *
ostree_bootconfig_parser_clone (OstreeBootconfigParser *self) ostree_bootconfig_parser_clone (OstreeBootconfigParser *self)
{ {
OstreeBootconfigParser *parser = ostree_bootconfig_parser_new (); OstreeBootconfigParser *parser = ostree_bootconfig_parser_new ();
guint i;
GHashTableIter hashiter;
gpointer k, v;
for (i = 0; i < self->lines->len; i++) for (guint i = 0; i < self->lines->len; i++)
g_ptr_array_add (parser->lines, g_variant_ref (self->lines->pdata[i])); g_ptr_array_add (parser->lines, g_variant_ref (self->lines->pdata[i]));
g_hash_table_iter_init (&hashiter, self->options); GLNX_HASH_TABLE_FOREACH_KV (self->options, const char*, k, const char*, v)
while (g_hash_table_iter_next (&hashiter, &k, &v))
g_hash_table_replace (parser->options, g_strdup (k), g_strdup (v)); g_hash_table_replace (parser->options, g_strdup (k), g_strdup (v));
return parser; return parser;
@ -183,14 +179,11 @@ ostree_bootconfig_parser_write_at (OstreeBootconfigParser *self,
} }
} }
GHashTableIter hashiter; GLNX_HASH_TABLE_FOREACH_KV (self->options, const char*, k, const char*, v)
gpointer hashkey, hashvalue;
g_hash_table_iter_init (&hashiter, self->options);
while (g_hash_table_iter_next (&hashiter, &hashkey, &hashvalue))
{ {
if (g_hash_table_lookup (written_overrides, hashkey)) if (g_hash_table_lookup (written_overrides, k))
continue; continue;
write_key (self, buf, hashkey, hashvalue); write_key (self, buf, k, v);
} }
if (!glnx_file_replace_contents_at (dfd, path, (guint8*)buf->str, buf->len, if (!glnx_file_replace_contents_at (dfd, path, (guint8*)buf->str, buf->len,

View File

@ -21,6 +21,7 @@
#pragma once #pragma once
#include "ostree-core.h" #include "ostree-core.h"
#include <sys/stat.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -88,7 +89,8 @@ _ostree_make_temporary_symlink_at (int tmp_dirfd,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
GFileInfo * _ostree_header_gfile_info_new (mode_t mode, uid_t uid, gid_t gid); GFileInfo * _ostree_stbuf_to_gfileinfo (const struct stat *stbuf);
GFileInfo * _ostree_mode_uidgid_to_gfileinfo (mode_t mode, uid_t uid, gid_t gid);
static inline void static inline void
_ostree_checksum_inplace_from_bytes_v (GVariant *csum_v, char *buf) _ostree_checksum_inplace_from_bytes_v (GVariant *csum_v, char *buf)
@ -173,6 +175,29 @@ _ostree_raw_file_to_archive_stream (GInputStream *input,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
#ifndef OSTREE_ENABLE_EXPERIMENTAL_API
gboolean ostree_validate_collection_id (const char *collection_id, GError **error);
#endif /* !OSTREE_ENABLE_EXPERIMENTAL_API */
#if (defined(OSTREE_COMPILATION) || GLIB_CHECK_VERSION(2, 44, 0)) && !defined(OSTREE_ENABLE_EXPERIMENTAL_API)
#include <libglnx.h>
#include "ostree-ref.h"
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeCollectionRef, ostree_collection_ref_free)
G_DEFINE_AUTO_CLEANUP_FREE_FUNC (OstreeCollectionRefv, ostree_collection_ref_freev, NULL)
#include "ostree-repo-finder.h"
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinder, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinderResult, ostree_repo_finder_result_free)
G_DEFINE_AUTO_CLEANUP_FREE_FUNC (OstreeRepoFinderResultv, ostree_repo_finder_result_freev, NULL)
#include "ostree-repo-finder-avahi.h"
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinderAvahi, g_object_unref)
#include "ostree-repo-finder-config.h"
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinderConfig, g_object_unref)
#include "ostree-repo-finder-mount.h"
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinderMount, g_object_unref)
#endif
G_END_DECLS G_END_DECLS

View File

@ -101,6 +101,7 @@ ostree_validate_checksum_string (const char *sha256,
#define OSTREE_REF_FRAGMENT_REGEXP "[-._\\w\\d]+" #define OSTREE_REF_FRAGMENT_REGEXP "[-._\\w\\d]+"
#define OSTREE_REF_REGEXP "(?:" OSTREE_REF_FRAGMENT_REGEXP "/)*" OSTREE_REF_FRAGMENT_REGEXP #define OSTREE_REF_REGEXP "(?:" OSTREE_REF_FRAGMENT_REGEXP "/)*" OSTREE_REF_FRAGMENT_REGEXP
#define OSTREE_REMOTE_NAME_REGEXP OSTREE_REF_FRAGMENT_REGEXP
/** /**
* ostree_parse_refspec: * ostree_parse_refspec:
@ -125,7 +126,7 @@ ostree_parse_refspec (const char *refspec,
static gsize regex_initialized; static gsize regex_initialized;
if (g_once_init_enter (&regex_initialized)) if (g_once_init_enter (&regex_initialized))
{ {
regex = g_regex_new ("^(" OSTREE_REF_FRAGMENT_REGEXP ":)?(" OSTREE_REF_REGEXP ")$", 0, 0, NULL); regex = g_regex_new ("^(" OSTREE_REMOTE_NAME_REGEXP ":)?(" OSTREE_REF_REGEXP ")$", 0, 0, NULL);
g_assert (regex); g_assert (regex);
g_once_init_leave (&regex_initialized, 1); g_once_init_leave (&regex_initialized, 1);
} }
@ -180,6 +181,67 @@ ostree_validate_rev (const char *rev,
return TRUE; return TRUE;
} }
/**
* ostree_validate_remote_name:
* @remote_name: A remote name
* @error: Error
*
* Returns: %TRUE if @remote_name is a valid remote name
* Since: 2017.8
*/
gboolean
ostree_validate_remote_name (const char *remote_name,
GError **error)
{
g_autoptr(GMatchInfo) match = NULL;
static gsize regex_initialized;
static GRegex *regex;
if (g_once_init_enter (&regex_initialized))
{
regex = g_regex_new ("^" OSTREE_REMOTE_NAME_REGEXP "$", 0, 0, NULL);
g_assert (regex);
g_once_init_leave (&regex_initialized, 1);
}
if (!g_regex_match (regex, remote_name, 0, &match))
return glnx_throw (error, "Invalid remote name %s", remote_name);
return TRUE;
}
/**
* ostree_validate_collection_id:
* @rev: (nullable): A collection ID
* @error: Error
*
* Check whether the given @collection_id is valid. Return an error if it is
* invalid or %NULL.
*
* Valid collection IDs are reverse DNS names:
* * They are composed of 1 or more elements separated by a period (`.`) character.
* All elements must contain at least one character.
* * Each element must only contain the ASCII characters `[A-Z][a-z][0-9]_` and must not
* begin with a digit.
* * They must contain at least one `.` (period) character (and thus at least two elements).
* * They must not begin with a `.` (period) character.
* * They must not exceed 255 characters in length.
*
* (This makes their format identical to D-Bus interface names, for consistency.)
*
* Returns: %TRUE if @collection_id is a valid collection ID, %FALSE if it is invalid
* or %NULL
*/
gboolean
ostree_validate_collection_id (const char *collection_id, GError **error)
{
/* Abuse g_dbus_is_interface_name(), since collection IDs have the same format. */
if (collection_id == NULL || !g_dbus_is_interface_name (collection_id))
return glnx_throw (error, "Invalid collection ID %s", collection_id);
return TRUE;
}
GVariant * GVariant *
_ostree_file_header_new (GFileInfo *file_info, _ostree_file_header_new (GFileInfo *file_info,
GVariant *xattrs) GVariant *xattrs)
@ -614,7 +676,7 @@ ostree_content_stream_parse (gboolean compressed,
if (compressed) if (compressed)
{ {
if (!zlib_file_header_parse (file_header, if (!zlib_file_header_parse (file_header,
out_file_info ? &ret_file_info : NULL, &ret_file_info,
out_xattrs ? &ret_xattrs : NULL, out_xattrs ? &ret_xattrs : NULL,
error)) error))
return FALSE; return FALSE;
@ -622,12 +684,11 @@ ostree_content_stream_parse (gboolean compressed,
else else
{ {
if (!file_header_parse (file_header, if (!file_header_parse (file_header,
out_file_info ? &ret_file_info : NULL, &ret_file_info,
out_xattrs ? &ret_xattrs : NULL, out_xattrs ? &ret_xattrs : NULL,
error)) error))
return FALSE; return FALSE;
if (ret_file_info) g_file_info_set_size (ret_file_info, input_length - archive_header_size - 8);
g_file_info_set_size (ret_file_info, input_length - archive_header_size - 8);
} }
g_autoptr(GInputStream) ret_input = NULL; g_autoptr(GInputStream) ret_input = NULL;
@ -1432,7 +1493,7 @@ _ostree_loose_path (char *buf,
} }
/** /**
* _ostree_header_gfile_info_new: * _ostree_stbuf_to_gfileinfo:
* @mode: File mode * @mode: File mode
* @uid: File uid * @uid: File uid
* @gid: File gid * @gid: File gid
@ -1445,17 +1506,42 @@ _ostree_loose_path (char *buf,
* Returns: (transfer full): A new #GFileInfo mapping a subset of @stbuf. * Returns: (transfer full): A new #GFileInfo mapping a subset of @stbuf.
*/ */
GFileInfo * GFileInfo *
_ostree_header_gfile_info_new (mode_t mode, uid_t uid, gid_t gid) _ostree_stbuf_to_gfileinfo (const struct stat *stbuf)
{ {
GFileInfo *ret = g_file_info_new (); GFileInfo *ret = g_file_info_new ();
g_file_info_set_attribute_uint32 (ret, "standard::type", ot_gfile_type_for_mode (mode)); GFileType ftype;
const mode_t mode = stbuf->st_mode;
if (S_ISDIR (mode))
ftype = G_FILE_TYPE_DIRECTORY;
else if (S_ISREG (mode))
ftype = G_FILE_TYPE_REGULAR;
else if (S_ISLNK (mode))
ftype = G_FILE_TYPE_SYMBOLIC_LINK;
else if (S_ISBLK (mode) || S_ISCHR(mode) || S_ISFIFO(mode))
ftype = G_FILE_TYPE_SPECIAL;
else
ftype = G_FILE_TYPE_UNKNOWN;
g_file_info_set_attribute_uint32 (ret, "standard::type", ftype);
g_file_info_set_attribute_boolean (ret, "standard::is-symlink", S_ISLNK (mode)); g_file_info_set_attribute_boolean (ret, "standard::is-symlink", S_ISLNK (mode));
g_file_info_set_attribute_uint32 (ret, "unix::uid", uid); g_file_info_set_attribute_uint32 (ret, "unix::uid", stbuf->st_uid);
g_file_info_set_attribute_uint32 (ret, "unix::gid", gid); g_file_info_set_attribute_uint32 (ret, "unix::gid", stbuf->st_gid);
g_file_info_set_attribute_uint32 (ret, "unix::mode", mode); g_file_info_set_attribute_uint32 (ret, "unix::mode", mode);
if (S_ISREG (mode))
g_file_info_set_attribute_uint64 (ret, "standard::size", stbuf->st_size);
return ret; return ret;
} }
GFileInfo *
_ostree_mode_uidgid_to_gfileinfo (mode_t mode, uid_t uid, gid_t gid)
{
struct stat stbuf;
stbuf.st_mode = mode;
stbuf.st_uid = uid;
stbuf.st_gid = gid;
return _ostree_stbuf_to_gfileinfo (&stbuf);
}
/* /*
* _ostree_get_relative_object_path: * _ostree_get_relative_object_path:
* @checksum: ASCII checksum string * @checksum: ASCII checksum string
@ -1619,8 +1705,7 @@ file_header_parse (GVariant *metadata,
uid = GUINT32_FROM_BE (uid); uid = GUINT32_FROM_BE (uid);
gid = GUINT32_FROM_BE (gid); gid = GUINT32_FROM_BE (gid);
mode = GUINT32_FROM_BE (mode); mode = GUINT32_FROM_BE (mode);
g_autoptr(GFileInfo) ret_file_info = _ostree_mode_uidgid_to_gfileinfo (mode, uid, gid);
g_autoptr(GFileInfo) ret_file_info = _ostree_header_gfile_info_new (mode, uid, gid);
if (S_ISREG (mode)) if (S_ISREG (mode))
{ {
@ -1670,7 +1755,7 @@ zlib_file_header_parse (GVariant *metadata,
uid = GUINT32_FROM_BE (uid); uid = GUINT32_FROM_BE (uid);
gid = GUINT32_FROM_BE (gid); gid = GUINT32_FROM_BE (gid);
mode = GUINT32_FROM_BE (mode); mode = GUINT32_FROM_BE (mode);
g_autoptr(GFileInfo) ret_file_info = _ostree_header_gfile_info_new (mode, uid, gid); g_autoptr(GFileInfo) ret_file_info = _ostree_mode_uidgid_to_gfileinfo (mode, uid, gid);
g_file_info_set_size (ret_file_info, GUINT64_FROM_BE (size)); g_file_info_set_size (ret_file_info, GUINT64_FROM_BE (size));
if (S_ISREG (mode)) if (S_ISREG (mode))

View File

@ -242,6 +242,14 @@ int ostree_cmp_checksum_bytes (const guchar *a, const guchar *b);
_OSTREE_PUBLIC _OSTREE_PUBLIC
gboolean ostree_validate_rev (const char *rev, GError **error); gboolean ostree_validate_rev (const char *rev, GError **error);
#ifdef OSTREE_ENABLE_EXPERIMENTAL_API
_OSTREE_PUBLIC
gboolean ostree_validate_collection_id (const char *collection_id, GError **error);
#endif /* OSTREE_ENABLE_EXPERIMENTAL_API */
_OSTREE_PUBLIC
gboolean ostree_validate_remote_name (const char *remote_name, GError **error);
_OSTREE_PUBLIC _OSTREE_PUBLIC
gboolean ostree_parse_refspec (const char *refspec, gboolean ostree_parse_refspec (const char *refspec,
char **out_remote, char **out_remote,

View File

@ -99,7 +99,7 @@ struct FetcherRequest {
OstreeFetcherRequestFlags flags; OstreeFetcherRequestFlags flags;
gboolean is_membuf; gboolean is_membuf;
GError *caught_write_error; GError *caught_write_error;
OtTmpfile tmpf; GLnxTmpfile tmpf;
GString *output_buf; GString *output_buf;
CURL *easy; CURL *easy;
@ -270,9 +270,9 @@ ensure_tmpfile (FetcherRequest *req, GError **error)
{ {
if (!req->tmpf.initialized) if (!req->tmpf.initialized)
{ {
if (!ot_open_tmpfile_linkable_at (req->fetcher->tmpdir_dfd, ".", if (!glnx_open_tmpfile_linkable_at (req->fetcher->tmpdir_dfd, ".",
O_WRONLY | O_CLOEXEC, &req->tmpf, O_WRONLY | O_CLOEXEC, &req->tmpf,
error)) error))
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
@ -390,9 +390,9 @@ check_multi_info (OstreeFetcher *fetcher)
glnx_set_error_from_errno (error); glnx_set_error_from_errno (error);
g_task_return_error (task, g_steal_pointer (&local_error)); g_task_return_error (task, g_steal_pointer (&local_error));
} }
else if (!ot_link_tmpfile_at (&req->tmpf, GLNX_LINK_TMPFILE_REPLACE, else if (!glnx_link_tmpfile_at (&req->tmpf, GLNX_LINK_TMPFILE_REPLACE,
fetcher->tmpdir_dfd, tmpfile_path, fetcher->tmpdir_dfd, tmpfile_path,
error)) error))
g_task_return_error (task, g_steal_pointer (&local_error)); g_task_return_error (task, g_steal_pointer (&local_error));
else else
{ {
@ -616,7 +616,7 @@ request_unref (FetcherRequest *req)
g_ptr_array_unref (req->mirrorlist); g_ptr_array_unref (req->mirrorlist);
g_free (req->filename); g_free (req->filename);
g_clear_error (&req->caught_write_error); g_clear_error (&req->caught_write_error);
ot_tmpfile_clear (&req->tmpf); glnx_tmpfile_clear (&req->tmpf);
if (req->output_buf) if (req->output_buf)
g_string_free (req->output_buf, TRUE); g_string_free (req->output_buf, TRUE);
curl_easy_cleanup (req->easy); curl_easy_cleanup (req->easy);
@ -690,9 +690,6 @@ static void
adopt_steal_mainctx (OstreeFetcher *self, adopt_steal_mainctx (OstreeFetcher *self,
GMainContext *mainctx) GMainContext *mainctx)
{ {
GHashTableIter hiter;
gpointer key, value;
g_assert (self->mainctx == NULL); g_assert (self->mainctx == NULL);
self->mainctx = mainctx; /* Transfer */ self->mainctx = mainctx; /* Transfer */
@ -706,12 +703,8 @@ adopt_steal_mainctx (OstreeFetcher *self,
update_timeout_cb (self->multi, timeout_micros / 1000, self); update_timeout_cb (self->multi, timeout_micros / 1000, self);
} }
g_hash_table_iter_init (&hiter, self->sockets); GLNX_HASH_TABLE_FOREACH (self->sockets, SockInfo*, fdp)
while (g_hash_table_iter_next (&hiter, &key, &value)) setsock (fdp, fdp->sockfd, fdp->action, self);
{
SockInfo *fdp = key;
setsock (fdp, fdp->sockfd, fdp->action, self);
}
} }
static void static void

View File

@ -1323,24 +1323,18 @@ _ostree_fetcher_request_to_membuf_finish (OstreeFetcher *self,
guint64 guint64
_ostree_fetcher_bytes_transferred (OstreeFetcher *self) _ostree_fetcher_bytes_transferred (OstreeFetcher *self)
{ {
GHashTableIter hiter;
gpointer key, value;
guint64 ret;
g_return_val_if_fail (OSTREE_IS_FETCHER (self), 0); g_return_val_if_fail (OSTREE_IS_FETCHER (self), 0);
g_mutex_lock (&self->thread_closure->output_stream_set_lock); g_mutex_lock (&self->thread_closure->output_stream_set_lock);
ret = self->thread_closure->total_downloaded; guint64 ret = self->thread_closure->total_downloaded;
g_hash_table_iter_init (&hiter, self->thread_closure->output_stream_set); GLNX_HASH_TABLE_FOREACH (self->thread_closure->output_stream_set,
while (g_hash_table_iter_next (&hiter, &key, &value)) GFileOutputStream*, stream)
{ {
GFileOutputStream *stream = key;
struct stat stbuf;
if (G_IS_FILE_DESCRIPTOR_BASED (stream)) if (G_IS_FILE_DESCRIPTOR_BASED (stream))
{ {
struct stat stbuf;
if (glnx_stream_fstat ((GFileDescriptorBased*)stream, &stbuf, NULL)) if (glnx_stream_fstat ((GFileDescriptorBased*)stream, &stbuf, NULL))
ret += stbuf.st_size; ret += stbuf.st_size;
} }

View File

@ -172,12 +172,11 @@ _ostree_impl_system_generator (const char *ostree_cmdline,
/* Generate our bind mount unit */ /* Generate our bind mount unit */
const char *stateroot_var_path = glnx_strjoina ("/sysroot/ostree/deploy/", stateroot, "/var"); const char *stateroot_var_path = glnx_strjoina ("/sysroot/ostree/deploy/", stateroot, "/var");
glnx_fd_close int tmpfd = -1; g_auto(GLnxTmpfile) tmpf = { 0, };
g_autofree char *tmppath = NULL;
if (!glnx_open_tmpfile_linkable_at (normal_dir_dfd, ".", O_WRONLY | O_CLOEXEC, if (!glnx_open_tmpfile_linkable_at (normal_dir_dfd, ".", O_WRONLY | O_CLOEXEC,
&tmpfd, &tmppath, error)) &tmpf, error))
return FALSE; return FALSE;
g_autoptr(GOutputStream) outstream = g_unix_output_stream_new (tmpfd, FALSE); g_autoptr(GOutputStream) outstream = g_unix_output_stream_new (tmpf.fd, FALSE);
gsize bytes_written; gsize bytes_written;
/* This code is inspired by systemd's fstab-generator.c. /* This code is inspired by systemd's fstab-generator.c.
* *
@ -204,12 +203,11 @@ _ostree_impl_system_generator (const char *ostree_cmdline,
return FALSE; return FALSE;
g_clear_object (&outstream); g_clear_object (&outstream);
/* It should be readable */ /* It should be readable */
if (fchmod (tmpfd, 0644) < 0) if (fchmod (tmpf.fd, 0644) < 0)
return glnx_throw_errno_prefix (error, "fchmod"); return glnx_throw_errno_prefix (error, "fchmod");
/* Error out if somehow it already exists, that'll help us debug conflicts */ /* Error out if somehow it already exists, that'll help us debug conflicts */
if (!glnx_link_tmpfile_at (normal_dir_dfd, GLNX_LINK_TMPFILE_NOREPLACE, if (!glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_NOREPLACE,
tmpfd, tmppath, normal_dir_dfd, normal_dir_dfd, "var.mount", error))
"var.mount", error))
return FALSE; return FALSE;
/* And ensure it's required; newer systemd will auto-inject fs dependencies /* And ensure it's required; newer systemd will auto-inject fs dependencies

View File

@ -114,9 +114,6 @@ ostree_mutable_tree_set_contents_checksum (OstreeMutableTree *self,
const char * const char *
ostree_mutable_tree_get_contents_checksum (OstreeMutableTree *self) ostree_mutable_tree_get_contents_checksum (OstreeMutableTree *self)
{ {
GHashTableIter iter;
gpointer key, value;
if (!self->contents_checksum) if (!self->contents_checksum)
return NULL; return NULL;
@ -127,10 +124,8 @@ ostree_mutable_tree_get_contents_checksum (OstreeMutableTree *self)
* *
* However, we only call this function once right now. * However, we only call this function once right now.
*/ */
g_hash_table_iter_init (&iter, self->subdirs); GLNX_HASH_TABLE_FOREACH_V (self->subdirs, OstreeMutableTree*, subdir)
while (g_hash_table_iter_next (&iter, &key, &value))
{ {
OstreeMutableTree *subdir = value;
if (!ostree_mutable_tree_get_contents_checksum (subdir)) if (!ostree_mutable_tree_get_contents_checksum (subdir))
{ {
g_free (self->contents_checksum); g_free (self->contents_checksum);

193
src/libostree/ostree-ref.c Normal file
View File

@ -0,0 +1,193 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright © 2017 Endless Mobile, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* - Philip Withnall <withnall@endlessm.com>
*/
#include "config.h"
#include <gio/gio.h>
#include <glib.h>
#include <glib-object.h>
#include <libglnx.h>
#include "ostree-autocleanups.h"
#include "ostree-core.h"
#include "ostree-core-private.h"
#include "ostree-ref.h"
G_DEFINE_BOXED_TYPE (OstreeCollectionRef, ostree_collection_ref,
ostree_collection_ref_dup, ostree_collection_ref_free)
/**
* ostree_collection_ref_new:
* @collection_id: (nullable): a collection ID, or %NULL for a plain ref
* @ref_name: a ref name
*
* Create a new #OstreeCollectionRef containing (@collection_id, @ref_name). If
* @collection_id is %NULL, this is equivalent to a plain ref name string (not a
* refspec; no remote name is included), which can be used for non-P2P
* operations.
*
* Returns: (transfer full): a new #OstreeCollectionRef
* Since: 2017.8
*/
OstreeCollectionRef *
ostree_collection_ref_new (const gchar *collection_id,
const gchar *ref_name)
{
g_autoptr(OstreeCollectionRef) collection_ref = NULL;
g_return_val_if_fail (collection_id == NULL ||
ostree_validate_collection_id (collection_id, NULL), NULL);
g_return_val_if_fail (ostree_validate_rev (ref_name, NULL), NULL);
collection_ref = g_new0 (OstreeCollectionRef, 1);
collection_ref->collection_id = g_strdup (collection_id);
collection_ref->ref_name = g_strdup (ref_name);
return g_steal_pointer (&collection_ref);
}
/**
* ostree_collection_ref_dup:
* @ref: an #OstreeCollectionRef
*
* Create a copy of the given @ref.
*
* Returns: (transfer full): a newly allocated copy of @ref
* Since: 2017.8
*/
OstreeCollectionRef *
ostree_collection_ref_dup (const OstreeCollectionRef *ref)
{
g_return_val_if_fail (ref != NULL, NULL);
return ostree_collection_ref_new (ref->collection_id, ref->ref_name);
}
/**
* ostree_collection_ref_free:
* @ref: (transfer full): an #OstreeCollectionRef
*
* Free the given @ref.
*
* Since: 2017.8
*/
void
ostree_collection_ref_free (OstreeCollectionRef *ref)
{
g_return_if_fail (ref != NULL);
g_free (ref->collection_id);
g_free (ref->ref_name);
g_free (ref);
}
/**
* ostree_collection_ref_hash:
* @ref: an #OstreeCollectionRef
*
* Hash the given @ref. This function is suitable for use with #GHashTable.
* @ref must be non-%NULL.
*
* Returns: hash value for @ref
* Since: 2017.8
*/
guint
ostree_collection_ref_hash (gconstpointer ref)
{
const OstreeCollectionRef *_ref = ref;
if (_ref->collection_id != NULL)
return g_str_hash (_ref->collection_id) ^ g_str_hash (_ref->ref_name);
else
return g_str_hash (_ref->ref_name);
}
/**
* ostree_collection_ref_equal:
* @ref1: an #OstreeCollectionRef
* @ref2: another #OstreeCollectionRef
*
* Compare @ref1 and @ref2 and return %TRUE if they have the same collection ID and
* ref name, and %FALSE otherwise. Both @ref1 and @ref2 must be non-%NULL.
*
* Returns: %TRUE if @ref1 and @ref2 are equal, %FALSE otherwise
* Since: 2017.8
*/
gboolean
ostree_collection_ref_equal (gconstpointer ref1,
gconstpointer ref2)
{
const OstreeCollectionRef *_ref1 = ref1, *_ref2 = ref2;
return (g_strcmp0 (_ref1->collection_id, _ref2->collection_id) == 0 &&
g_strcmp0 (_ref1->ref_name, _ref2->ref_name) == 0);
}
/**
* ostree_collection_ref_dupv:
* @refs: (array zero-terminated=1): %NULL-terminated array of #OstreeCollectionRefs
*
* Copy an array of #OstreeCollectionRefs, including deep copies of all its
* elements. @refs must be %NULL-terminated; it may be empty, but must not be
* %NULL.
*
* Returns: (transfer full) (array zero-terminated=1): a newly allocated copy of @refs
* Since: 2017.8
*/
OstreeCollectionRef **
ostree_collection_ref_dupv (const OstreeCollectionRef * const *refs)
{
gsize i, n_refs = g_strv_length ((gchar **) refs); /* hack */
g_auto(OstreeCollectionRefv) new_refs = NULL;
g_return_val_if_fail (refs != NULL, NULL);
new_refs = g_new0 (OstreeCollectionRef*, n_refs + 1);
for (i = 0; i < n_refs; i++)
new_refs[i] = ostree_collection_ref_dup (refs[i]);
new_refs[i] = NULL;
return g_steal_pointer (&new_refs);
}
/**
* ostree_collection_ref_freev:
* @refs: (transfer full) (array zero-terminated=1): an array of #OstreeCollectionRefs
*
* Free the given array of @refs, including freeing all its elements. @refs
* must be %NULL-terminated; it may be empty, but must not be %NULL.
*
* Since: 2017.8
*/
void
ostree_collection_ref_freev (OstreeCollectionRef **refs)
{
gsize i;
g_return_if_fail (refs != NULL);
for (i = 0; refs[i] != NULL; i++)
ostree_collection_ref_free (refs[i]);
g_free (refs);
}

View File

@ -0,0 +1,90 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright © 2017 Endless Mobile, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* - Philip Withnall <withnall@endlessm.com>
*/
#pragma once
#include <gio/gio.h>
#include <glib.h>
#include <glib-object.h>
#include "ostree-types.h"
G_BEGIN_DECLS
/**
* OstreeCollectionRef:
* @collection_id: (nullable): collection ID which provided the ref, or %NULL if there
* is no associated collection
* @ref_name: ref name
*
* A structure which globally uniquely identifies a ref as the tuple
* (@collection_id, @ref_name). For backwards compatibility, @collection_id may be %NULL,
* indicating a ref name which is not globally unique.
*
* Since: 2017.8
*/
typedef struct
{
gchar *collection_id; /* (nullable) */
gchar *ref_name; /* (not nullable) */
} OstreeCollectionRef;
#ifndef __GI_SCANNER__
_OSTREE_PUBLIC
GType ostree_collection_ref_get_type (void);
_OSTREE_PUBLIC
OstreeCollectionRef *ostree_collection_ref_new (const gchar *collection_id,
const gchar *ref_name);
_OSTREE_PUBLIC
OstreeCollectionRef *ostree_collection_ref_dup (const OstreeCollectionRef *ref);
_OSTREE_PUBLIC
void ostree_collection_ref_free (OstreeCollectionRef *ref);
#endif
_OSTREE_PUBLIC
guint ostree_collection_ref_hash (gconstpointer ref);
_OSTREE_PUBLIC
gboolean ostree_collection_ref_equal (gconstpointer ref1,
gconstpointer ref2);
_OSTREE_PUBLIC
OstreeCollectionRef **ostree_collection_ref_dupv (const OstreeCollectionRef * const *refs);
_OSTREE_PUBLIC
void ostree_collection_ref_freev (OstreeCollectionRef **refs);
/**
* OstreeCollectionRefv:
*
* A %NULL-terminated array of #OstreeCollectionRef instances, designed to
* be used with g_auto():
*
* |[<!-- language="C" -->
* g_auto(OstreeCollectionRefv) refs = NULL;
* ]|
*
* Since: 2017.8
*/
typedef OstreeCollectionRef** OstreeCollectionRefv;
G_END_DECLS

View File

@ -41,7 +41,7 @@ G_BEGIN_DECLS
* remotes can only be passed around as (reference counted) opaque handles. In * remotes can only be passed around as (reference counted) opaque handles. In
* future, more API may be added to create and interrogate them. * future, more API may be added to create and interrogate them.
* *
* Since: 2016.7 * Since: 2017.6
*/ */
#ifndef OSTREE_ENABLE_EXPERIMENTAL_API #ifndef OSTREE_ENABLE_EXPERIMENTAL_API
/* This is in ostree-types.h otherwise */ /* This is in ostree-types.h otherwise */

View File

@ -60,9 +60,9 @@ checkout_object_for_uncompressed_cache (OstreeRepo *self,
guint32 file_mode = g_file_info_get_attribute_uint32 (src_info, "unix::mode"); guint32 file_mode = g_file_info_get_attribute_uint32 (src_info, "unix::mode");
file_mode &= ~(S_ISUID|S_ISGID); file_mode &= ~(S_ISUID|S_ISGID);
g_auto(OtTmpfile) tmpf = { 0, }; g_auto(GLnxTmpfile) tmpf = { 0, };
if (!ot_open_tmpfile_linkable_at (self->tmp_dir_fd, ".", O_WRONLY | O_CLOEXEC, if (!glnx_open_tmpfile_linkable_at (self->tmp_dir_fd, ".", O_WRONLY | O_CLOEXEC,
&tmpf, error)) &tmpf, error))
return FALSE; return FALSE;
g_autoptr(GOutputStream) temp_out = g_unix_output_stream_new (tmpf.fd, FALSE); g_autoptr(GOutputStream) temp_out = g_unix_output_stream_new (tmpf.fd, FALSE);
@ -89,9 +89,9 @@ checkout_object_for_uncompressed_cache (OstreeRepo *self,
cancellable, error)) cancellable, error))
return FALSE; return FALSE;
if (!ot_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST, if (!glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST,
self->uncompressed_objects_dir_fd, loose_path, self->uncompressed_objects_dir_fd, loose_path,
error)) error))
return FALSE; return FALSE;
return TRUE; return TRUE;
@ -254,11 +254,11 @@ create_file_copy_from_input_at (OstreeRepo *repo,
} }
else if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR) else if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
{ {
g_auto(OtTmpfile) tmpf = { 0, }; g_auto(GLnxTmpfile) tmpf = { 0, };
GLnxLinkTmpfileReplaceMode replace_mode; GLnxLinkTmpfileReplaceMode replace_mode;
if (!ot_open_tmpfile_linkable_at (destination_dfd, ".", O_WRONLY | O_CLOEXEC, if (!glnx_open_tmpfile_linkable_at (destination_dfd, ".", O_WRONLY | O_CLOEXEC,
&tmpf, error)) &tmpf, error))
return FALSE; return FALSE;
if (sepolicy_enabled && options->mode != OSTREE_REPO_CHECKOUT_MODE_USER) if (sepolicy_enabled && options->mode != OSTREE_REPO_CHECKOUT_MODE_USER)
@ -285,9 +285,9 @@ create_file_copy_from_input_at (OstreeRepo *repo,
else else
replace_mode = GLNX_LINK_TMPFILE_NOREPLACE; replace_mode = GLNX_LINK_TMPFILE_NOREPLACE;
if (!ot_link_tmpfile_at (&tmpf, replace_mode, if (!glnx_link_tmpfile_at (&tmpf, replace_mode,
destination_dfd, destination_name, destination_dfd, destination_name,
error)) error))
return FALSE; return FALSE;
} }
else else
@ -446,7 +446,7 @@ checkout_one_file_at (OstreeRepo *repo,
/* But only under these conditions */ /* But only under these conditions */
if (is_bare || is_archive_z2_with_cache) if (is_bare || is_archive_z2_with_cache)
{ {
/* Override repo mode; for archive-z2 we're looking in /* Override repo mode; for archive we're looking in
the cache, which is in "bare" form */ the cache, which is in "bare" form */
_ostree_loose_path (loose_path_buf, checksum, OSTREE_OBJECT_TYPE_FILE, OSTREE_REPO_MODE_BARE); _ostree_loose_path (loose_path_buf, checksum, OSTREE_OBJECT_TYPE_FILE, OSTREE_REPO_MODE_BARE);
if (!checkout_file_hardlink (current_repo, if (!checkout_file_hardlink (current_repo,
@ -488,7 +488,7 @@ checkout_one_file_at (OstreeRepo *repo,
g_autoptr(GInputStream) input = NULL; g_autoptr(GInputStream) input = NULL;
g_autoptr(GVariant) xattrs = NULL; g_autoptr(GVariant) xattrs = NULL;
/* Ok, if we're archive-z2 and we didn't find an object, uncompress /* Ok, if we're archive and we didn't find an object, uncompress
* it now, stick it in the cache, and then hardlink to that. * it now, stick it in the cache, and then hardlink to that.
*/ */
if (can_cache if (can_cache
@ -1088,13 +1088,12 @@ ostree_repo_checkout_gc (OstreeRepo *self,
self->updated_uncompressed_dirs = g_hash_table_new (NULL, NULL); self->updated_uncompressed_dirs = g_hash_table_new (NULL, NULL);
g_mutex_unlock (&self->cache_lock); g_mutex_unlock (&self->cache_lock);
GHashTableIter iter; if (!to_clean_dirs)
gpointer key, value; return TRUE; /* Note early return */
if (to_clean_dirs)
g_hash_table_iter_init (&iter, to_clean_dirs); GLNX_HASH_TABLE_FOREACH (to_clean_dirs, gpointer, prefix)
while (to_clean_dirs && g_hash_table_iter_next (&iter, &key, &value))
{ {
g_autofree char *objdir_name = g_strdup_printf ("%02x", GPOINTER_TO_UINT (key)); g_autofree char *objdir_name = g_strdup_printf ("%02x", GPOINTER_TO_UINT (prefix));
g_auto(GLnxDirFdIterator) dfd_iter = { 0, }; g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
if (!glnx_dirfd_iterator_init_at (self->uncompressed_objects_dir_fd, objdir_name, FALSE, if (!glnx_dirfd_iterator_init_at (self->uncompressed_objects_dir_fd, objdir_name, FALSE,

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,137 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright © 2016 Kinvolk GmbH
* Copyright © 2017 Endless Mobile, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* - Krzesimir Nowak <krzesimir@kinvolk.io>
* - Philip Withnall <withnall@endlessm.com>
*/
#include "config.h"
#include <avahi-common/strlst.h>
#include <glib.h>
#include <glib-object.h>
#include <string.h>
#include "ostree-autocleanups.h"
#include "ostree-repo-finder-avahi.h"
#include "ostree-repo-finder-avahi-private.h"
/* Reference: RFC 6763, §6. */
static gboolean
parse_txt_record (const guint8 *txt,
gsize txt_len,
const gchar **key,
gsize *key_len,
const guint8 **value,
gsize *value_len)
{
gsize i;
g_return_val_if_fail (key != NULL, FALSE);
g_return_val_if_fail (key_len != NULL, FALSE);
g_return_val_if_fail (value != NULL, FALSE);
g_return_val_if_fail (value_len != NULL, FALSE);
/* RFC 6763, §6.1. */
if (txt_len > 8900)
return FALSE;
*key = (const gchar *) txt;
*key_len = 0;
*value = NULL;
*value_len = 0;
for (i = 0; i < txt_len; i++)
{
if (txt[i] >= 0x20 && txt[i] <= 0x7e && txt[i] != '=')
{
/* Key character. */
*key_len = *key_len + 1;
continue;
}
else if (*key_len > 0 && txt[i] == '=')
{
/* Separator. */
*value = txt + (i + 1);
*value_len = txt_len - (i + 1);
return TRUE;
}
else
{
return FALSE;
}
}
/* The entire TXT record is the key; there is no = or value. */
*value = NULL;
*value_len = 0;
return (*key_len > 0);
}
/* TODO: Docs. Return value is only valid as long as @txt is. Reference: RFC 6763, §6. */
GHashTable *
_ostree_txt_records_parse (AvahiStringList *txt)
{
AvahiStringList *l;
g_autoptr(GHashTable) out = NULL;
out = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_bytes_unref);
for (l = txt; l != NULL; l = avahi_string_list_get_next (l))
{
const guint8 *txt;
gsize txt_len;
const gchar *key;
const guint8 *value;
gsize key_len, value_len;
g_autofree gchar *key_allocated = NULL;
g_autoptr(GBytes) value_allocated = NULL;
txt = avahi_string_list_get_text (l);
txt_len = avahi_string_list_get_size (l);
if (!parse_txt_record (txt, txt_len, &key, &key_len, &value, &value_len))
{
g_debug ("Ignoring invalid TXT record of length %" G_GSIZE_FORMAT,
txt_len);
continue;
}
key_allocated = g_ascii_strdown (key, key_len);
if (g_hash_table_lookup_extended (out, key_allocated, NULL, NULL))
{
g_debug ("Ignoring duplicate TXT record %s", key_allocated);
continue;
}
/* Distinguish between the case where the entire record is the key
* (value == NULL) and the case where the record is the key + = and the
* value is empty (value != NULL && value_len == 0). */
if (value != NULL)
value_allocated = g_bytes_new_static (value, value_len);
g_hash_table_insert (out, g_steal_pointer (&key_allocated), g_steal_pointer (&value_allocated));
}
return g_steal_pointer (&out);
}

View File

@ -0,0 +1,35 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright © 2017 Endless Mobile, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* - Philip Withnall <withnall@endlessm.com>
*/
#pragma once
#include <avahi-common/strlst.h>
#include <gio/gio.h>
#include <glib.h>
#include <glib-object.h>
G_BEGIN_DECLS
GHashTable *_ostree_txt_records_parse (AvahiStringList *txt);
G_END_DECLS

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright © 2017 Endless Mobile, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* - Philip Withnall <withnall@endlessm.com>
*/
#pragma once
#include <gio/gio.h>
#include <glib.h>
#include <glib-object.h>
#include "ostree-repo-finder.h"
#include "ostree-types.h"
G_BEGIN_DECLS
#define OSTREE_TYPE_REPO_FINDER_AVAHI (ostree_repo_finder_avahi_get_type ())
/* Manually expanded version of the following, omitting autoptr support (for GLib < 2.44):
_OSTREE_PUBLIC
G_DECLARE_FINAL_TYPE (OstreeRepoFinderAvahi, ostree_repo_finder_avahi, OSTREE, REPO_FINDER_AVAHI, GObject) */
_OSTREE_PUBLIC
GType ostree_repo_finder_avahi_get_type (void);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct _OstreeRepoFinderAvahi OstreeRepoFinderAvahi;
typedef struct { GObjectClass parent_class; } OstreeRepoFinderAvahiClass;
static inline OstreeRepoFinderAvahi *OSTREE_REPO_FINDER_AVAHI (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_repo_finder_avahi_get_type (), OstreeRepoFinderAvahi); }
static inline gboolean OSTREE_IS_REPO_FINDER_AVAHI (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_repo_finder_avahi_get_type ()); }
G_GNUC_END_IGNORE_DEPRECATIONS
_OSTREE_PUBLIC
OstreeRepoFinderAvahi *ostree_repo_finder_avahi_new (GMainContext *context);
_OSTREE_PUBLIC
void ostree_repo_finder_avahi_start (OstreeRepoFinderAvahi *self,
GError **error);
_OSTREE_PUBLIC
void ostree_repo_finder_avahi_stop (OstreeRepoFinderAvahi *self);
G_END_DECLS

Some files were not shown because too many files have changed in this diff Show More