mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix bugs in vfs2 to make symlink tests pass.
- Return ENOENT if target path is empty. - Make sure open(2) with O_CREAT|O_EXCL returns EEXIST when necessary. - Correctly update atime in tmpfs using touchATime(). Updates #2923. PiperOrigin-RevId: 317382655
This commit is contained in:
@@ -79,7 +79,7 @@ afterSymlink:
|
||||
}
|
||||
if symlink, ok := child.inode.impl.(*symlink); ok && rp.ShouldFollowSymlink() {
|
||||
// Symlink traversal updates access time.
|
||||
atomic.StoreInt64(&d.inode.atime, d.inode.fs.clock.Now().Nanoseconds())
|
||||
child.inode.touchAtime(rp.Mount())
|
||||
if err := rp.HandleSymlink(symlink.target); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -372,6 +372,9 @@ afterTrailingSymlink:
|
||||
parentDir.inode.touchCMtime()
|
||||
return fd, nil
|
||||
}
|
||||
if mustCreate {
|
||||
return nil, syserror.EEXIST
|
||||
}
|
||||
// Is the file mounted over?
|
||||
if err := rp.CheckMount(&child.vfsd); err != nil {
|
||||
return nil, err
|
||||
@@ -379,7 +382,7 @@ afterTrailingSymlink:
|
||||
// Do we need to resolve a trailing symlink?
|
||||
if symlink, ok := child.inode.impl.(*symlink); ok && rp.ShouldFollowSymlink() {
|
||||
// Symlink traversal updates access time.
|
||||
atomic.StoreInt64(&child.inode.atime, child.inode.fs.clock.Now().Nanoseconds())
|
||||
child.inode.touchAtime(rp.Mount())
|
||||
if err := rp.HandleSymlink(symlink.target); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -313,6 +313,9 @@ func symlinkat(t *kernel.Task, targetAddr usermem.Addr, newdirfd int32, linkpath
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(target) == 0 {
|
||||
return syserror.ENOENT
|
||||
}
|
||||
linkpath, err := copyInPath(t, linkpathAddr)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user