OBS-URL: https://build.opensuse.org/request/show/423993 OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/lxcfs?expand=0&rev=6
72 lines
2.0 KiB
Diff
72 lines
2.0 KiB
Diff
From 2e81a5e3d8f70f395b83941e3a0277f995c27e08 Mon Sep 17 00:00:00 2001
|
|
From: Christian Brauner <cbrauner@suse.de>
|
|
Date: Mon, 22 Aug 2016 02:47:27 +0200
|
|
Subject: [PATCH 06/24] bindings: use openat fd for fstatat(), unlinkat()
|
|
|
|
Signed-off-by: Christian Brauner <cbrauner@suse.de>
|
|
---
|
|
bindings.c | 15 ++++++---------
|
|
1 file changed, 6 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/bindings.c b/bindings.c
|
|
index e3975cc..f0e7b80 100644
|
|
--- a/bindings.c
|
|
+++ b/bindings.c
|
|
@@ -571,7 +571,7 @@ int cgfs_create(const char *controller, const char *cg, uid_t uid, gid_t gid)
|
|
return 0;
|
|
}
|
|
|
|
-static bool recursive_rmdir(const char *dirname, int fd)
|
|
+static bool recursive_rmdir(const char *dirname, int fd, int cfd)
|
|
{
|
|
struct dirent *direntp;
|
|
DIR *dir;
|
|
@@ -593,9 +593,6 @@ static bool recursive_rmdir(const char *dirname, int fd)
|
|
struct stat mystat;
|
|
int rc;
|
|
|
|
- if (!direntp)
|
|
- break;
|
|
-
|
|
if (!strcmp(direntp->d_name, ".") ||
|
|
!strcmp(direntp->d_name, ".."))
|
|
continue;
|
|
@@ -606,13 +603,13 @@ static bool recursive_rmdir(const char *dirname, int fd)
|
|
continue;
|
|
}
|
|
|
|
- ret = fstatat(fd, pathname, &mystat, AT_SYMLINK_NOFOLLOW);
|
|
- if (ret) {
|
|
+ rc = fstatat(cfd, pathname, &mystat, AT_SYMLINK_NOFOLLOW);
|
|
+ if (rc) {
|
|
lxcfs_debug("Failed to stat %s: %s.\n", pathname, strerror(errno));
|
|
continue;
|
|
}
|
|
if (S_ISDIR(mystat.st_mode))
|
|
- if (!recursive_rmdir(pathname, fd))
|
|
+ if (!recursive_rmdir(pathname, fd, cfd))
|
|
lxcfs_debug("Error removing %s.\n", pathname);
|
|
}
|
|
|
|
@@ -622,7 +619,7 @@ static bool recursive_rmdir(const char *dirname, int fd)
|
|
ret = false;
|
|
}
|
|
|
|
- if (unlinkat(fd, dirname, AT_REMOVEDIR) < 0) {
|
|
+ if (unlinkat(cfd, dirname, AT_REMOVEDIR) < 0) {
|
|
lxcfs_debug("Failed to delete %s: %s.\n", dirname, strerror(errno));
|
|
ret = false;
|
|
}
|
|
@@ -652,7 +649,7 @@ bool cgfs_remove(const char *controller, const char *cg)
|
|
if (fd < 0)
|
|
return false;
|
|
|
|
- return recursive_rmdir(dirnam, fd);
|
|
+ return recursive_rmdir(dirnam, fd, cfd);
|
|
}
|
|
|
|
bool cgfs_chmod_file(const char *controller, const char *file, mode_t mode)
|
|
--
|
|
2.9.3
|
|
|