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

Method stat

pkg/sentry/kernel/msgqueue/msgqueue.go:536–565  ·  view source on GitHub ↗

stat returns a MsqidDS object filled with information about the queue. An error is returned if the user doesn't have the specified permissions.

(ctx context.Context, ats vfs.AccessTypes)

Source from the content-addressed store, hash-verified

534// stat returns a MsqidDS object filled with information about the queue. An
535// error is returned if the user doesn't have the specified permissions.
536func (q *Queue) stat(ctx context.Context, ats vfs.AccessTypes) (*linux.MsqidDS, error) {
537 q.mu.Lock()
538 defer q.mu.Unlock()
539
540 creds := auth.CredentialsFromContext(ctx)
541 if !q.obj.CheckPermissions(creds, ats) {
542 // "The caller must have read permission on the message queue."
543 return nil, linuxerr.EACCES
544 }
545
546 return &linux.MsqidDS{
547 MsgPerm: linux.IPCPerm{
548 Key: uint32(q.obj.Key),
549 UID: uint32(creds.UserNamespace.MapFromKUID(q.obj.OwnerUID)),
550 GID: uint32(creds.UserNamespace.MapFromKGID(q.obj.OwnerGID)),
551 CUID: uint32(creds.UserNamespace.MapFromKUID(q.obj.CreatorUID)),
552 CGID: uint32(creds.UserNamespace.MapFromKGID(q.obj.CreatorGID)),
553 Mode: uint16(q.obj.Mode),
554 Seq: 0, // IPC sequences not supported.
555 },
556 MsgStime: q.sendTime.TimeT(),
557 MsgRtime: q.receiveTime.TimeT(),
558 MsgCtime: q.changeTime.TimeT(),
559 MsgCbytes: q.byteCount,
560 MsgQnum: q.messageCount,
561 MsgQbytes: q.maxBytes,
562 MsgLspid: q.sendPID,
563 MsgLrpid: q.receivePID,
564 }, nil
565}
566
567// Lock implements ipc.Mechanism.Lock.
568func (q *Queue) Lock() {

Callers 2

StatMethod · 0.95
StatAnyMethod · 0.95

Calls 7

CredentialsFromContextFunction · 0.92
MapFromKUIDMethod · 0.80
MapFromKGIDMethod · 0.80
TimeTMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
CheckPermissionsMethod · 0.65

Tested by

no test coverage detected