Commit 6e8dcf6c authored by Nils Goroll's avatar Nils Goroll

implement remove correctly

parent b27c61ba
......@@ -700,9 +700,23 @@ our(unlink)(const char *p) {
return our(unlinkat)(AT_FDCWD, p, 0);
}
static inline int
removeat(int fd, const char *p) {
#ifdef _LP64
struct stat tstat;
#else
struct stat64 tstat;
#endif
if (real64(fstatat)(fd, p, &tstat, AT_SYMLINK_NOFOLLOW) == -1)
return -1;
return real(unlinkat)(fd, p,
(tstat.st_mode & S_IFDIR) ? AT_REMOVEDIR : 0);
}
int
our(remove)(const char *p) {
return our(unlinkat)(AT_FDCWD, p, 0);
Xatl(removeat, AT_FDCWD, p);
}
/** SYMLINK **/
......
......@@ -171,6 +171,10 @@ test_file(const char *path, const char *path2) {
/* TEST unlinkl */
ok(unlinkl, linkpath);
/* TEST removel */
ok(linkl, path, linkpath);
ok(removel, linkpath);
/* TEST symlinkl */
ok(symlinkl, strrchr(path, '/') + 1, linkpath);
......@@ -218,6 +222,10 @@ test_dir(const char *path, const char *path2) {
/* TEST rmdirl */
ok(rmdirl, cdp1);
/* TEST removel */
ok(mkdirl, cdp1, 0700);
ok(removel, cdp1);
cdp1 = cdp2 = NULL;
/* TEST mkdtempl */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment