bootconfig: Add ostree_bootconfig_parser_write_at
This fd-relative API will be used by later libostree porting in the deploy code path.
This commit is contained in:
parent
506a891e36
commit
3a4f90cf8e
|
|
@ -160,16 +160,16 @@ write_key (OstreeBootconfigParser *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_bootconfig_parser_write (OstreeBootconfigParser *self,
|
ostree_bootconfig_parser_write_at (OstreeBootconfigParser *self,
|
||||||
GFile *output,
|
int dfd,
|
||||||
GCancellable *cancellable,
|
const char *path,
|
||||||
GError **error)
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GHashTableIter hashiter;
|
GHashTableIter hashiter;
|
||||||
gpointer hashkey, hashvalue;
|
gpointer hashkey, hashvalue;
|
||||||
GString *buf = g_string_new ("");
|
GString *buf = g_string_new ("");
|
||||||
g_autoptr(GBytes) bytes = NULL;
|
|
||||||
guint i;
|
guint i;
|
||||||
g_autoptr(GHashTable) written_overrides = NULL;
|
g_autoptr(GHashTable) written_overrides = NULL;
|
||||||
|
|
||||||
|
|
@ -205,19 +205,29 @@ ostree_bootconfig_parser_write (OstreeBootconfigParser *self,
|
||||||
write_key (self, buf, hashkey, hashvalue);
|
write_key (self, buf, hashkey, hashvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes = g_string_free_to_bytes (buf);
|
if (!glnx_file_replace_contents_at (dfd, path, (guint8*)buf->str, buf->len,
|
||||||
buf = NULL;
|
GLNX_FILE_REPLACE_NODATASYNC,
|
||||||
|
cancellable, error))
|
||||||
if (!ot_gfile_replace_contents_fsync (output, bytes,
|
|
||||||
cancellable, error))
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
if (buf) g_string_free (buf, TRUE);
|
if (buf)
|
||||||
|
g_string_free (buf, TRUE);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ostree_bootconfig_parser_write (OstreeBootconfigParser *self,
|
||||||
|
GFile *output,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return ostree_bootconfig_parser_write_at (self,
|
||||||
|
AT_FDCWD, gs_file_get_path_cached (output),
|
||||||
|
cancellable, error);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ostree_bootconfig_parser_finalize (GObject *object)
|
ostree_bootconfig_parser_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,12 @@ gboolean ostree_bootconfig_parser_write (OstreeBootconfigParser *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
gboolean ostree_bootconfig_parser_write_at (OstreeBootconfigParser *self,
|
||||||
|
int dfd,
|
||||||
|
const char *path,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
void ostree_bootconfig_parser_set (OstreeBootconfigParser *self,
|
void ostree_bootconfig_parser_set (OstreeBootconfigParser *self,
|
||||||
const char *key,
|
const char *key,
|
||||||
const char *value);
|
const char *value);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue