MCPcopy
hub / github.com/google/gvisor / Readlink

Method Readlink

pkg/sentry/fsimpl/fuse/inode.go:758–779  ·  view source on GitHub ↗

Readlink implements kernfs.Inode.Readlink.

(ctx context.Context, mnt *vfs.Mount)

Source from the content-addressed store, hash-verified

756
757// Readlink implements kernfs.Inode.Readlink.
758func (i *inode) Readlink(ctx context.Context, mnt *vfs.Mount) (string, error) {
759 i.attrMu.Lock()
760 defer i.attrMu.Unlock()
761 if i.filemode().FileType()&linux.S_IFLNK == 0 {
762 return "", linuxerr.EINVAL
763 }
764 if len(i.link) == 0 {
765 req := i.fs.conn.NewRequest(auth.CredentialsFromContext(ctx), pidFromContext(ctx), i.nodeID, linux.FUSE_READLINK, &linux.FUSEEmptyIn{})
766 res, err := i.fs.conn.Call(ctx, req)
767 if err != nil {
768 return "", err
769 }
770 if err := res.Error(); err != nil {
771 return "", err
772 }
773 i.link = string(res.data[res.hdr.SizeBytes():])
774 if !mnt.Options().ReadOnly {
775 i.attrTime = ktime.ZeroTime
776 }
777 }
778 return i.link, nil
779}
780
781// Stat implements kernfs.Inode.Stat.
782func (i *inode) Stat(ctx context.Context, fs *vfs.Filesystem, opts vfs.StatOptions) (linux.Statx, error) {

Callers 1

GetlinkMethod · 0.95

Calls 11

filemodeMethod · 0.95
CredentialsFromContextFunction · 0.92
pidFromContextFunction · 0.85
NewRequestMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
SizeBytesMethod · 0.65
FileTypeMethod · 0.45
CallMethod · 0.45
ErrorMethod · 0.45
OptionsMethod · 0.45

Tested by

no test coverage detected