Skip to content

Commit

Permalink
add APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
fearful-symmetry committed Dec 5, 2023
1 parent dfe8b5f commit 768646a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions system.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func Host() (types.Host, error) {
return provider.Host()
}

// HostFS is the same as Host, but allows for a custom root hostfs mountpoint
// a custom filesystem root is only supported on linux, and this will fallback to the default provider on other platforms
func HostFS(hostfs string) (types.Host, error) {
provider := registry.GetHostProviderWithRoot(hostfs)
if provider == nil {
Expand All @@ -72,6 +74,16 @@ func Process(pid int) (types.Process, error) {
return provider.Process(pid)
}

// ProcessFS is the same as Process, but allows for a custom root hostfs mountpoint
// a custom filesystem root is only supported on linux, and this will fallback to the default provider on other platforms
func ProcessFS(hostfs string, pid int) (types.Process, error) {
provider := registry.GetProcessProviderWithRoot(hostfs)
if provider == nil {
return nil, types.ErrNotImplemented
}
return provider.Process(pid)
}

// Processes return a list of all processes. If process information collection
// is not implemented for this platform then types.ErrNotImplemented is
// returned.
Expand All @@ -83,6 +95,16 @@ func Processes() ([]types.Process, error) {
return provider.Processes()
}

// ProcessesFS is the same as Processes, but allows for a custom root hostfs mountpoint
// a custom filesystem root is only supported on linux, and this will fallback to the default provider on other platforms
func ProcessesFS(hostfs string) ([]types.Process, error) {
provider := registry.GetProcessProviderWithRoot(hostfs)
if provider == nil {
return nil, types.ErrNotImplemented
}
return provider.Processes()
}

// Self return a types.Process object representing this process. If process
// information collection is not implemented for this platform then
// types.ErrNotImplemented is returned.
Expand Down

0 comments on commit 768646a

Please sign in to comment.