summaryrefslogtreecommitdiff
path: root/src/libotutil/ot-fs-utils.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2014-12-15 22:23:37 -0500
committerColin Walters <walters@verbum.org>2015-01-06 22:43:14 -0500
commit026c5c60d3aa5ffc529e64f136aa5e468a315d62 (patch)
tree73c05d99d677a292075d2db45cd1319862a7a933 /src/libotutil/ot-fs-utils.c
parentcf8d6848b3264eb5b92590d9802c1a0bd579b4c6 (diff)
downloadostree-026c5c60d3aa5ffc529e64f136aa5e468a315d62.tar.gz
Use *at() functions for native filesystem commits
This is just an efficiency optimization. We're getting fairly close to all of the hot code paths using `*at()`. Note that we end up maintaining a half-duplicate code path set here, because we still need to support commits from an arbitrary GFile *, which in a possible common case is an OSTree commit. I think it's worth it though.
Diffstat (limited to 'src/libotutil/ot-fs-utils.c')
-rw-r--r--src/libotutil/ot-fs-utils.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libotutil/ot-fs-utils.c b/src/libotutil/ot-fs-utils.c
index bd834130..3ca62352 100644
--- a/src/libotutil/ot-fs-utils.c
+++ b/src/libotutil/ot-fs-utils.c
@@ -115,3 +115,31 @@ ot_lsetxattrat (int dfd,
return TRUE;
}
+
+gboolean
+ot_readlinkat_gfile_info (int dfd,
+ const char *path,
+ GFileInfo *target_info,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gboolean ret = FALSE;
+ char targetbuf[PATH_MAX+1];
+ ssize_t len;
+
+ do
+ len = readlinkat (dfd, path, targetbuf, sizeof (targetbuf) - 1);
+ while (G_UNLIKELY (len == -1 && errno == EINTR));
+ if (len == -1)
+ {
+ gs_set_error_from_errno (error, errno);
+ goto out;
+ }
+ targetbuf[len] = '\0';
+ g_file_info_set_symlink_target (target_info, targetbuf);
+
+ ret = TRUE;
+ out:
+ return ret;
+}
+