summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-bootconfig-parser.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2015-04-20 22:23:39 -0400
committerColin Walters <walters@verbum.org>2015-12-19 08:24:51 -0500
commit3a4f90cf8e30284f336918ffb0c3bd56f4cb3fde (patch)
tree97d2e7bb609985b1e5a4100f44f22fca7e0572c3 /src/libostree/ostree-bootconfig-parser.c
parent506a891e36d384cb1343f2da1477c5b07abe6731 (diff)
downloadostree-3a4f90cf8e30284f336918ffb0c3bd56f4cb3fde.tar.gz
bootconfig: Add ostree_bootconfig_parser_write_at
This fd-relative API will be used by later libostree porting in the deploy code path.
Diffstat (limited to 'src/libostree/ostree-bootconfig-parser.c')
-rw-r--r--src/libostree/ostree-bootconfig-parser.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/libostree/ostree-bootconfig-parser.c b/src/libostree/ostree-bootconfig-parser.c
index 6320b5bb..661e759d 100644
--- a/src/libostree/ostree-bootconfig-parser.c
+++ b/src/libostree/ostree-bootconfig-parser.c
@@ -158,18 +158,18 @@ write_key (OstreeBootconfigParser *self,
g_string_append (buf, value);
g_string_append_c (buf, '\n');
}
-
+
gboolean
-ostree_bootconfig_parser_write (OstreeBootconfigParser *self,
- GFile *output,
- GCancellable *cancellable,
- GError **error)
+ostree_bootconfig_parser_write_at (OstreeBootconfigParser *self,
+ int dfd,
+ const char *path,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
GHashTableIter hashiter;
gpointer hashkey, hashvalue;
GString *buf = g_string_new ("");
- g_autoptr(GBytes) bytes = NULL;
guint i;
g_autoptr(GHashTable) written_overrides = NULL;
@@ -205,18 +205,28 @@ ostree_bootconfig_parser_write (OstreeBootconfigParser *self,
write_key (self, buf, hashkey, hashvalue);
}
- bytes = g_string_free_to_bytes (buf);
- buf = NULL;
-
- if (!ot_gfile_replace_contents_fsync (output, bytes,
- cancellable, error))
+ if (!glnx_file_replace_contents_at (dfd, path, (guint8*)buf->str, buf->len,
+ GLNX_FILE_REPLACE_NODATASYNC,
+ cancellable, error))
goto out;
ret = TRUE;
out:
- if (buf) g_string_free (buf, TRUE);
+ if (buf)
+ g_string_free (buf, TRUE);
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
ostree_bootconfig_parser_finalize (GObject *object)