diff options
author | Colin Walters <walters@verbum.org> | 2017-10-04 06:32:10 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-10-05 13:28:59 +0000 |
commit | 7f6af94c5a9a1ffa411636225baf5cb51de08144 (patch) | |
tree | 89d124677c0fb914f55c2f3ef931fd57c6a397a2 /src/libotutil/ot-fs-utils.c | |
parent | 9350e8a4881fce066e16fadce0240233016bed4b (diff) | |
download | ostree-7f6af94c5a9a1ffa411636225baf5cb51de08144.tar.gz |
lib/utils: Port a bit to decl-after-stmt style
Add add some more comments.
Closes: #1247
Approved by: jlebon
Diffstat (limited to 'src/libotutil/ot-fs-utils.c')
-rw-r--r-- | src/libotutil/ot-fs-utils.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/libotutil/ot-fs-utils.c b/src/libotutil/ot-fs-utils.c index 79ba3cf7..cad27496 100644 --- a/src/libotutil/ot-fs-utils.c +++ b/src/libotutil/ot-fs-utils.c @@ -36,6 +36,9 @@ ot_fdrel_to_gfile (int dfd, const char *path) return g_file_new_for_path (abspath); } +/* Wraps readlinkat(), and sets the `symlink-target` property + * of @target_info. + */ gboolean ot_readlinkat_gfile_info (int dfd, const char *path, @@ -54,7 +57,6 @@ ot_readlinkat_gfile_info (int dfd, return TRUE; } - /** * ot_openat_read_stream: * @dfd: Directory file descriptor @@ -77,16 +79,10 @@ ot_openat_read_stream (int dfd, GCancellable *cancellable, GError **error) { - int fd = -1; - int flags = O_RDONLY | O_NOCTTY | O_CLOEXEC; - - if (!follow) - flags |= O_NOFOLLOW; - - if (TEMP_FAILURE_RETRY (fd = openat (dfd, path, flags, 0)) < 0) - return glnx_throw_errno_prefix (error, "openat(%s)", path); - - *out_istream = g_unix_input_stream_new (fd, TRUE); + glnx_fd_close int fd = -1; + if (!glnx_openat_rdonly (dfd, path, follow, &fd, error)) + return FALSE; + *out_istream = g_unix_input_stream_new (glnx_steal_fd (&fd), TRUE); return TRUE; } |