-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gather all syscall use in the osutil helper
Makes it easier to add windows portability Signed-off-by: Anders F Björklund <[email protected]>
- Loading branch information
1 parent
6410674
commit fa6eff1
Showing
6 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,32 @@ | ||
package osutil | ||
|
||
import ( | ||
"io/fs" | ||
"syscall" | ||
) | ||
|
||
// UnixPathMax is the value of UNIX_PATH_MAX. | ||
const UnixPathMax = 108 | ||
|
||
// Stat is a selection of syscall.Stat_t | ||
type Stat struct { | ||
Uid uint32 | ||
Gid uint32 | ||
} | ||
|
||
func SysStat(fi fs.FileInfo) (Stat, bool) { | ||
stat, ok := fi.Sys().(*syscall.Stat_t) | ||
return Stat{Uid: stat.Uid, Gid: stat.Gid}, ok | ||
} | ||
|
||
// SigInt is the value of SIGINT. | ||
const SigInt = Signal(syscall.SIGINT) | ||
|
||
// SigKill is the value of SIGKILL. | ||
const SigKill = Signal(syscall.SIGKILL) | ||
|
||
type Signal syscall.Signal | ||
|
||
func SysKill(pid int, sig Signal) error { | ||
return syscall.Kill(pid, syscall.Signal(sig)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,35 @@ | ||
//go:build !linux | ||
// +build !linux | ||
//go:build !linux && !windows | ||
// +build !linux,!windows | ||
|
||
package osutil | ||
|
||
import ( | ||
"io/fs" | ||
"syscall" | ||
) | ||
|
||
// UnixPathMax is the value of UNIX_PATH_MAX. | ||
const UnixPathMax = 104 | ||
|
||
// Stat is a selection of syscall.Stat_t | ||
type Stat struct { | ||
Uid uint32 | ||
Gid uint32 | ||
} | ||
|
||
func SysStat(fi fs.FileInfo) (Stat, bool) { | ||
stat, ok := fi.Sys().(*syscall.Stat_t) | ||
return Stat{Uid: stat.Uid, Gid: stat.Gid}, ok | ||
} | ||
|
||
// SigInt is the value of SIGINT. | ||
const SigInt = Signal(syscall.SIGINT) | ||
|
||
// SigKill is the value of SIGKILL. | ||
const SigKill = Signal(syscall.SIGKILL) | ||
|
||
type Signal syscall.Signal | ||
|
||
func SysKill(pid int, sig Signal) error { | ||
return syscall.Kill(pid, syscall.Signal(sig)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package osutil | ||
|
||
import ( | ||
"fmt" | ||
"io/fs" | ||
) | ||
|
||
// UnixPathMax is the value of UNIX_PATH_MAX. | ||
const UnixPathMax = 108 | ||
|
||
// Stat is a selection of syscall.Stat_t | ||
type Stat struct { | ||
Uid uint32 | ||
Gid uint32 | ||
} | ||
|
||
func SysStat(fi fs.FileInfo) (Stat, bool) { | ||
return Stat{Uid: 0, Gid: 0}, false | ||
} | ||
|
||
// SigInt is the value of SIGINT. | ||
const SigInt = Signal(2) | ||
|
||
// SigKill is the value of SIGKILL. | ||
const SigKill = Signal(9) | ||
|
||
type Signal int | ||
|
||
func SysKill(pid int, sig Signal) error { | ||
return fmt.Errorf("unimplemented") | ||
} |