OSTree.KernelArgs

Fields

None

Methods

class

cleanup (loc)

append (arg)

append_argv (argv)

append_argv_filtered (argv, prefixes)

append_if_missing (arg)

append_proc_cmdline (cancellable)

contains (arg)

delete (arg)

delete_if_present (arg)

delete_key_entry (key)

free ()

get_last_value (key)

new_replace (arg)

parse_append (options)

replace (arg)

replace_argv (argv)

replace_take (arg)

to_string ()

to_strv ()

Details

class OSTree.KernelArgs
classmethod cleanup(loc)
Parameters:

loc (object or None) – Address of an OSTree.KernelArgs pointer

Frees the OSTree.KernelArgs structure pointed by *loc

New in version 2019.3.

append(arg)
Parameters:

arg (str) – key or key/value pair to be added

Appends arg which is in the form of key=value pair to the hash table kargs->table (appends to the value list if key is already in the hash table) and appends key to kargs->order if it is not in the hash table already.

New in version 2019.3.

append_argv(argv)
Parameters:

argv ([str]) – an array of key=value argument pairs

Appends each value in argv to the corresponding value array and appends key to kargs->order if it is not in the hash table already.

New in version 2019.3.

append_argv_filtered(argv, prefixes)
Parameters:
  • argv ([str]) – an array of key=value argument pairs

  • prefixes ([str]) – an array of prefix strings

Appends each argument that does not have one of the prefixes as prefix to the self

New in version 2019.3.

append_if_missing(arg)
Parameters:

arg (str) – key or key/value pair to be added

Appends arg which is in the form of key=value pair to the hash table kargs->table (appends to the value list if key is not in the hash table) and appends key to kargs->order if it is not in the hash table.

New in version 2022.5.

append_proc_cmdline(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – optional Gio.Cancellable object, None to ignore

Raises:

GLib.Error

Returns:

True on success, False on failure

Return type:

bool

Appends the command line arguments in the file “/proc/cmdline” that does not have “BOOT_IMAGE=” and “initrd=” as prefixes to the self

New in version 2019.3.

contains(arg)
Parameters:

arg (str) – key or key/value pair to check

Returns:

True if arg is contained in self, False otherwise.

Return type:

bool

Search for arg which is in the form of key=value pair at the hash table kargs->table and returns true if finds it.

New in version 2022.7.

delete(arg)
Parameters:

arg (str) – key or key/value pair for deletion

Raises:

GLib.Error

Return type:

bool

There are few scenarios being handled for deletion:

1: for input arg with a single key(i.e without = for split), the key/value pair will be deleted if there is only one value that is associated with the key

2: for input arg wth key/value pair, the specific key value pair will be deleted from the pointer array if those exist.

3: If the found key has only one value associated with it, the key entry in the table will also be removed, and the key will be removed from order table

Returns: True on success, False on failure

New in version 2019.3.

delete_if_present(arg)
Parameters:

arg (str) – key or key/value pair to be deleted

Raises:

GLib.Error

Returns:

True on success, False on failure

Return type:

bool

Deletes arg which is in the form of key=value pair from the hash table kargs->table.

New in version 2022.7.

delete_key_entry(key)
Parameters:

key (str) – the key to remove

Raises:

GLib.Error

Returns:

True on success, False on failure

Return type:

bool

This function removes the key entry from the hashtable as well from the order pointer array inside kargs

Note: since both table and order inside kernel args are with free function, no extra free functions are being called as they are done automatically by GLib

New in version 2019.3.

free()

Frees the kargs structure

New in version 2019.3.

get_last_value(key)
Parameters:

key (str) – a key to look for in self hash table

Returns:

None if key is not found in the self hash table, otherwise returns last element of value array corresponding to key

Return type:

str or None

Finds and returns the last element of value array corresponding to the key in self hash table. Note that the application will be terminated if the key is found but the value array is empty

New in version 2019.3.

new_replace(arg)
Parameters:

arg (str) – a string argument

Raises:

GLib.Error

Returns:

True on success, False on failure (and in some other instances such as:

key not found in self

old value not found when arg is in the form of key=old_val=new_val

multiple old values found when arg is in the form of key=old_val)

Return type:

bool

This function implements the basic logic behind key/value pair replacement. Do note that the arg need to be properly formatted

When replacing key with exact one value, the arg can be in the form: key, key=new_val, or key=old_val=new_val The first one swaps the old_val with the key to an empty value The second and third replace the old_val into the new_val

When replacing key with multiple values, the arg can only be in the form of: key=old_val=new_val. Unless there is a special case where there is an empty value associated with the key, then key=new_val will work because old_val is empty. The empty val will be swapped with the new_val in that case

New in version 2019.3.

parse_append(options)
Parameters:

options (str) – a string representing command line arguments

Parses options by separating it by whitespaces and appends each argument to self

New in version 2019.3.

replace(arg)
Parameters:

arg (str) – key or key/value pair for replacement

Finds and replaces the old key if arg is already in the hash table, otherwise adds arg as new key and split_keyeq (arg) as value. Note that when replacing old key value pair, the old values are freed.

New in version 2019.3.

replace_argv(argv)
Parameters:

argv (str) – an array of key or key/value pairs

Finds and replaces each non-null arguments of argv in the hash table, otherwise adds individual arg as new key and split_keyeq (arg) as value. Note that when replacing old key value pair, the old values are freed.

New in version 2019.3.

replace_take(arg)
Parameters:

arg (str) – key or key/value pair for replacement

Finds and replaces the old key if arg is already in the hash table, otherwise adds arg as new key and split_keyeq (arg) as value. Note that when replacing old key, the old values are freed.

New in version 2019.3.

to_string()
Returns:

a string of “key=value” pairs or “key” if value is None, separated by single whitespaces

Return type:

str

Extracts all key value pairs in self and appends to a temporary GLib.String in forms of “key=value” or “key” if value is None separated by a single whitespace, and returns the temporary string with the GLib.String wrapper freed

Note: the application will be terminated if one of the values array in self is None

New in version 2019.3.

to_strv()
Returns:

an array of “key=value” pairs or “key” if value is None

Return type:

[str]

Extracts all key value pairs in self and appends to a temporary array in forms of “key=value” or “key” if value is None, and returns the temporary array with the GLib.PtrArray wrapper freed

New in version 2019.3.