1
2
3
4
5
6
7
8 package ld
9
10 import (
11 "syscall"
12 "unsafe"
13 )
14
15
16
17 func fcntl(fd int, cmd int, arg int) (int, error)
18
19 func (out *OutBuf) fallocate(size uint64) error {
20 stat, err := out.f.Stat()
21 if err != nil {
22 return err
23 }
24
25
26
27 cursize := uint64(stat.Sys().(*syscall.Stat_t).Blocks * 512)
28 if size <= cursize {
29 return nil
30 }
31
32 store := &syscall.Fstore_t{
33 Flags: syscall.F_ALLOCATEALL,
34 Posmode: syscall.F_PEOFPOSMODE,
35 Offset: 0,
36 Length: int64(size - cursize),
37 }
38
39 _, err = fcntl(int(out.f.Fd()), syscall.F_PREALLOCATE, int(uintptr(unsafe.Pointer(store))))
40 return err
41 }
42
43 func (out *OutBuf) purgeSignatureCache() {
44
45
46
47
48 syscall.Syscall(syscall.SYS_MSYNC, uintptr(unsafe.Pointer(&out.buf[0])), uintptr(len(out.buf)), syscall.MS_INVALIDATE)
49
50 }
51
View as plain text