golang/go
Ver no GitHubos: if rename system call fails, try ioctl(FICLONE)
Open
#41.487 aberto em 18 de set. de 2020
NeedsInvestigationOS-Linuxhelp wanted
Métricas do repositório
- Stars
- (133.883 stars)
- Métricas de merge de PR
- (Nenhuma PRs mesclada em 30d)
Description
What version of Go are you using (go version)?
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
What did you do?
I am cross-compiling on Mac for Linux
Linux execution env: Linux nas 4.4.190.x86_64.1 #1 SMP Mon Oct 28 01:55:46 UTC 2019 x86_64 GNU/Linux
Build command: GOOS=linux GOARCH=amd64 go build -v
func move(src, dst string) error {
err := os.Rename(src, dst)
// cross device move
if err != nil && strings.Contains(err.Error(), "cross-device") {
if err := copy(src, dst); err != nil {
return err
}
if err := os.Remove(src); err != nil {
return err
}
}
return nil
}
What did you expect to see?
os.Rename() to succeed because the source and target are on the same filesystem.
What did you see instead?
os.Rename() returns "invalid cross-device link" and the above code falls back to copy-and-delete. If I do an mv on the command line, it completes immediately - even for multi-gigabyte files.