Renaming an in-use directory results in access-denied error in 9p-mounted windows directory
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
### Windows Version
Microsoft Windows [Version10.0.22631.5189]
### WSL Version
2.3.26.0
### Are you using WSL 1 or WSL 2?
- [x] WSL 2
- [ ] WSL 1
### Kernel Version
_No response_
### Distro Version
_No response_
### Other Software
_No response_
### Repro Steps
Compile and run the code in linux-distro, expecting the error `Permission denied`
```
// repro_2.c
#include
#include
#include
#include
#include
#include
int OPEN_DIR_FLAG = __O_DIRECTORY | O_RDONLY;
int CREATE_DIR_MDOE =
S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IROTH;
int CREATE_FILE_FLAG = O_RDWR | O_CREAT | O_EXCL | O_SYNC | __O_DIRECT;
int CREATE_FILE_MDOE = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
char test_str[100] = "1e2d22";
int main() {
// device "D" should be under-Windows device
char log_pool_tmp_path[100] = "/d/tmp/log_pool.tmp";
char log_pool_path[100] = "/d/tmp/log_pool";
mkdir(log_pool_tmp_path, CREATE_DIR_MDOE);
int tmp_dir_fd = -1;
tmp_dir_fd = open(log_pool_tmp_path, OPEN_DIR_FLAG);
int meta_fd_ = -1;
meta_fd_ =
openat(tmp_dir_fd, "meta", CREATE_FILE_FLAG, CREATE_FILE_MDOE);
pwrite(meta_fd_, test_str, 2, 0);
sleep(1);
int ret = rename(log_pool_tmp_path, log_pool_path);
if(ret == -1) {
printf("error: %d, %s\n", errno, strerror(errno));
return errno;
}
close(meta_fd_);
return 0;
}
```
### Expected Behavior
No error happens, as in linux-based distro like Ubuntu and CentOS which i have tested
### Actual Behavior
Compile and run the code in linux-distro, expecting the error `Permission denied`
### Diagnostic Logs
_No response_
Contributor guide
Research direction
Start by compiling and running repro_2.c in WSL 2 against a 9p-mounted Windows directory, then compare the rename behavior with the open directory and file descriptors shown. Done means the supplied rename succeeds without Permission denied while the file remains open; no repository file or test is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100