-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os: directory exists but os.ReadDir reports "no such file or directory" #46408
Comments
Is that directory mounted in a special way? I don't think we'll be able to determine whether this is a bug without more information though. |
What is the output of Please report this as ordinary plain text in the issue, not as a screenshot. Screenshots are very difficult to read and there is no reason to use them for ordinary text. Thanks. |
i mount cifs device in this dir,but sometime i can read ,there is a little chance of reading failure,this is my mount command: |
Does anything if you remove the trailing slash in the call to |
I try keep it, but nothing change |
That is a different directory. Also, it has a trailing slash. I'm trying to understand whether there is something about CIFS that is rejecting attempts to open a directory when the trailing slash is passed to |
When my directory does not have /, i tried to use os.ReadDir open 100000.package main
import (
"fmt"
"os"
)
var (
max = 100000
errCount int
i = 0
dir="/media/olongfen/stomach/data/ccb/A003-202104/A003-7"
)
for i < max {
if _, err := os.ReadDir(dir); err != nil {
errCount++
}
i++
}
fmt.Println("fail count: ", errCount)
// outout: fail count: 2615 When my directory does have /,i tried to use os.ReadDir open 100000.package main
import (
"fmt"
"os"
)
var (
max = 100000
errCount int
i = 0
dir = "/media/olongfen/stomach/data/ccb/A003-202104/A003-7/"
)
for i < max {
if _, err := os.ReadDir(dir); err != nil {
errCount++
}
i++
}
fmt.Println("fail count: ", errCount)
// otput: fail count: 2575 so i think nothing to do with slash |
@olongfen This is off-topic, but can you format your comment to make it easy to read? See https://github.github.com/gfm/ for how to write markdown. |
I am sorry |
Thanks. Can you run your program under
|
My used command
|
Thanks. That output is very odd. Omitting a lot of irrelevancies, I see
The Go library does not expect the Looking at the glibc code, I see this:
Perhaps we should do something similar. That said, it doesn't seem to me that this directory has been removed. This seems like a bug in the CIFS file system support, a bug that is being papered over by glibc. Specifically, I think the bug may be here: https://github.com/torvalds/linux/blob/master/fs/cifs/readdir.c#L721. Why is that code correct? Anybody know someone to ask? Thanks. |
Thanks. |
Ian, have you asked that Q on any Linux forum? @gopherbot remove WaitingForInfo |
go env
OutputI do it
What did you see instead?
The text was updated successfully, but these errors were encountered: