closedir(d);
if (fstatat(rootfd, path, &st, AT_SYMLINK_NOFOLLOW) != 0)
return;
unlinkat(rootfd, path, S_ISDIR(st.st_mode) ? AT_REMOVEDIR : 0);
if (S_ISLNK(st.st_mode))
unlinkat(rootfd, path, 0);
else if (st.st_uid == uid)
unlinkat(rootfd, path, AT_REMOVEDIR);
}