-
-
Notifications
You must be signed in to change notification settings - Fork 542
fchmod fails on open file descriptor after file is unlinked #1112
Copy link
Copy link
Closed
Milestone
Description
MacOS version: 15.6.1
MacFUSE version: 5.0.6
Repro steps:
- Open fd
- unlink
- fchmod
Expected: the fchmod should succeed
Actual: the fchmod fails with "No such file or directory"
Script to reproduce:
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
int main(int argc, char **argv) {
if (argc < 2) { fprintf(stderr, "Usage: %s MOUNTPOINT\n", argv[0]); return 1; }
char path1[512];
snprintf(path1, sizeof(path1), "%s/test1.txt", argv[1]);
// open then unlink, chmod path vs fchmod fd
int fd = open(path1, O_CREAT|O_WRONLY|O_TRUNC);
if (fd < 0) { perror("open2"); return 1; }
unlink(path1);
if (chmod(path1, 0600) == -1) {
printf("chmod(%s) failed as expected: %s\n", path1, strerror(errno));
}
else {
printf("chmod(%s) succeeded WHICH IS BAD\n", path1);
}
if (fchmod(fd, 0600) == 0) {
printf("fchmod(fd) succeeded on unlinked file\n");
}
else {
printf("fchmod(fd) failed, WHICH IS BAD: %s\n", strerror(errno));
}
close(fd);
return 0;
}
Output on the demo LoopbackFS-C:
chmod(test1.txt) failed as expected: No such file or directory
fchmod(fd) failed, WHICH IS BAD: No such file or directory
Output on local drive:
chmod(test1.txt) failed as expected: No such file or directory
fchmod(fd) succeeded on unlinked file
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels