diff --git a/doc/ostree-sections.txt b/doc/ostree-sections.txt index 570c327b..1ecb1381 100644 --- a/doc/ostree-sections.txt +++ b/doc/ostree-sections.txt @@ -5,11 +5,9 @@ OSTREE_MAX_RECURSION OstreeObjectType OSTREE_OBJECT_TYPE_IS_META OSTREE_OBJECT_TYPE_LAST -OSTREE_FILE_HEADER_GVARIANT_FORMAT OSTREE_DIRMETA_GVARIANT_FORMAT OSTREE_TREE_GVARIANT_FORMAT OSTREE_COMMIT_GVARIANT_FORMAT -OSTREE_ZLIB_FILE_HEADER_GVARIANT_FORMAT ostree_metadata_variant_type ostree_validate_checksum_string ostree_checksum_to_bytes @@ -35,10 +33,6 @@ ostree_get_xattrs_for_file ostree_set_xattrs ostree_map_metadata_file ostree_write_variant_with_size -ostree_file_header_new -ostree_zlib_file_header_new -ostree_file_header_parse -ostree_zlib_file_header_parse ostree_content_stream_parse ostree_content_file_parse ostree_write_file_header_update_checksum diff --git a/src/libostree/ostree-core-private.h b/src/libostree/ostree-core-private.h new file mode 100644 index 00000000..47d96f6c --- /dev/null +++ b/src/libostree/ostree-core-private.h @@ -0,0 +1,70 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2013 Colin Walters + * + * 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 "ostree-core.h" + +G_BEGIN_DECLS + +/* This file contains private implementation data format definitions + * read by multiple implementation .c files. + */ + +/* + * File objects are stored as a stream, with one #GVariant header, + * followed by content. + * + * The file header is of the following form: + * + * <BE guint32 containing variant length> + * u - uid + * u - gid + * u - mode + * u - rdev + * s - symlink target + * a(ayay) - xattrs + * + * Then the rest of the stream is data. + */ +#define _OSTREE_FILE_HEADER_GVARIANT_FORMAT G_VARIANT_TYPE ("(uuuusa(ayay))") + +/* + * A variation on %OSTREE_FILE_HEADER_GVARIANT_FORMAT, used for + * storing zlib-compressed content objects. + * + * <BE guint32 containing variant length> + * t - size + * u - uid + * u - gid + * u - mode + * u - rdev + * s - symlink target + * a(ayay) - xattrs + * --- + * zlib-compressed data + */ +#define _OSTREE_ZLIB_FILE_HEADER_GVARIANT_FORMAT G_VARIANT_TYPE ("(tuuuusa(ayay))") + +GVariant *_ostree_zlib_file_header_new (GFileInfo *file_info, + GVariant *xattrs); + +G_END_DECLS + diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c index 14426d86..0248a718 100644 --- a/src/libostree/ostree-core.c +++ b/src/libostree/ostree-core.c @@ -28,6 +28,7 @@ #include #include #include "ostree.h" +#include "ostree-core-private.h" #include "ostree-chain-input-stream.h" #include "otutil.h" #include "libgsystem.h" @@ -35,6 +36,17 @@ #define ALIGN_VALUE(this, boundary) \ (( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1))) +static gboolean +file_header_parse (GVariant *metadata, + GFileInfo **out_file_info, + GVariant **out_xattrs, + GError **error); +static gboolean +zlib_file_header_parse (GVariant *metadata, + GFileInfo **out_file_info, + GVariant **out_xattrs, + GError **error); + /** * SECTION:libostree-core * @title: Core repository-independent functions @@ -334,9 +346,9 @@ ostree_get_xattrs_for_file (GFile *f, return ret; } -GVariant * -ostree_file_header_new (GFileInfo *file_info, - GVariant *xattrs) +static GVariant * +file_header_new (GFileInfo *file_info, + GVariant *xattrs) { guint32 uid; guint32 gid; @@ -366,7 +378,7 @@ ostree_file_header_new (GFileInfo *file_info, return ret; } -/** +/* * ostree_zlib_file_header_new: * @file_info: a #GFileInfo * @xattrs: (allow-none): Optional extended attribute array @@ -374,8 +386,8 @@ ostree_file_header_new (GFileInfo *file_info, * Returns: (transfer full): A new #GVariant containing file header for an archive-z2 repository */ GVariant * -ostree_zlib_file_header_new (GFileInfo *file_info, - GVariant *xattrs) +_ostree_zlib_file_header_new (GFileInfo *file_info, + GVariant *xattrs) { guint64 size; guint32 uid; @@ -567,7 +579,7 @@ ostree_raw_file_to_content_stream (GInputStream *input, gs_unref_object GOutputStream *header_out_stream = NULL; gs_unref_object GInputStream *header_in_stream = NULL; - file_header = ostree_file_header_new (file_info, xattrs); + file_header = file_header_new (file_info, xattrs); header_out_stream = g_memory_output_stream_new (NULL, 0, g_realloc, g_free); @@ -663,25 +675,25 @@ ostree_content_stream_parse (gboolean compressed, if (!g_input_stream_read_all (input, buf, archive_header_size, &bytes_read, cancellable, error)) goto out; - file_header = g_variant_new_from_data (compressed ? OSTREE_ZLIB_FILE_HEADER_GVARIANT_FORMAT : OSTREE_FILE_HEADER_GVARIANT_FORMAT, + file_header = g_variant_new_from_data (compressed ? _OSTREE_ZLIB_FILE_HEADER_GVARIANT_FORMAT : _OSTREE_FILE_HEADER_GVARIANT_FORMAT, buf, archive_header_size, trusted, g_free, buf); buf = NULL; if (compressed) { - if (!ostree_zlib_file_header_parse (file_header, - out_file_info ? &ret_file_info : NULL, - out_xattrs ? &ret_xattrs : NULL, - error)) + if (!zlib_file_header_parse (file_header, + out_file_info ? &ret_file_info : NULL, + out_xattrs ? &ret_xattrs : NULL, + error)) goto out; } else { - if (!ostree_file_header_parse (file_header, - out_file_info ? &ret_file_info : NULL, - out_xattrs ? &ret_xattrs : NULL, - error)) + if (!file_header_parse (file_header, + out_file_info ? &ret_file_info : NULL, + out_xattrs ? &ret_xattrs : NULL, + error)) goto out; if (ret_file_info) g_file_info_set_size (ret_file_info, input_length - archive_header_size - 8); @@ -827,7 +839,7 @@ ostree_checksum_file_from_input (GFileInfo *file_info, { gs_unref_variant GVariant *file_header = NULL; - file_header = ostree_file_header_new (file_info, xattrs); + file_header = file_header_new (file_info, xattrs); if (!ostree_write_file_header_update_checksum (NULL, file_header, checksum, cancellable, error)) @@ -1376,7 +1388,7 @@ ostree_get_relative_object_path (const char *checksum, return g_string_free (path, FALSE); } -/** +/* * ostree_file_header_parse: * @metadata: A metadata variant of type %OSTREE_FILE_HEADER_GVARIANT_FORMAT * @out_file_info: (out): Parsed file information @@ -1386,11 +1398,11 @@ ostree_get_relative_object_path (const char *checksum, * Load file header information into standard Gio #GFileInfo object, * along with extended attributes tored in @out_xattrs. */ -gboolean -ostree_file_header_parse (GVariant *metadata, - GFileInfo **out_file_info, - GVariant **out_xattrs, - GError **error) +static gboolean +file_header_parse (GVariant *metadata, + GFileInfo **out_file_info, + GVariant **out_xattrs, + GError **error) { gboolean ret = FALSE; guint32 uid, gid, mode, rdev; @@ -1436,8 +1448,8 @@ ostree_file_header_parse (GVariant *metadata, return ret; } -/** - * ostree_zlib_file_header_parse: +/* + * zlib_file_header_parse: * @metadata: A metadata variant of type %OSTREE_FILE_HEADER_GVARIANT_FORMAT * @out_file_info: (out): Parsed file information * @out_xattrs: (out): Parsed extended attribute set @@ -1446,11 +1458,11 @@ ostree_file_header_parse (GVariant *metadata, * Like ostree_file_header_parse(), but operates on zlib-compressed * content. */ -gboolean -ostree_zlib_file_header_parse (GVariant *metadata, - GFileInfo **out_file_info, - GVariant **out_xattrs, - GError **error) +static gboolean +zlib_file_header_parse (GVariant *metadata, + GFileInfo **out_file_info, + GVariant **out_xattrs, + GError **error) { gboolean ret = FALSE; guint64 size; diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h index 253be08d..bace0b25 100644 --- a/src/libostree/ostree-core.h +++ b/src/libostree/ostree-core.h @@ -72,26 +72,6 @@ typedef enum { */ #define OSTREE_OBJECT_TYPE_LAST OSTREE_OBJECT_TYPE_COMMIT -/** - * OSTREE_FILE_HEADER_GVARIANT_FORMAT: - * - * File objects are stored as a stream, with one #GVariant header, - * followed by content. - * - * The file header is of the following form: - * - * <BE guint32 containing variant length> - * u - uid - * u - gid - * u - mode - * u - rdev - * s - symlink target - * a(ayay) - xattrs - * - * Then the rest of the stream is data. - */ -#define OSTREE_FILE_HEADER_GVARIANT_FORMAT G_VARIANT_TYPE ("(uuuusa(ayay))") - /** * OSTREE_DIRMETA_GVARIANT_FORMAT: * @@ -124,25 +104,6 @@ typedef enum { */ #define OSTREE_COMMIT_GVARIANT_FORMAT G_VARIANT_TYPE ("(a{sv}aya(say)sstayay)") -/** - * OSTREE_ZLIB_FILE_HEADER_GVARIANT_FORMAT: - * - * This is a variation on %OSTREE_FILE_HEADER_GVARIANT_FORMAT, used for - * storing zlib-compressed content objects. - * - * <BE guint32 containing variant length> - * t - size - * u - uid - * u - gid - * u - mode - * u - rdev - * s - symlink target - * a(ayay) - xattrs - * --- - * zlib-compressed data - */ -#define OSTREE_ZLIB_FILE_HEADER_GVARIANT_FORMAT G_VARIANT_TYPE ("(tuuuusa(ayay))") - const GVariantType *ostree_metadata_variant_type (OstreeObjectType objtype); gboolean ostree_validate_checksum_string (const char *sha256, @@ -220,8 +181,6 @@ gboolean ostree_write_variant_with_size (GOutputStream *output, GVariant *ostree_file_header_new (GFileInfo *file_info, GVariant *xattrs); -GVariant *ostree_zlib_file_header_new (GFileInfo *file_info, - GVariant *xattrs); gboolean ostree_file_header_parse (GVariant *metadata, GFileInfo **out_file_info, diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index 8d86895f..1a5b0de2 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -30,6 +30,7 @@ #include #include "ostree-repo-private.h" +#include "ostree-core-private.h" #include "ostree-mutable-tree.h" #include "ostree-checksum-input-stream.h" #include "otutil.h" @@ -707,7 +708,7 @@ stage_object (OstreeRepo *self, goto out; temp_file_is_regular = TRUE; - file_meta = ostree_zlib_file_header_new (file_info, xattrs); + file_meta = _ostree_zlib_file_header_new (file_info, xattrs); if (!ostree_write_variant_with_size (temp_out, file_meta, 0, NULL, NULL, cancellable, error))