Coverage Report

Created: 2026-10-28 06:30

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ostree/src/libostree/ostree-core-private.h
Line
Count
Source
1
/*
2
 * Copyright (C) 2013 Colin Walters <walters@verbum.org>
3
 *
4
 * SPDX-License-Identifier: LGPL-2.0+
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
#pragma once
21
22
#include "ostree-core.h"
23
#include "otutil.h"
24
#include <sys/stat.h>
25
26
G_BEGIN_DECLS
27
28
/* It's what gzip does, 9 is too slow */
29
236
#define OSTREE_ARCHIVE_DEFAULT_COMPRESSION_LEVEL (6)
30
31
/* Note the permissive group bits. We want to be liberal here and let individual machines
32
 * narrow permissions as needed via umask. This is important in setups where group ownership
33
 * can matter for repo management (like OpenShift). */
34
1.57k
#define DEFAULT_DIRECTORY_MODE 0775
35
#define DEFAULT_REGFILE_MODE 0660
36
37
/* This exists in glibc's sys/stat.h, but not on musl */
38
#ifndef ALLPERMS
39
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
40
#endif
41
42
/* This file contains private implementation data format definitions
43
 * read by multiple implementation .c files.
44
 */
45
46
/*
47
 * File objects are stored as a stream, with one #GVariant header,
48
 * followed by content.
49
 *
50
 * The file header is of the following form:
51
 *
52
 * &lt;BE guint32 containing variant length&gt;
53
 * u - uid
54
 * u - gid
55
 * u - mode
56
 * u - rdev (must be 0)
57
 * s - symlink target
58
 * a(ayay) - xattrs
59
 *
60
 * Then the rest of the stream is data.
61
 */
62
78
#define _OSTREE_FILE_HEADER_GVARIANT_FORMAT G_VARIANT_TYPE ("(uuuusa(ayay))")
63
64
/*
65
 * A variation on %OSTREE_FILE_HEADER_GVARIANT_FORMAT, used for
66
 * storing zlib-compressed content objects.
67
 *
68
 * &lt;BE guint32 containing variant length&gt;
69
 * t - size
70
 * u - uid
71
 * u - gid
72
 * u - mode
73
 * u - rdev (must be 0)
74
 * s - symlink target
75
 * a(ayay) - xattrs
76
 * ---
77
 * zlib-compressed data
78
 */
79
70
#define _OSTREE_ZLIB_FILE_HEADER_GVARIANT_FORMAT G_VARIANT_TYPE ("(tuuuusa(ayay))")
80
81
GBytes *_ostree_file_header_new (GFileInfo *file_info, GVariant *xattrs);
82
83
GBytes *_ostree_zlib_file_header_new (GFileInfo *file_info, GVariant *xattrs);
84
85
gboolean _ostree_make_temporary_symlink_at (int tmp_dirfd, const char *target, char **out_name,
86
                                            GCancellable *cancellable, GError **error);
87
88
GFileInfo *_ostree_stbuf_to_gfileinfo (const struct stat *stbuf);
89
void _ostree_gfileinfo_to_stbuf (GFileInfo *file_info, struct stat *out_stbuf);
90
gboolean _ostree_gfileinfo_equal (GFileInfo *a, GFileInfo *b);
91
gboolean _ostree_stbuf_equal (struct stat *stbuf_a, struct stat *stbuf_b);
92
GFileInfo *_ostree_mode_uidgid_to_gfileinfo (mode_t mode, uid_t uid, gid_t gid);
93
GVariant *_ostree_canonicalize_xattrs (GVariant *xattrs);
94
gboolean _ostree_validate_structureof_xattrs (GVariant *xattrs, GError **error);
95
96
static inline void
97
_ostree_checksum_inplace_from_bytes_v (GVariant *csum_v, char *buf)
98
0
{
99
0
  const guint8 *csum = ostree_checksum_bytes_peek (csum_v);
100
0
  g_assert (csum);
101
0
  ostree_checksum_inplace_from_bytes (csum, buf);
102
0
}
Unexecuted instantiation: ostree-core.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-repo.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-repo-commit.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-repo-composefs.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-repo-refs.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-repo-verity.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-sysroot.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-sysroot-cleanup.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-sysroot-deploy.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-repo-static-delta-core.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-repo-static-delta-processing.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-mutable-tree.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-ref.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-repo-checkout.c:_ostree_checksum_inplace_from_bytes_v
Unexecuted instantiation: ostree-repo-prune.c:_ostree_checksum_inplace_from_bytes_v
103
104
/* XX/checksum-2.extension, but let's just use 256 for a
105
 * bit of overkill.
106
 */
107
0
#define _OSTREE_LOOSE_PATH_MAX (256)
108
109
/* GVariant format for ostree.sizes metadata entries. */
110
#define _OSTREE_OBJECT_SIZES_ENTRY_SIGNATURE "ay"
111
112
char *_ostree_get_relative_object_path (const char *checksum, OstreeObjectType type,
113
                                        gboolean compressed);
