From cbb99336cee7d37f4050875a95946ca88b7ac690 Mon Sep 17 00:00:00 2001 From: Chong Cai Date: Wed, 4 Aug 2021 16:41:27 -0700 Subject: Add Fs controls Add Fs controls and implement "cat" command. PiperOrigin-RevId: 388812540 --- runsc/sandbox/sandbox.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'runsc/sandbox') diff --git a/runsc/sandbox/sandbox.go b/runsc/sandbox/sandbox.go index 822da8c5e..b15572a98 100644 --- a/runsc/sandbox/sandbox.go +++ b/runsc/sandbox/sandbox.go @@ -1002,6 +1002,24 @@ func (s *Sandbox) Resume(cid string) error { return nil } +// Cat sends the cat call for a container in the sandbox. +func (s *Sandbox) Cat(cid string, files []string, out *os.File) error { + log.Debugf("Cat sandbox %q", s.ID) + conn, err := s.sandboxConnect() + if err != nil { + return err + } + defer conn.Close() + + if err := conn.Call(boot.FsCat, &control.CatOpts{ + Files: files, + FilePayload: urpc.FilePayload{Files: []*os.File{out}}, + }, nil); err != nil { + return fmt.Errorf("Cat container %q: %v", cid, err) + } + return nil +} + // IsRunning returns true if the sandbox or gofer process is running. func (s *Sandbox) IsRunning() bool { if s.Pid != 0 { -- cgit v1.2.3