Skip to content

Commit

Permalink
Add Self struct to guest
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelsr committed Aug 14, 2023
1 parent 7685594 commit b350460
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions guest/system/self.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package system

import (
"context"

"capnproto.org/go/capnp/v3"
api "github.com/wetware/pkg/api/process"
"github.com/wetware/pkg/cap/csp"
)

type Self struct {
Args []string
Caps []capnp.Client
CID string
PID uint32
}

func Init(ctx context.Context) (Self, error) {
var (
s Self
err error
)

b := Bootstrap[api.BootContext](ctx)
bCtx := csp.BootCtx(b)

s.Args, err = bCtx.Args(ctx)
if err != nil {
return s, err
}

s.Caps, err = bCtx.Caps(ctx)
if err != nil {
return s, err
}

s.CID, err = bCtx.Cid(ctx)
if err != nil {
return s, err
}

s.PID, err = bCtx.Pid(ctx)
return s, err
}
Binary file modified rom/internal/main.wasm
Binary file not shown.

0 comments on commit b350460

Please sign in to comment.