mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: size restricted tmpfs /tmp and read-only / support (#1012)
* fn: size restricted tmpfs /tmp and read-only / support *) read-only Root Fs Support *) removed CPUShares from docker API. This was unused. *) docker.Prepare() refactoring *) added docker.configureTmpFs() for size limited tmpfs on /tmp *) tmpfs size support in routes and resource tracker *) fix fn-test-utils to handle sparse files better in create file * test typo fix
This commit is contained in:
@@ -477,9 +477,27 @@ func createFile(name string, size int) error {
|
||||
}
|
||||
|
||||
if size > 0 {
|
||||
err := f.Truncate(int64(size))
|
||||
if err != nil {
|
||||
return err
|
||||
// create a 1K block (keep this buffer small to keep
|
||||
// memory usage small)
|
||||
chunk := make([]byte, 1024)
|
||||
for i := 0; i < 1024; i++ {
|
||||
chunk[i] = byte(i)
|
||||
}
|
||||
|
||||
for size > 0 {
|
||||
dlen := size
|
||||
if dlen > 1024 {
|
||||
dlen = 1024
|
||||
}
|
||||
|
||||
_, err := f.Write(chunk[:dlen])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// slightly modify the chunk to avoid any sparse file possibility
|
||||
chunk[0]++
|
||||
size = size - dlen
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user