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