summaryrefslogtreecommitdiff
path: root/glnx-shutil.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2015-03-17 13:40:35 -0400
committerColin Walters <walters@verbum.org>2015-03-17 13:41:57 -0400
commitcf2a89f50633df330858efe963263b0577010718 (patch)
treea812290d0d793243ed3cbdec45378b6d736cdbe2 /glnx-shutil.c
parentc92adab47af5d3e75f4e4e73c50e02637f226ba8 (diff)
downloadlibglnx-cf2a89f50633df330858efe963263b0577010718.tar.gz
Add glnx_dirfd_canonicalize()
We want to honor `-1 == AT_FDCWD`.
Diffstat (limited to 'glnx-shutil.c')
-rw-r--r--glnx-shutil.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/glnx-shutil.c b/glnx-shutil.c
index 9fcb65a..967e364 100644
--- a/glnx-shutil.c
+++ b/glnx-shutil.c
@@ -118,7 +118,7 @@ glnx_shutil_rm_rf_children (GLnxDirFdIterator *dfd_iter,
/**
* glnx_shutil_rm_rf_at:
- * @dfd: A directory file descriptor, or -1 for current
+ * @dfd: A directory file descriptor, or `AT_FDCWD` or `-1` for current
* @path: Path
* @cancellable: Cancellable
* @error: Error
@@ -137,6 +137,8 @@ glnx_shutil_rm_rf_at (int dfd,
glnx_fd_close int target_dfd = -1;
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
+ dfd = glnx_dirfd_canonicalize (dfd);
+
/* With O_NOFOLLOW first */
target_dfd = openat (dfd, path,
O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);