![]() |
![]() |
![]() |
fwupd Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
enum FuAppFlags; enum FuPathKind; void (*FuOutputHandler) (const gchar *line
,gpointer user_data
); gboolean fu_common_spawn_sync (const gchar * const *argv
,FuOutputHandler handler_cb
,gpointer handler_user_data
,GCancellable *cancellable
,GError **error
); gchar * fu_common_get_path (FuPathKind path_kind
); gboolean fu_common_rmtree (const gchar *directory
,GError **error
); GPtrArray * fu_common_get_files_recursive (const gchar *path
,GError **error
); gboolean fu_common_mkdir_parent (const gchar *filename
,GError **error
); gboolean fu_common_set_contents_bytes (const gchar *filename
,GBytes *bytes
,GError **error
); GBytes * fu_common_get_contents_bytes (const gchar *filename
,GError **error
); GBytes * fu_common_get_contents_fd (gint fd
,gsize count
,GError **error
); gboolean fu_common_extract_archive (GBytes *blob
,const gchar *dir
,GError **error
); GBytes * fu_common_firmware_builder (GBytes *bytes
,const gchar *script_fn
,const gchar *output_fn
,GError **error
); GError * fu_common_error_array_get_best (GPtrArray *errors
); typedef FuEndianType; void fu_common_write_uint16 (guint8 *buf
,guint16 val_native
,FuEndianType endian
); void fu_common_write_uint32 (guint8 *buf
,guint32 val_native
,FuEndianType endian
); guint16 fu_common_read_uint16 (const guint8 *buf
,FuEndianType endian
); guint32 fu_common_read_uint32 (const guint8 *buf
,FuEndianType endian
);
typedef enum { FU_APP_FLAGS_NONE = 0, FU_APP_FLAGS_NO_IDLE_SOURCES = 1 << 0, FU_APP_FLAGS_LAST } FuAppFlags;
typedef enum { FU_PATH_KIND_CACHEDIR_PKG, FU_PATH_KIND_DATADIR_PKG, FU_PATH_KIND_LOCALSTATEDIR, FU_PATH_KIND_LOCALSTATEDIR_PKG, FU_PATH_KIND_PLUGINDIR_PKG, FU_PATH_KIND_SYSCONFDIR, FU_PATH_KIND_SYSCONFDIR_PKG, FU_PATH_KIND_LAST } FuPathKind;
gboolean fu_common_spawn_sync (const gchar * const *argv
,FuOutputHandler handler_cb
,gpointer handler_user_data
,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.
|
The argument list to run |
|
A FuOutputHandler or NULL . [scope call]
|
|
the user data to pass to handler_cb
|
|
a GCancellable, or NULL
|
|
A GError or NULL
|
Returns : |
TRUE for success |
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
.
|
A FuPathKind e.g. FU_PATH_KIND_DATADIR_PKG
|
Returns : |
a system path, or NULL if invalid |
gboolean fu_common_rmtree (const gchar *directory
,GError **error
);
Recursively removes a directory.
|
a directory name |
|
A GError or NULL
|
Returns : |
TRUE for success, FALSE otherwise |
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.
|
a directory name |
|
A GError or NULL
|
Returns : |
array of files, or NULL for error. [element-type][transfer container]
|
gboolean fu_common_mkdir_parent (const gchar *filename
,GError **error
);
Creates any required directories, including any parent directories.
|
A full pathname |
|
A GError, or NULL
|
Returns : |
TRUE for success |
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.
|
A filename |
|
The data to write |
|
A GError, or NULL
|
Returns : |
TRUE for success |
GBytes * fu_common_get_contents_bytes (const gchar *filename
,GError **error
);
Reads a blob of data from a file.
|
A filename |
|
A GError, or NULL
|
Returns : |
a GBytes, or NULL for failure |
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
|
A file descriptor |
|
The maximum number of bytes to read |
|
A GError, or NULL
|
Returns : |
a GBytes, or NULL . [transfer full]
|
gboolean fu_common_extract_archive (GBytes *blob
,const gchar *dir
,GError **error
);
Extracts an achive to a directory.
|
a GBytes archive as a blob |
|
a directory name to extract to |
|
A GError, or NULL
|
Returns : |
TRUE for success |
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:
1. The bytes
data is untarred to a temporary location
2. A bubblewrap container is set up
3. The startup.sh script is run inside the container
4. The firmware.bin is extracted from the container
5. The temporary location is deleted
|
The data to use |
|
Name of the script to run in the tarball, e.g. `startup.sh` |
|
Name of the generated firmware, e.g. `firmware.bin` |
|
A GError, or NULL
|
Returns : |
a new GBytes, or NULL for error |
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.
|
array of errors. [element-type GError] |
Returns : |
a GError, never NULL . [transfer full]
|
void fu_common_write_uint16 (guint8 *buf
,guint16 val_native
,FuEndianType endian
);
Writes a value to a buffer using a specified endian.
|
A writable buffer |
|
a value in host byte-order |
|
A FuEndianType, e.g. G_LITTLE_ENDIAN
|
void fu_common_write_uint32 (guint8 *buf
,guint32 val_native
,FuEndianType endian
);
Writes a value to a buffer using a specified endian.
|
A writable buffer |
|
a value in host byte-order |
|
A FuEndianType, e.g. G_LITTLE_ENDIAN
|
guint16 fu_common_read_uint16 (const guint8 *buf
,FuEndianType endian
);
Read a value from a buffer using a specified endian.
|
A readable buffer |
|
A FuEndianType, e.g. G_LITTLE_ENDIAN
|
Returns : |
a value in host byte-order |
guint32 fu_common_read_uint32 (const guint8 *buf
,FuEndianType endian
);
Read a value from a buffer using a specified endian.
|
A readable buffer |
|
A FuEndianType, e.g. G_LITTLE_ENDIAN
|
Returns : |
a value in host byte-order |