"errors"
"fmt"
"io/ioutil"
- "log"
"os"
"path/filepath"
+ "strconv"
+ "strings"
"syscall"
-
- "golang.org/x/sys/unix"
)
type Ctx struct {
} else {
ctx.LogPath = logPath
}
+ if strings.HasPrefix(ctx.LogPath, LogFdPrefix) {
+ ptr, err := strconv.ParseUint(
+ strings.TrimPrefix(ctx.LogPath, LogFdPrefix), 10, 64,
+ )
+ if err != nil {
+ return nil, err
+ }
+ LogFd = os.NewFile(uintptr(ptr), CfgLogEnv)
+ if LogFd == nil {
+ return nil, errors.New("can not open:" + ctx.LogPath)
+ }
+ }
if showPrgrs {
ctx.ShowPrgrs = true
}
return ctx, nil
}
-func (ctx *Ctx) IsEnoughSpace(want int64) bool {
- var s unix.Statfs_t
- if err := unix.Statfs(ctx.Spool, &s); err != nil {
- log.Fatalln("Can not stat spool:", err)
- }
- return int64(s.Bavail)*int64(s.Bsize) > want
-}
-
func (ctx *Ctx) Umask() {
if ctx.UmaskForce != nil {
syscall.Umask(*ctx.UmaskForce)