From f413e4b11794cd71cc3b2b64c8f6861f5394a3f1 Mon Sep 17 00:00:00 2001 From: Fabricio Voznika Date: Thu, 11 Oct 2018 11:55:45 -0700 Subject: Add bare bones unsupported syscall logging This change introduces a new flags to create/run called --user-log. Logs to this files are visible to users and are meant to help debugging problems with their images and containers. For now only unsupported syscalls are sent to this log, and only minimum support was added. We can build more infrastructure around it as needed. PiperOrigin-RevId: 216735977 Change-Id: I54427ca194604991c407d49943ab3680470de2d0 --- runsc/container/test_app.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'runsc/container/test_app.go') diff --git a/runsc/container/test_app.go b/runsc/container/test_app.go index f69cfdf83..9e4b5326d 100644 --- a/runsc/container/test_app.go +++ b/runsc/container/test_app.go @@ -24,6 +24,7 @@ import ( "os" "os/exec" "strconv" + sys "syscall" "time" "flag" @@ -38,6 +39,7 @@ func main() { subcommands.Register(new(taskTree), "") subcommands.Register(new(forkBomb), "") subcommands.Register(new(reaper), "") + subcommands.Register(new(syscall), "") flag.Parse() @@ -241,3 +243,37 @@ func (c *reaper) Execute(ctx context.Context, f *flag.FlagSet, args ...interface defer stop() select {} } + +type syscall struct { + sysno uint64 +} + +// Name implements subcommands.Command. +func (*syscall) Name() string { + return "syscall" +} + +// Synopsis implements subcommands.Command. +func (*syscall) Synopsis() string { + return "syscall makes a syscall" +} + +// Usage implements subcommands.Command. +func (*syscall) Usage() string { + return "syscall " +} + +// SetFlags implements subcommands.Command. +func (s *syscall) SetFlags(f *flag.FlagSet) { + f.Uint64Var(&s.sysno, "syscall", 0, "syscall to call") +} + +// Execute implements subcommands.Command. +func (s *syscall) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus { + if _, _, errno := sys.Syscall(uintptr(s.sysno), 0, 0, 0); errno != 0 { + fmt.Printf("syscall(%d, 0, 0...) failed: %v\n", s.sysno, errno) + } else { + fmt.Printf("syscall(%d, 0, 0...) success\n", s.sysno) + } + return subcommands.ExitSuccess +} -- cgit v1.2.3