Skip to content
Snippets Groups Projects
Commit 90390949 authored by Colin Walters's avatar Colin Walters
Browse files

fdio: glnx_file_copy_at: If no stbuf passed, do stat internally

There are some cases where we want to copy with just a filename,
so let's be convenient in that case and do stat for the caller.

This will be used by an ostree commit.
parent 381ca54e
Branches
Tags
No related merge requests found
......@@ -484,6 +484,7 @@ glnx_file_copy_at (int src_dfd,
struct timespec ts[2];
glnx_fd_close int src_fd = -1;
glnx_fd_close int dest_fd = -1;
struct stat local_stbuf;
if (g_cancellable_set_error_if_cancelled (cancellable, error))
goto out;
......@@ -491,6 +492,17 @@ glnx_file_copy_at (int src_dfd,
src_dfd = glnx_dirfd_canonicalize (src_dfd);
dest_dfd = glnx_dirfd_canonicalize (dest_dfd);
/* Automatically do stat() if no stat buffer was supplied */
if (!src_stbuf)
{
if (fstatat (src_dfd, src_subpath, &local_stbuf, AT_SYMLINK_NOFOLLOW) != 0)
{
glnx_set_error_from_errno (error);
goto out;
}
src_stbuf = &local_stbuf;
}
if (S_ISLNK (src_stbuf->st_mode))
{
return copy_symlink_at (src_dfd, src_subpath, src_stbuf,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment