sysroot/deploy: Some cleanup to decl-after-stmt/return FALSE style

And fd-relative. I also introduced some helpers here which I'll use later in
more invasive patches.

Closes: #742
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2017-03-20 19:56:48 +00:00
1 parent df5cbc9be9
commit ec2f52e625
3 files changed
+115 -122

No files matched your search

+34
View File
@@ -25,6 +25,16 @@
#include <sys/xattr.h>
#include <gio/gunixinputstream.h>
/* Convert a fd-relative path to a GFile* - use
* for legacy code.
*/
GFile *
ot_fdrel_to_gfile (int dfd, const char *path)
{
g_autofree char *abspath = glnx_fdrel_abspath (dfd, path);
return g_file_new_for_path (abspath);
}
int
ot_opendirat (int dfd, const char *path, gboolean follow)
{
@@ -205,6 +215,30 @@ ot_ensure_unlinked_at (int dfd,
return TRUE;
}
gboolean
ot_query_exists_at (int dfd, const char *path,
gboolean *out_exists,
GError **error)
{
struct stat stbuf;
gboolean ret_exists;
if (fstatat (dfd, path, &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
{
if (errno != ENOENT)
{
glnx_set_error_from_errno (error);
return FALSE;
}
ret_exists = FALSE;
}
else
ret_exists = TRUE;
*out_exists = ret_exists;
return TRUE;
}
gboolean
ot_openat_ignore_enoent (int dfd,
const char *path,
+7
View File
@@ -24,6 +24,8 @@
G_BEGIN_DECLS
GFile * ot_fdrel_to_gfile (int dfd, const char *path);
int ot_opendirat (int dfd, const char *path, gboolean follow);
gboolean ot_gopendirat (int dfd,
const char *path,
@@ -57,6 +59,11 @@ gboolean ot_openat_read_stream (int dfd,
GCancellable *cancellable,
GError **error);
gboolean ot_query_exists_at (int dfd, const char *path,
gboolean *out_exists,
GError **error);
gboolean ot_ensure_unlinked_at (int dfd,
const char *path,
GError **error);