[common] Extract OS specific functions into common module.
This commit is contained in:
parent
d7fc0cb2b8
commit
c13f46b3a8
7 changed files with 14 additions and 14 deletions
|
@ -76,7 +76,7 @@ func archiveFile (_context *context, _pathResolved string, _pathInArchive string
|
|||
var _fileSize uint64
|
||||
var _fileTimestamp uint64
|
||||
if _stat, _error := os.Stat (_pathResolved); _error == nil {
|
||||
_fileDev, _fileInode, _fileSize, _fileTimestamp, _error = statExtract (_stat)
|
||||
_fileDev, _fileInode, _fileSize, _fileTimestamp, _error = SysStatExtract (_stat)
|
||||
if _error != nil {
|
||||
return _error
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func archiveFile (_context *context, _pathResolved string, _pathInArchive string
|
|||
}
|
||||
defer _file.Close ()
|
||||
if _stat, _error := _file.Stat (); _error == nil {
|
||||
_fileDev_0, _fileInode_0, _fileSize_0, _fileTimestamp_0, _error := statExtract (_stat)
|
||||
_fileDev_0, _fileInode_0, _fileSize_0, _fileTimestamp_0, _error := SysStatExtract (_stat)
|
||||
if _error != nil {
|
||||
return nil, _error
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ func archiveFile (_context *context, _pathResolved string, _pathInArchive string
|
|||
return nil, _error
|
||||
}
|
||||
if _stat, _error := _file.Stat (); _error == nil {
|
||||
_, _, _fileSize_0, _fileTimestamp_0, _error := statExtract (_stat)
|
||||
_, _, _fileSize_0, _fileTimestamp_0, _error := SysStatExtract (_stat)
|
||||
if _error != nil {
|
||||
return nil, _error
|
||||
}
|
||||
|
|
|
@ -918,7 +918,7 @@ func main_0 () (error) {
|
|||
if !_quiet && _isMaster {
|
||||
log.Printf ("[ii] [2c130d70] limiting memory to %d MiB;\n", _limitMemory)
|
||||
}
|
||||
if _error := setrlimit (_limitMemory); _error != nil {
|
||||
if _error := SysSetrlimit (_limitMemory); _error != nil {
|
||||
AbortError (_error, "[4da96378] failed to configure memory limit!")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//go:build freebsd || darwin
|
||||
|
||||
|
||||
package archiver
|
||||
package common
|
||||
|
||||
|
||||
import "fmt"
|
||||
|
@ -12,7 +12,7 @@ import "syscall"
|
|||
|
||||
|
||||
|
||||
func statExtract (_stat os.FileInfo) (_dev uint64, _inode uint64, _size uint64, _timestamp uint64, _error error) {
|
||||
func SysStatExtract (_stat os.FileInfo) (_dev uint64, _inode uint64, _size uint64, _timestamp uint64, _error error) {
|
||||
if _stat, _ok := _stat.Sys () .(*syscall.Stat_t); _ok {
|
||||
_dev = uint64 (_stat.Dev)
|
||||
_inode = uint64 (_stat.Ino)
|
|
@ -2,14 +2,14 @@
|
|||
//go:build freebsd
|
||||
|
||||
|
||||
package server
|
||||
package common
|
||||
|
||||
|
||||
import "syscall"
|
||||
|
||||
|
||||
|
||||
func setrlimit (_limitMemory uint) (error) {
|
||||
func SysSetrlimit (_limitMemory uint) (error) {
|
||||
{
|
||||
_limitMb := (2 * _limitMemory) + (1 * 1024)
|
||||
_limit := syscall.Rlimit {
|
|
@ -2,7 +2,7 @@
|
|||
//go:build linux || darwin
|
||||
|
||||
|
||||
package server
|
||||
package common
|
||||
|
||||
|
||||
import "syscall"
|
||||
|
@ -10,7 +10,7 @@ import "syscall"
|
|||
|
||||
|
||||
|
||||
func setrlimit (_limitMemory uint) (error) {
|
||||
func SysSetrlimit (_limitMemory uint) (error) {
|
||||
{
|
||||
_limitMb := (2 * _limitMemory) + (1 * 1024)
|
||||
_limit := syscall.Rlimit {
|
|
@ -2,7 +2,7 @@
|
|||
//go:build linux || openbsd
|
||||
|
||||
|
||||
package archiver
|
||||
package common
|
||||
|
||||
|
||||
import "fmt"
|
||||
|
@ -12,7 +12,7 @@ import "syscall"
|
|||
|
||||
|
||||
|
||||
func statExtract (_stat os.FileInfo) (_dev uint64, _inode uint64, _size uint64, _timestamp uint64, _error error) {
|
||||
func SysStatExtract (_stat os.FileInfo) (_dev uint64, _inode uint64, _size uint64, _timestamp uint64, _error error) {
|
||||
if _stat, _ok := _stat.Sys () .(*syscall.Stat_t); _ok {
|
||||
_dev = uint64 (_stat.Dev)
|
||||
_inode = uint64 (_stat.Ino)
|
|
@ -2,7 +2,7 @@
|
|||
//go:build openbsd
|
||||
|
||||
|
||||
package server
|
||||
package common
|
||||
|
||||
|
||||
import "syscall"
|
||||
|
@ -10,7 +10,7 @@ import "syscall"
|
|||
|
||||
|
||||
|
||||
func setrlimit (_limitMemory uint) (error) {
|
||||
func SysSetrlimit (_limitMemory uint) (error) {
|
||||
{
|
||||
_limitMb := _limitMemory
|
||||
_limit := syscall.Rlimit {
|
Loading…
Reference in a new issue