My thought is that glibc has some kind of fallback code if you use unlinkat on a system that doesn't support it, and that's what's broken; since these are all being compiled with the same glibc, the libc symbol should always exist, no? Adam, could you try building/running the attached? If it also fails, it ain't coreutils.

Mike Stone
#define _ATFILE_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <fcntl.h>
#include <stdio.h>
#include <dirent.h>

main() {
char tempdir[] = "testXXXXXX";
if (!mkdtemp(tempdir)) perror("error making tempdir");
if (chdir(tempdir)) perror("error changing to tempdir");
if (!open("foothingtoremove",O_WRONLY|O_CREAT,600)) perror("error making target file");
if (mkdir("foodirtoremove",700)) perror("error making target dir");
DIR *dirp = opendir(".");
if (dirfd == NULL) perror("error opening directory");
int err = unlinkat(dirfd(dirp), "foothingtoremove", 0);
if (err < 0) perror("error removing foothingtoremove");
err = unlinkat(dirfd(dirp), "foodirtoremove", AT_REMOVEDIR);
if (err < 0) perror("error removing foodirtoremove");
chdir("..");
rmdir(tempdir);
}

Reply via email to