114
115
char *_ostree_get_relative_static_delta_path (const char *from, const char *to, const char *target);
116
117
char *_ostree_get_relative_static_delta_superblock_path (const char *from, const char *to);
118
119
char *_ostree_get_relative_static_delta_detachedmeta_path (const char *from, const char *to);
120
121
char *_ostree_get_relative_static_delta_part_path (const char *from, const char *to, guint i);
122
123
char *_ostree_get_relative_static_delta_index_path (const char *to);
124
125
static inline char *
126
_ostree_get_commitpartial_path (const char *checksum)
127
0
{
128
0
  return g_strconcat ("state/", checksum, ".commitpartial", NULL);
129
0
}
Unexecuted instantiation: ostree-core.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-repo.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-repo-commit.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-repo-composefs.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-repo-refs.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-repo-verity.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-sysroot.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-sysroot-cleanup.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-sysroot-deploy.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-repo-static-delta-core.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-repo-static-delta-processing.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-mutable-tree.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-ref.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-repo-checkout.c:_ostree_get_commitpartial_path
Unexecuted instantiation: ostree-repo-prune.c:_ostree_get_commitpartial_path
130
131
gboolean _ostree_validate_ref_fragment (const char *fragment, GError **error);
132
133
gboolean _ostree_validate_bareuseronly_mode (guint32 mode, const char *checksum, GError **error);
134
static inline gboolean
135
_ostree_validate_bareuseronly_mode_finfo (GFileInfo *finfo, const char *checksum, GError **error)
136
0
{
137
0
  const guint32 content_mode = g_file_info_get_attribute_uint32 (finfo, "unix::mode");
138
0
  return _ostree_validate_bareuseronly_mode (content_mode, checksum, error);
139
0
}
Unexecuted instantiation: ostree-core.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-repo.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-repo-commit.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-repo-composefs.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-repo-refs.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-repo-verity.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-sysroot.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-sysroot-cleanup.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-sysroot-deploy.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-repo-static-delta-core.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-repo-static-delta-processing.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-mutable-tree.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-ref.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-repo-checkout.c:_ostree_validate_bareuseronly_mode_finfo
Unexecuted instantiation: ostree-repo-prune.c:_ostree_validate_bareuseronly_mode_finfo
140
141
gboolean _ostree_compare_object_checksum (OstreeObjectType objtype, const char *expected,
142
                                          const char *actual, GError **error);
143
144
gboolean _ostree_parse_delta_name (const char *delta_name, char **out_from, char **out_to,
145
                                   GError **error);
146
147
void _ostree_loose_path (char *buf, const char *checksum, OstreeObjectType objtype,
148
                         OstreeRepoMode repo_mode);
149
150
gboolean _ostree_validate_structureof_metadata (OstreeObjectType objtype, GVariant *commit,
151
                                                GError **error);
152
153
gboolean _ostree_verify_metadata_object (OstreeObjectType objtype, const char *expected_checksum,
154
                                         GVariant *metadata, GError **error);
155
156
0
#define _OSTREE_METADATA_GPGSIGS_NAME "ostree.gpgsigs"
157
0
#define _OSTREE_METADATA_GPGSIGS_TYPE G_VARIANT_TYPE ("aay")
158
159
static inline gboolean
160
_ostree_repo_mode_is_bare (OstreeRepoMode mode)
161
0
{
162
0
  return mode == OSTREE_REPO_MODE_BARE || mode == OSTREE_REPO_MODE_BARE_USER
163
0
         || mode == OSTREE_REPO_MODE_BARE_USER_ONLY || mode == OSTREE_REPO_MODE_BARE_SPLIT_XATTRS;
164
0
}
Unexecuted instantiation: ostree-core.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-repo.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-repo-commit.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-repo-composefs.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-repo-refs.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-repo-verity.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-sysroot.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-sysroot-cleanup.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-sysroot-deploy.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-repo-static-delta-core.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-repo-static-delta-processing.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-mutable-tree.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-ref.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-repo-checkout.c:_ostree_repo_mode_is_bare
Unexecuted instantiation: ostree-repo-prune.c:_ostree_repo_mode_is_bare
165
166
#ifndef OSTREE_DISABLE_GPGME
167
GVariant *_ostree_detached_metadata_append_gpg_sig (GVariant *existing_metadata,
168
                                                    GBytes *signature_bytes);
169
#endif
170
171
GFile *_ostree_get_default_sysroot_path (void);
172
173
_OSTREE_PUBLIC
174
gboolean _ostree_raw_file_to_archive_stream (GInputStream *input, GFileInfo *file_info,
175
                                             GVariant *xattrs, guint compression_level,
176
                                             GInputStream **out_input, GCancellable *cancellable,
177
                                             GError **error);
178
179
gboolean _ostree_compare_timestamps (const char *current_rev, guint64 current_ts,
180
                                     const char *new_rev, guint64 new_ts, GError **error);
181
182
G_END_DECLS