Top | ![]() |
![]() |
![]() |
![]() |
enum | FuAppFlags |
enum | FuDumpFlags |
typedef | FuEndianType |
enum | FuPathKind |
enum | FuCpuVendor |
gboolean fu_common_spawn_sync (const gchar * const *argv
,FuOutputHandler handler_cb
,gpointer handler_user_data
,guint timeout_ms
,GCancellable *cancellable
,GError **error
);
Runs a subprocess and waits for it to exit. Any output on standard out or
standard error will be forwarded to handler_cb
as whole lines.
argv |
The argument list to run |
|
handler_cb |
A FuOutputHandler or |
[scope call] |
handler_user_data |
the user data to pass to |
|
timeout_ms |
a timeout in ms, or 0 for no limit |
|
cancellable |
a GCancellable, or |
|
error |
A GError or |
Since: 0.9.7
gchar *
fu_common_get_path (FuPathKind path_kind
);
Gets a fwupd-specific system path. These can be overridden with various
environment variables, for instance FWUPD_DATADIR
.
Since: 1.0.8
gchar * fu_common_realpath (const gchar *filename
,GError **error
);
Finds the canonicalized absolute filename for a path.
Since: 1.2.6
GPtrArray * fu_common_filename_glob (const gchar *directory
,const gchar *pattern
,GError **error
);
Returns all the filenames that match a specific glob pattern.
Any results are sorted. No matching files will set error
.
Since: 1.5.0
gboolean fu_common_fnmatch (const gchar *pattern
,const gchar *str
);
Matches a string against a glob pattern.
pattern |
a glob pattern, e.g. |
|
str |
a string to match against the pattern, e.g. |
Since: 1.3.5
gboolean fu_common_rmtree (const gchar *directory
,GError **error
);
Recursively removes a directory.
Since: 0.9.7
GPtrArray * fu_common_get_files_recursive (const gchar *path
,GError **error
);
Returns every file found under directory
, and any subdirectory.
If any path under directory
cannot be accessed due to permissions an error
will be returned.
Since: 1.0.6
gboolean fu_common_mkdir_parent (const gchar *filename
,GError **error
);
Creates any required directories, including any parent directories.
Since: 0.9.7
gboolean fu_common_set_contents_bytes (const gchar *filename
,GBytes *bytes
,GError **error
);
Writes a blob of data to a filename, creating the parent directories as required.
Since: 0.9.5
GBytes * fu_common_get_contents_bytes (const gchar *filename
,GError **error
);
Reads a blob of data from a file.
Since: 0.9.7
GBytes * fu_common_get_contents_fd (gint fd
,gsize count
,GError **error
);
Reads a blob from a specific file descriptor.
Note: this will close the fd when done
Since: 0.9.5
gboolean fu_common_extract_archive (GBytes *blob
,const gchar *dir
,GError **error
);
Extracts an archive to a directory.
blob |
a GBytes archive as a blob |
|
dir |
a directory name to extract to |
|
error |
A GError, or |
Since: 0.9.7
GBytes * fu_common_firmware_builder (GBytes *bytes
,const gchar *script_fn
,const gchar *output_fn
,GError **error
);
Builds a firmware file using tools from the host session in a bubblewrap jail. Several things happen during build:
The bytes
data is untarred to a temporary location
A bubblewrap container is set up
The startup.sh script is run inside the container
The firmware.bin is extracted from the container
The temporary location is deleted
bytes |
The data to use |
|
script_fn |
Name of the script to run in the tarball, e.g. |
|
output_fn |
Name of the generated firmware, e.g. |
|
error |
A GError, or |
Since: 0.9.7
GError *
fu_common_error_array_get_best (GPtrArray *errors
);
Finds the 'best' error to show the user from a array of errors, creating a completely bespoke error where required.
Since: 1.0.8
guint64
fu_common_strtoull (const gchar *str
);
Converts a string value to an integer. Values are assumed base 10, unless prefixed with "0x" where they are parsed as base 16.
Since: 1.1.2
gchar * fu_common_find_program_in_path (const gchar *basename
,GError **error
);
Looks for a program in the PATH variable
Since: 1.1.2
gchar *
fu_common_strstrip (const gchar *str
);
Removes leading and trailing whitespace from a constant string.
Since: 1.1.2
void fu_common_dump_raw (const gchar *log_domain
,const gchar *title
,const guint8 *data
,gsize len
);
Dumps a raw buffer to the screen.
log_domain |
log domain, typically |
|
title |
prefix title, or |
|
data |
buffer to print |
|
len |
the size of |
Since: 1.2.2
void fu_common_dump_full (const gchar *log_domain
,const gchar *title
,const guint8 *data
,gsize len
,guint columns
,FuDumpFlags flags
);
Dumps a raw buffer to the screen.
log_domain |
log domain, typically |
|
title |
prefix title, or |
|
data |
buffer to print |
|
len |
the size of |
|
columns |
break new lines after this many bytes |
|
flags |
some FuDumpFlags, e.g. |
Since: 1.2.4
void fu_common_dump_bytes (const gchar *log_domain
,const gchar *title
,GBytes *bytes
);
Dumps a byte buffer to the screen.
log_domain |
log domain, typically |
|
title |
prefix title, or |
|
bytes |
a GBytes |
Since: 1.2.2
GBytes * fu_common_bytes_align (GBytes *bytes
,gsize blksz
,gchar padval
);
Aligns a block of memory to blksize
using the padval
value; if
the block is already aligned then the original bytes
is returned.
Since: 1.2.4
gboolean
fu_common_bytes_is_empty (GBytes *bytes
);
Checks if a byte array are just empty (0xff) bytes.
Since: 1.2.6
gboolean fu_common_bytes_compare (GBytes *bytes1
,GBytes *bytes2
,GError **error
);
Compares the buffers for equality.
Since: 1.2.6
gboolean fu_common_bytes_compare_raw (const guint8 *buf1
,gsize bufsz1
,const guint8 *buf2
,gsize bufsz2
,GError **error
);
Compares the buffers for equality.
buf1 |
a buffer |
|
bufsz1 |
sizeof |
|
buf2 |
another buffer |
|
bufsz2 |
sizeof |
|
error |
A GError or |
Since: 1.3.2
GBytes * fu_common_bytes_pad (GBytes *bytes
,gsize sz
);
Pads a GBytes to a minimum sz
with 0xff
.
Since: 1.3.1
GBytes * fu_common_bytes_new_offset (GBytes *bytes
,gsize offset
,gsize length
,GError **error
);
Creates a GBytes which is a subsection of another GBytes.
bytes |
a GBytes |
|
offset |
where subsection starts at |
|
length |
length of subsection |
|
error |
A GError or |
Since: 1.5.4
gsize
fu_common_strwidth (const gchar *text
);
Returns the width of the string in displayed characters on the console.
Since: 1.3.2
guint8 * fu_memdup_safe (const guint8 *src
,gsize n
,GError **error
);
Duplicates some memory using memdup in a safe way.
You don't need to use this function in "obviously correct" cases, nor should you use it when performance is a concern. Only us it when you're not sure if malicious data from a device or firmware could cause memory corruption.
NOTE: This function intentionally limits allocation size to 1GB.
Since: 1.5.6
gboolean fu_memcpy_safe (guint8 *dst
,gsize dst_sz
,gsize dst_offset
,const guint8 *src
,gsize src_sz
,gsize src_offset
,gsize n
,GError **error
);
Copies some memory using memcpy in a safe way. Providing the buffer sizes of both the destination and the source allows us to check for buffer overflow.
Providing the buffer offsets also allows us to check reading past the end of
the source buffer. For this reason the caller should NEVER add an offset to
src
or dst
.
You don't need to use this function in "obviously correct" cases, nor should you use it when performance is a concern. Only us it when you're not sure if malicious data from a device or firmware could cause memory corruption.
dst |
destination buffer |
|
dst_sz |
maximum size of |
|
dst_offset |
offset in bytes into |
|
src |
source buffer |
|
src_sz |
maximum size of |
|
src_offset |
offset in bytes into |
|
n |
number of bytes to copy from |
|
error |
A GError or |
Since: 1.3.1
gboolean fu_common_read_uint8_safe (const guint8 *buf
,gsize bufsz
,gsize offset
,guint8 *value
,GError **error
);
Read a value from a buffer in a safe way.
You don't need to use this function in "obviously correct" cases, nor should you use it when performance is a concern. Only us it when you're not sure if malicious data from a device or firmware could cause memory corruption.
buf |
source buffer |
|
bufsz |
maximum size of |
|
offset |
offset in bytes into |
|
value |
the parsed value. |
[out][allow-none] |
error |
A GError or |
Since: 1.3.3
gboolean fu_common_read_uint16_safe (const guint8 *buf
,gsize bufsz
,gsize offset
,guint16 *value
,FuEndianType endian
,GError **error
);
Read a value from a buffer using a specified endian in a safe way.
You don't need to use this function in "obviously correct" cases, nor should you use it when performance is a concern. Only us it when you're not sure if malicious data from a device or firmware could cause memory corruption.
buf |
source buffer |
|
bufsz |
maximum size of |
|
offset |
offset in bytes into |
|
value |
the parsed value. |
[out][allow-none] |
endian |
A FuEndianType, e.g. |
|
error |
A GError or |
Since: 1.3.3
gboolean fu_common_read_uint32_safe (const guint8 *buf
,gsize bufsz
,gsize offset
,guint32 *value
,FuEndianType endian
,GError **error
);
Read a value from a buffer using a specified endian in a safe way.
You don't need to use this function in "obviously correct" cases, nor should you use it when performance is a concern. Only us it when you're not sure if malicious data from a device or firmware could cause memory corruption.
buf |
source buffer |
|
bufsz |
maximum size of |
|
offset |
offset in bytes into |
|
value |
the parsed value. |
[out][allow-none] |
endian |
A FuEndianType, e.g. |
|
error |
A GError or |
Since: 1.3.3
gboolean fu_common_read_uint64_safe (const guint8 *buf
,gsize bufsz
,gsize offset
,guint64 *value
,FuEndianType endian
,GError **error
);
Read a value from a buffer using a specified endian in a safe way.
You don't need to use this function in "obviously correct" cases, nor should you use it when performance is a concern. Only us it when you're not sure if malicious data from a device or firmware could cause memory corruption.
buf |
source buffer |
|
bufsz |
maximum size of |
|
offset |
offset in bytes into |
|
value |
the parsed value. |
[out][allow-none] |
endian |
A FuEndianType, e.g. |
|
error |
A GError or |
Since: 1.5.8
gboolean fu_common_write_uint8_safe (guint8 *buf
,gsize bufsz
,gsize offset
,guint8 value
,GError **error
);
Write a value to a buffer in a safe way.
You don't need to use this function in "obviously correct" cases, nor should you use it when performance is a concern. Only us it when you're not sure if malicious data from a device or firmware could cause memory corruption.
buf |
source buffer |
|
bufsz |
maximum size of |
|
offset |
offset in bytes into |
|
value |
the value to write |
|
error |
A GError or |
Since: 1.5.8
gboolean fu_common_write_uint16_safe (guint8 *buf
,gsize bufsz
,gsize offset
,guint16 value
,FuEndianType endian
,GError **error
);
Write a value to a buffer using a specified endian in a safe way.
You don't need to use this function in "obviously correct" cases, nor should you use it when performance is a concern. Only us it when you're not sure if malicious data from a device or firmware could cause memory corruption.
buf |
source buffer |
|
bufsz |
maximum size of |
|
offset |
offset in bytes into |
|
value |
the value to write |
|
endian |
A FuEndianType, e.g. |
|
error |
A GError or |
Since: 1.5.8
gboolean fu_common_write_uint32_safe (guint8 *buf
,gsize bufsz
,gsize offset
,guint32 value
,FuEndianType endian
,GError **error
);
Write a value to a buffer using a specified endian in a safe way.
You don't need to use this function in "obviously correct" cases, nor should you use it when performance is a concern. Only us it when you're not sure if malicious data from a device or firmware could cause memory corruption.
buf |
source buffer |
|
bufsz |
maximum size of |
|
offset |
offset in bytes into |
|
value |
the value to write |
|
endian |
A FuEndianType, e.g. |
|
error |
A GError or |
Since: 1.5.8
gboolean fu_common_write_uint64_safe (guint8 *buf
,gsize bufsz
,gsize offset
,guint64 value
,FuEndianType endian
,GError **error
);
Write a value to a buffer using a specified endian in a safe way.
You don't need to use this function in "obviously correct" cases, nor should you use it when performance is a concern. Only us it when you're not sure if malicious data from a device or firmware could cause memory corruption.
buf |
source buffer |
|
bufsz |
maximum size of |
|
offset |
offset in bytes into |
|
value |
the value to write |
|
endian |
A FuEndianType, e.g. |
|
error |
A GError or |
Since: 1.5.8
void fu_byte_array_set_size (GByteArray *array
,guint length
);
Sets the size of the GByteArray, expanding it with NULs if necessary.
Since: 1.5.0
void fu_byte_array_append_uint8 (GByteArray *array
,guint8 data
);
Adds a 8 bit integer to a byte array
Since: 1.3.1
void fu_byte_array_append_uint16 (GByteArray *array
,guint16 data
,FuEndianType endian
);
Adds a 16 bit integer to a byte array
Since: 1.3.1
void fu_byte_array_append_uint32 (GByteArray *array
,guint32 data
,FuEndianType endian
);
Adds a 32 bit integer to a byte array
Since: 1.3.1
void fu_byte_array_append_uint64 (GByteArray *array
,guint64 data
,FuEndianType endian
);
Adds a 64 bit integer to a byte array
Since: 1.5.8
void fu_common_write_uint16 (guint8 *buf
,guint16 val_native
,FuEndianType endian
);
Writes a value to a buffer using a specified endian.
buf |
A writable buffer |
|
val_native |
a value in host byte-order |
|
endian |
A FuEndianType, e.g. |
Since: 1.0.3
void fu_common_write_uint32 (guint8 *buf
,guint32 val_native
,FuEndianType endian
);
Writes a value to a buffer using a specified endian.
buf |
A writable buffer |
|
val_native |
a value in host byte-order |
|
endian |
A FuEndianType, e.g. |
Since: 1.0.3
void fu_common_write_uint64 (guint8 *buf
,guint64 val_native
,FuEndianType endian
);
Writes a value to a buffer using a specified endian.
buf |
A writable buffer |
|
val_native |
a value in host byte-order |
|
endian |
A FuEndianType, e.g. |
Since: 1.5.8
guint16 fu_common_read_uint16 (const guint8 *buf
,FuEndianType endian
);
Read a value from a buffer using a specified endian.
Since: 1.0.3
guint32 fu_common_read_uint32 (const guint8 *buf
,FuEndianType endian
);
Read a value from a buffer using a specified endian.
Since: 1.0.3
guint64 fu_common_read_uint64 (const guint8 *buf
,FuEndianType endian
);
Read a value from a buffer using a specified endian.
Since: 1.5.8
guint fu_common_string_replace (GString *string
,const gchar *search
,const gchar *replace
);
Performs multiple search and replace operations on the given string.
string |
The GString to operate on |
|
search |
The text to search for |
|
replace |
The text to use for substitutions |
Since: 1.2.0
void fu_common_string_append_kv (GString *str
,guint idt
,const gchar *key
,const gchar *value
);
Appends a key and string value to a string
Since: 1.2.4
void fu_common_string_append_ku (GString *str
,guint idt
,const gchar *key
,guint64 value
);
Appends a key and unsigned integer to a string
Since: 1.2.4
void fu_common_string_append_kx (GString *str
,guint idt
,const gchar *key
,guint64 value
);
Appends a key and hex integer to a string
Since: 1.2.4
void fu_common_string_append_kb (GString *str
,guint idt
,const gchar *key
,gboolean value
);
Appends a key and boolean value to a string
Since: 1.2.4
gchar ** fu_common_strnsplit (const gchar *str
,gsize sz
,const gchar *delimiter
,gint max_tokens
);
Splits a string into a maximum of max_tokens
pieces, using the given
delimiter. If max_tokens
is reached, the remainder of string is appended
to the last token.
str |
a string to split |
|
sz |
size of |
|
delimiter |
a string which specifies the places at which to split the string |
|
max_tokens |
the maximum number of pieces to split |
Since: 1.3.1
gchar * fu_common_strsafe (const gchar *str
,gsize maxsz
);
Converts a string into something that can be safely printed.
Since: 1.5.5
gchar * fu_common_strjoin_array (const gchar *separator
,GPtrArray *array
);
Joins an array of strings together to form one long string, with the optional separator inserted between each of them.
If array
has no items, the return value will be an empty string.
If array
contains a single item, separator will not appear in the resulting
string.
separator |
string to insert between each of the strings, or |
[nullable] |
array |
A GPtrArray. |
[element-type utf8] |
Since: 1.5.6
gboolean
fu_common_kernel_locked_down (void
);
Determines if kernel lockdown in effect
Since: 1.3.8
gboolean fu_common_cpuid (guint32 leaf
,guint32 *eax
,guint32 *ebx
,guint32 *ecx
,guint32 *edx
,GError **error
);
Calls CPUID and returns the registers for the given leaf.
leaf |
The CPUID level, now called the 'leaf' by Intel |
|
eax |
EAX register. |
[out][nullable] |
ebx |
EBX register. |
[out][nullable] |
ecx |
ECX register. |
[out][nullable] |
edx |
EDX register. |
[out][nullable] |
error |
A GError or NULL |
Since: 1.5.0
gboolean
fu_common_is_cpu_intel (void
);
fu_common_is_cpu_intel
has been deprecated since version 1.5.5 and should not be used in newly-written code.
Use fu_common_get_cpu_vendor()
instead.
Uses CPUID to discover the CPU vendor and check if it is Intel.
Since: 1.5.0
FuCpuVendor
fu_common_get_cpu_vendor (void
);
Uses CPUID to discover the CPU vendor.
Since: 1.5.5
gboolean
fu_common_is_live_media (void
);
Checks if the user is running from a live media using various heuristics.
Since: 1.4.6
guint64
fu_common_get_memory_size (void
);
Returns the size of physical memory.
Since: 1.5.6
GPtrArray * fu_common_get_volumes_by_kind (const gchar *kind
,GError **error
);
Finds all volumes of a specific partition type
Since: 1.4.6
FuVolume * fu_common_get_volume_by_device (const gchar *device
,GError **error
);
Finds the first volume from the specified device.
Since: 1.5.1
FuVolume * fu_common_get_volume_by_devnum (guint32 devnum
,GError **error
);
Finds the first volume from the specified device.
Since: 1.5.1
FuVolume * fu_common_get_esp_for_path (const gchar *esp_path
,GError **error
);
Gets the platform ESP using a UNIX or UDisks path
Since: 1.4.6
FuVolume *
fu_common_get_esp_default (GError **error
);
Gets the platform default ESP
Since: 1.4.6
guint8 fu_common_crc8 (const guint8 *buf
,gsize bufsz
);
Returns the cyclic redundancy check value for the given memory buffer.
Since: 1.5.0
guint16 fu_common_crc16 (const guint8 *buf
,gsize bufsz
);
Returns the cyclic redundancy check value for the given memory buffer.
Since: 1.5.0
guint32 fu_common_crc32 (const guint8 *buf
,gsize bufsz
);
Returns the cyclic redundancy check value for the given memory buffer.
Since: 1.5.0
guint32 fu_common_crc32_full (const guint8 *buf
,gsize bufsz
,guint32 crc
,guint32 polynomial
);
Returns the cyclic redundancy check value for the given memory buffer.
buf |
memory buffer |
|
bufsz |
sizeof buf |
|
crc |
initial CRC value, typically 0xFFFFFFFF |
|
polynomial |
CRC polynomial, typically 0xEDB88320 |
Since: 1.5.0
Path types to use when dynamically determining a path at runtime
The cache directory (IE /var/cache/fwupd) |
||
The non-volatile data store (IE /usr/share/fwupd) |
||
The location to store EFI apps before install (IE /usr/libexec/fwupd/efi) |
||
The local state directory (IE /var) |
||
The local state directory for the package (IE /var/lib/fwupd) |
||
The location to look for plugins for package (IE /usr/lib/[triplet]/fwupd-plugins-3) |
||
The configuration location (IE /etc) |
||
The package configuration location (IE /etc/fwupd) |
||
The sysfs firmware location (IE /sys/firmware) |
||
The platform sysfs directory (IE /sys/bus/platform/drivers) |
||
The TPM sysfs directory (IE /sys/class/tpm) |
||
The procfs location (IE /proc) |
||
The directory for policy kit actions (IE /usr/share/polkit-1/actions/) |
||
The file for the offline trigger (IE /system-update) |
||
The sysfs security location (IE /sys/kernel/security) |
||
The location of the ACPI tables |