diff options
author | Colin Walters <walters@verbum.org> | 2017-06-26 13:04:35 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2017-06-26 13:37:05 -0400 |
commit | 4d34066a2ff5d806db35c3ac765f87ace460fa7e (patch) | |
tree | 7c56f74cc616c01b2569f5b0c4204aa70983c747 /glnx-fdio.h | |
parent | caa51ac24ffcdffcb610bc6ccc9da964d4be74ee (diff) | |
download | libglnx-4d34066a2ff5d806db35c3ac765f87ace460fa7e.tar.gz |
fdio: Add wrappers for renameat(), unlinkat()
Besides doing `TEMP_FAILURE_RETRY` and `GError` conversion,
these also prefix the error with arguments.
Diffstat (limited to 'glnx-fdio.h')
-rw-r--r-- | glnx-fdio.h | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/glnx-fdio.h b/glnx-fdio.h index 95574bd..bdccbe5 100644 --- a/glnx-fdio.h +++ b/glnx-fdio.h @@ -27,6 +27,7 @@ #include <sys/stat.h> #include <fcntl.h> #include <string.h> +#include <stdio.h> #include <sys/xattr.h> /* From systemd/src/shared/util.h */ /* When we include libgen.h because we need dirname() we immediately @@ -244,8 +245,42 @@ glnx_fstatat (int dfd, GError **error) { if (TEMP_FAILURE_RETRY (fstatat (dfd, path, buf, flags)) != 0) - return glnx_throw_errno (error); + return glnx_throw_errno_prefix (error, "fstatat(%s)", path); + return TRUE; +} + +/** + * glnx_renameat: + * + * Wrapper around renameat() which adds #GError support and ensures that it + * retries on %EINTR. + */ +static inline gboolean +glnx_renameat (int src_dfd, + const gchar *src_path, + int dest_dfd, + const gchar *dest_path, + GError **error) +{ + if (TEMP_FAILURE_RETRY (renameat (src_dfd, src_path, dest_dfd, dest_path)) != 0) + return glnx_throw_errno_prefix (error, "renameat(%s, %s)", src_path, dest_path); + return TRUE; +} +/** + * glnx_unlinkat: + * + * Wrapper around unlinkat() which adds #GError support and ensures that it + * retries on %EINTR. + */ +static inline gboolean +glnx_unlinkat (int dfd, + const gchar *path, + int flags, + GError **error) +{ + if (TEMP_FAILURE_RETRY (unlinkat (dfd, path, flags)) != 0) + return glnx_throw_errno_prefix (error, "unlinkat(%s)", path); return TRUE; } |