mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-05 13:18:17 +03:00
ostree_kernel_args_contains for OstreeKernelArgs
Check if an argument is present in OstreeKernelArgs. This is a way to make easier idempotent append and delete operations. ostree_kernel_args_append_if_missing uses it to avoid inserting a duplicate key. Closes #2329 Signed-off-by: Rafael Garcia Ruiz <rafael.garcia@collabora.com>
This commit is contained in:
parent
0dbd87c017
commit
c4db171dae
@ -171,9 +171,9 @@ endif # USE_GPGME
|
|||||||
symbol_files = $(top_srcdir)/src/libostree/libostree-released.sym
|
symbol_files = $(top_srcdir)/src/libostree/libostree-released.sym
|
||||||
|
|
||||||
# Uncomment this include when adding new development symbols.
|
# Uncomment this include when adding new development symbols.
|
||||||
#if BUILDOPT_IS_DEVEL_BUILD
|
if BUILDOPT_IS_DEVEL_BUILD
|
||||||
#symbol_files += $(top_srcdir)/src/libostree/libostree-devel.sym
|
symbol_files += $(top_srcdir)/src/libostree/libostree-devel.sym
|
||||||
#endif
|
endif
|
||||||
|
|
||||||
# http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html
|
# http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html
|
||||||
wl_versionscript_arg = -Wl,--version-script=
|
wl_versionscript_arg = -Wl,--version-script=
|
||||||
|
@ -738,6 +738,7 @@ ostree_kernel_args_get_last_value
|
|||||||
ostree_kernel_args_from_string
|
ostree_kernel_args_from_string
|
||||||
ostree_kernel_args_to_strv
|
ostree_kernel_args_to_strv
|
||||||
ostree_kernel_args_to_string
|
ostree_kernel_args_to_string
|
||||||
|
ostree_kernel_args_contains
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
|
@ -1313,6 +1313,12 @@ extern "C" {
|
|||||||
#[cfg(any(feature = "v2022_5", feature = "dox"))]
|
#[cfg(any(feature = "v2022_5", feature = "dox"))]
|
||||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2022_5")))]
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2022_5")))]
|
||||||
pub fn ostree_kernel_args_append_if_missing(kargs: *mut OstreeKernelArgs, arg: *const c_char);
|
pub fn ostree_kernel_args_append_if_missing(kargs: *mut OstreeKernelArgs, arg: *const c_char);
|
||||||
|
#[cfg(any(feature = "v2022_7", feature = "dox"))]
|
||||||
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2022_7")))]
|
||||||
|
pub fn ostree_kernel_args_contains(
|
||||||
|
kargs: *mut OstreeKernelArgs,
|
||||||
|
arg: *const c_char,
|
||||||
|
) -> gboolean;
|
||||||
#[cfg(any(feature = "v2019_3", feature = "dox"))]
|
#[cfg(any(feature = "v2019_3", feature = "dox"))]
|
||||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2019_3")))]
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2019_3")))]
|
||||||
pub fn ostree_kernel_args_append_proc_cmdline(
|
pub fn ostree_kernel_args_append_proc_cmdline(
|
||||||
|
@ -20,6 +20,10 @@
|
|||||||
- uncomment the include in Makefile-libostree.am
|
- uncomment the include in Makefile-libostree.am
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
LIBOSTREE_2022.7 {
|
||||||
|
global:
|
||||||
|
ostree_kernel_args_contains;
|
||||||
|
} LIBOSTREE_2022.5;
|
||||||
|
|
||||||
/* Stub section for the stable release *after* this development one; don't
|
/* Stub section for the stable release *after* this development one; don't
|
||||||
* edit this other than to update the year. This is just a copy/paste
|
* edit this other than to update the year. This is just a copy/paste
|
||||||
|
@ -820,12 +820,31 @@ void
|
|||||||
ostree_kernel_args_append_if_missing (OstreeKernelArgs *kargs,
|
ostree_kernel_args_append_if_missing (OstreeKernelArgs *kargs,
|
||||||
const char *arg)
|
const char *arg)
|
||||||
{
|
{
|
||||||
g_autofree char *key = g_strdup (arg);
|
|
||||||
split_keyeq (key);
|
|
||||||
|
|
||||||
// Don't insert a duplicate key.
|
// Don't insert a duplicate key.
|
||||||
if (g_hash_table_contains (kargs->table, key))
|
if (ostree_kernel_args_contains (kargs, arg))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ostree_kernel_args_append (kargs, arg);
|
ostree_kernel_args_append (kargs, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ostree_kernel_args_contains:
|
||||||
|
* @kargs: a OstreeKernelArgs instance
|
||||||
|
* @arg: key or key/value pair to check
|
||||||
|
*
|
||||||
|
* Search for @arg which is in the form of key=value pair at the hash table kargs->table
|
||||||
|
* and returns true if finds it.
|
||||||
|
*
|
||||||
|
*Returns: %TRUE if @arg is contained in @kargs, %FALSE otherwise.
|
||||||
|
*
|
||||||
|
* Since: 2022.7
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
ostree_kernel_args_contains (OstreeKernelArgs *kargs,
|
||||||
|
const char *arg)
|
||||||
|
{
|
||||||
|
g_autofree char *key = g_strdup (arg);
|
||||||
|
split_keyeq (key);
|
||||||
|
|
||||||
|
return g_hash_table_contains (kargs->table, key);
|
||||||
|
}
|
||||||
|
@ -134,4 +134,8 @@ _OSTREE_PUBLIC
|
|||||||
void ostree_kernel_args_append_if_missing (OstreeKernelArgs *kargs,
|
void ostree_kernel_args_append_if_missing (OstreeKernelArgs *kargs,
|
||||||
const char *arg);
|
const char *arg);
|
||||||
|
|
||||||
|
_OSTREE_PUBLIC
|
||||||
|
gboolean ostree_kernel_args_contains (OstreeKernelArgs *kargs,
|
||||||
|
const char *arg);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
Loading…
Reference in New Issue
Block a user