Top | ![]() |
![]() |
![]() |
![]() |
Core repository-independent functionsCore repository-independent functions — Create, validate, and convert core data types |
enum | OstreeObjectType |
#define | OSTREE_OBJECT_TYPE_LAST |
#define | OSTREE_DIRMETA_GVARIANT_STRING |
#define | OSTREE_DIRMETA_GVARIANT_FORMAT |
#define | OSTREE_FILEMETA_GVARIANT_STRING |
#define | OSTREE_FILEMETA_GVARIANT_FORMAT |
#define | OSTREE_TREE_GVARIANT_STRING |
#define | OSTREE_TREE_GVARIANT_FORMAT |
#define | OSTREE_COMMIT_GVARIANT_STRING |
#define | OSTREE_COMMIT_GVARIANT_FORMAT |
#define | OSTREE_SUMMARY_GVARIANT_STRING |
#define | OSTREE_SUMMARY_GVARIANT_FORMAT |
These functions implement repository-independent algorithms for operating on the core OSTree data formats, such as converting GFileInfo into a GVariant.
There are 4 types of objects; file, dirmeta, tree, and commit. The last 3 are metadata, and the file object is the only content object type.
All metadata objects are stored as GVariant (big endian). The rationale for this is the same as that of the ext{2,3,4} family of filesystems; most developers will be using LE, and so it's better to continually test the BE->LE swap.
The file object is a custom format in order to support streaming.
#define OSTREE_MAX_METADATA_SIZE (10 * 1024 * 1024)
Maximum permitted size in bytes of metadata objects. This is an arbitrary number, but really, no one should be putting humongous data in metadata.
#define OSTREE_MAX_METADATA_WARN_SIZE (7 * 1024 * 1024)
Objects committed above this size will be allowed, but a warning will be emitted.
const GVariantType *
ostree_metadata_variant_type (OstreeObjectType objtype
);
gboolean ostree_validate_checksum_string (const char *sha256
,GError **error
);
Use this function to see if input strings are checksums.
guchar *
ostree_checksum_to_bytes (const char *checksum
);
Binary checksum from checksum
of length 32; free with g_free()
.
[transfer full][array fixed-size=32]
void ostree_checksum_inplace_from_bytes (const guchar *csum
,char *buf
);
Overwrite the contents of buf
with stringified version of csum
.
csum |
An binary checksum of length 32. |
[array fixed-size=32] |
buf |
Output location, must be at least 65 bytes in length |
void ostree_checksum_inplace_to_bytes (const char *checksum
,guchar *buf
);
Convert checksum
from a string to binary in-place, without
allocating memory. Use this function in hot code paths.
const guchar *
ostree_checksum_bytes_peek (GVariant *bytes
);
Binary checksum data in bytes
; do not free. If bytes
does not have the correct length, return NULL
.
[transfer none][array fixed-size=32][element-type guint8]
const guchar * ostree_checksum_bytes_peek_validate (GVariant *bytes
,GError **error
);
Like ostree_checksum_bytes_peek()
, but also throws error
.
int ostree_cmp_checksum_bytes (const guchar *a
,const guchar *b
);
Compare two binary checksums, using memcmp()
.
gboolean ostree_parse_refspec (const char *refspec
,char **out_remote
,char **out_ref
,GError **error
);
Split a refspec like "gnome-ostree:gnome-ostree/buildmaster" into
two parts; out_remote
will be set to "gnome-ostree", and out_ref
will be "gnome-ostree/buildmaster".
If refspec
refers to a local ref, out_remote
will be NULL
.
refspec |
A "refspec" string |
|
out_remote |
The remote name, or |
[out][allow-none] |
out_ref |
Name of ref. |
[out][allow-none] |
error |
Error |
void ostree_checksum_update_meta (GChecksum *checksum
,GFileInfo *file_info
,GVariant *xattrs
);
const char *
ostree_object_type_to_string (OstreeObjectType objtype
);
Serialize objtype
to a string; this is used for file extensions.
OstreeObjectType
ostree_object_type_from_string (const char *str
);
The reverse of ostree_object_type_to_string()
.
guint
ostree_hash_object_name (gconstpointer a
);
Use this function with GHashTable and ostree_object_name_serialize()
.
GVariant * ostree_object_name_serialize (const char *checksum
,OstreeObjectType objtype
);
void ostree_object_name_deserialize (GVariant *variant
,const char **out_checksum
,OstreeObjectType *out_objtype
);
Reverse ostree_object_name_serialize()
. Note that out_checksum
is
only valid for the lifetime of variant
, and must not be freed.
variant |
A GVariant of type (su) |
|
out_checksum |
Pointer into string memory of |
[out][transfer none] |
out_objtype |
Return object type. |
[out] |
char * ostree_object_to_string (const char *checksum
,OstreeObjectType objtype
);
void ostree_object_from_string (const char *str
,gchar **out_checksum
,OstreeObjectType *out_objtype
);
Reverse ostree_object_to_string()
.
str |
An ASCII checksum |
|
out_checksum |
Parsed checksum. |
[out][transfer full] |
out_objtype |
Parsed object type. |
[out] |
gboolean ostree_content_stream_parse (gboolean compressed
,GInputStream *input
,guint64 input_length
,gboolean trusted
,GInputStream **out_input
,GFileInfo **out_file_info
,GVariant **out_xattrs
,GCancellable *cancellable
,GError **error
);
The reverse of ostree_raw_file_to_content_stream()
; this function
converts an object content stream back into components.
compressed |
Whether or not the stream is zlib-compressed |
|
input |
Object content stream |
|
input_length |
Length of stream |
|
trusted |
If |
|
out_input |
The raw file content stream. |
[out] |
out_file_info |
Normal metadata. |
[out] |
out_xattrs |
Extended attributes. |
[out] |
cancellable |
Cancellable |
|
error |
Error |
gboolean ostree_content_file_parse (gboolean compressed
,GFile *content_path
,gboolean trusted
,GInputStream **out_input
,GFileInfo **out_file_info
,GVariant **out_xattrs
,GCancellable *cancellable
,GError **error
);
A thin wrapper for ostree_content_stream_parse()
; this function
converts an object content stream back into components.
compressed |
Whether or not the stream is zlib-compressed |
|
content_path |
Path to file containing content |
|
trusted |
If |
|
out_input |
The raw file content stream. |
[out] |
out_file_info |
Normal metadata. |
[out] |
out_xattrs |
Extended attributes. |
[out] |
cancellable |
Cancellable |
|
error |
Error |
gboolean ostree_raw_file_to_content_stream (GInputStream *input
,GFileInfo *file_info
,GVariant *xattrs
,GInputStream **out_input
,guint64 *out_length
,GCancellable *cancellable
,GError **error
);
Convert from a "bare" file representation into an OSTREE_OBJECT_TYPE_FILE stream. This is a fundamental operation for writing data to an OstreeRepo.
input |
File raw content stream |
|
file_info |
A file info |
|
xattrs |
Optional extended attributes. |
[allow-none] |
out_input |
Serialized object stream. |
[out] |
out_length |
Length of stream. |
[out] |
cancellable |
Cancellable |
|
error |
Error |
gboolean ostree_checksum_file_from_input (GFileInfo *file_info
,GVariant *xattrs
,GInputStream *in
,OstreeObjectType objtype
,guchar **out_csum
,GCancellable *cancellable
,GError **error
);
Compute the OSTree checksum for a given input.
file_info |
File information |
|
xattrs |
Optional extended attributes. |
[allow-none] |
in |
File content, should be |
[allow-none] |
objtype |
Object type |
|
out_csum |
Return location for binary checksum. |
[out][array fixed-size=32] |
cancellable |
Cancellable |
|
error |
Error |
gboolean ostree_checksum_file (GFile *f
,OstreeObjectType objtype
,guchar **out_csum
,GCancellable *cancellable
,GError **error
);
Compute the OSTree checksum for a given file.
void ostree_checksum_file_async (GFile *f
,OstreeObjectType objtype
,int io_priority
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Asynchronously compute the OSTree checksum for a given file;
complete with ostree_checksum_file_async_finish()
.
gboolean ostree_checksum_file_async_finish (GFile *f
,GAsyncResult *result
,guchar **out_csum
,GError **error
);
Finish computing the OSTree checksum for a given file; see
ostree_checksum_file_async()
.
GVariant * ostree_create_directory_metadata (GFileInfo *dir_info
,GVariant *xattrs
);
dir_info |
a GFileInfo containing directory information |
|
xattrs |
Optional extended attributes. |
[allow-none] |
gboolean ostree_validate_structureof_objtype (guchar objtype
,GError **error
);
gboolean ostree_validate_structureof_csum_v (GVariant *checksum
,GError **error
);
gboolean ostree_validate_structureof_checksum_string (const char *checksum
,GError **error
);
gboolean ostree_validate_structureof_file_mode (guint32 mode
,GError **error
);
gboolean ostree_validate_structureof_commit (GVariant *commit
,GError **error
);
Use this to validate the basic structure of commit
, independent of
any other objects it references.
gboolean ostree_validate_structureof_dirtree (GVariant *dirtree
,GError **error
);
Use this to validate the basic structure of dirtree
, independent of
any other objects it references.
gboolean ostree_validate_structureof_dirmeta (GVariant *dirmeta
,GError **error
);
Use this to validate the basic structure of dirmeta
.
Enumeration for core object types; OSTREE_OBJECT_TYPE_FILE
is for
content, the other types are metadata.
#define OSTREE_OBJECT_TYPE_LAST OSTREE_OBJECT_TYPE_COMMIT
Last valid object type; use this to validate ranges.
#define OSTREE_DIRMETA_GVARIANT_FORMAT G_VARIANT_TYPE (OSTREE_DIRMETA_GVARIANT_STRING)
u - uid u - gid u - mode a(ayay) - xattrs
#define OSTREE_FILEMETA_GVARIANT_FORMAT G_VARIANT_TYPE (OSTREE_FILEMETA_GVARIANT_STRING)
This is not a regular object type, but used as an xattr on a .file object in bare-user repositories. This allows us to store metadata information that we can't store in the real filesystem but we can still use a regular .file object that we can hardlink to in the case of a user-mode checkout.
u - uid u - gid u - mode a(ayay) - xattrs
#define OSTREE_TREE_GVARIANT_FORMAT G_VARIANT_TYPE (OSTREE_TREE_GVARIANT_STRING)
a(say) - array of (filename, checksum) for files a(sayay) - array of (dirname, tree_checksum, meta_checksum) for directories
#define OSTREE_COMMIT_GVARIANT_FORMAT G_VARIANT_TYPE (OSTREE_COMMIT_GVARIANT_STRING)
a{sv} - Metadata ay - parent checksum (empty string for initial) a(say) - Related objects s - subject s - body t - Timestamp in seconds since the epoch (UTC) ay - Root tree contents ay - Root tree metadata
#define OSTREE_SUMMARY_GVARIANT_FORMAT G_VARIANT_TYPE (OSTREE_SUMMARY_GVARIANT_STRING)
refs: a(s(taya{sv})) - Map of ref name -> (latest commit size, latest commit checksum, additional metadata), sorted by ref name extensions: a{sv} - Additional metadata, none defined at the current time