summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/proc
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/fs/proc')
-rw-r--r--pkg/sentry/fs/proc/BUILD72
-rw-r--r--pkg/sentry/fs/proc/README.md336
-rw-r--r--pkg/sentry/fs/proc/device/BUILD10
-rw-r--r--pkg/sentry/fs/proc/device/device_state_autogen.go3
-rw-r--r--pkg/sentry/fs/proc/net_test.go74
-rw-r--r--pkg/sentry/fs/proc/proc_state_autogen.go1435
-rw-r--r--pkg/sentry/fs/proc/seqfile/BUILD35
-rw-r--r--pkg/sentry/fs/proc/seqfile/seqfile_state_autogen.go100
-rw-r--r--pkg/sentry/fs/proc/seqfile/seqfile_test.go279
-rw-r--r--pkg/sentry/fs/proc/sys_net_test.go125
10 files changed, 1538 insertions, 931 deletions
diff --git a/pkg/sentry/fs/proc/BUILD b/pkg/sentry/fs/proc/BUILD
deleted file mode 100644
index 77c2c5c0e..000000000
--- a/pkg/sentry/fs/proc/BUILD
+++ /dev/null
@@ -1,72 +0,0 @@
-load("//tools:defs.bzl", "go_library", "go_test")
-
-package(licenses = ["notice"])
-
-go_library(
- name = "proc",
- srcs = [
- "cgroup.go",
- "cpuinfo.go",
- "exec_args.go",
- "fds.go",
- "filesystems.go",
- "fs.go",
- "inode.go",
- "loadavg.go",
- "meminfo.go",
- "mounts.go",
- "net.go",
- "proc.go",
- "stat.go",
- "sys.go",
- "sys_net.go",
- "sys_net_state.go",
- "task.go",
- "uid_gid_map.go",
- "uptime.go",
- "version.go",
- ],
- visibility = ["//pkg/sentry:internal"],
- deps = [
- "//pkg/abi/linux",
- "//pkg/context",
- "//pkg/log",
- "//pkg/sentry/fs",
- "//pkg/sentry/fs/fsutil",
- "//pkg/sentry/fs/proc/device",
- "//pkg/sentry/fs/proc/seqfile",
- "//pkg/sentry/fs/ramfs",
- "//pkg/sentry/fsbridge",
- "//pkg/sentry/inet",
- "//pkg/sentry/kernel",
- "//pkg/sentry/kernel/auth",
- "//pkg/sentry/kernel/time",
- "//pkg/sentry/limits",
- "//pkg/sentry/mm",
- "//pkg/sentry/socket",
- "//pkg/sentry/socket/unix",
- "//pkg/sentry/socket/unix/transport",
- "//pkg/sentry/usage",
- "//pkg/sync",
- "//pkg/syserror",
- "//pkg/tcpip/header",
- "//pkg/usermem",
- "//pkg/waiter",
- ],
-)
-
-go_test(
- name = "proc_test",
- size = "small",
- srcs = [
- "net_test.go",
- "sys_net_test.go",
- ],
- library = ":proc",
- deps = [
- "//pkg/abi/linux",
- "//pkg/context",
- "//pkg/sentry/inet",
- "//pkg/usermem",
- ],
-)
diff --git a/pkg/sentry/fs/proc/README.md b/pkg/sentry/fs/proc/README.md
deleted file mode 100644
index 6667a0916..000000000
--- a/pkg/sentry/fs/proc/README.md
+++ /dev/null
@@ -1,336 +0,0 @@
-This document tracks what is implemented in procfs. Refer to
-Documentation/filesystems/proc.txt in the Linux project for information about
-procfs generally.
-
-**NOTE**: This document is not guaranteed to be up to date. If you find an
-inconsistency, please file a bug.
-
-[TOC]
-
-## Kernel data
-
-The following files are implemented:
-
-<!-- mdformat off(don't wrap the table) -->
-
-| File /proc/ | Content |
-| :------------------------ | :---------------------------------------------------- |
-| [cpuinfo](#cpuinfo) | Info about the CPU |
-| [filesystems](#filesystems) | Supported filesystems |
-| [loadavg](#loadavg) | Load average of last 1, 5 & 15 minutes |
-| [meminfo](#meminfo) | Overall memory info |
-| [stat](#stat) | Overall kernel statistics |
-| [sys](#sys) | Change parameters within the kernel |
-| [uptime](#uptime) | Wall clock since boot, combined idle time of all cpus |
-| [version](#version) | Kernel version |
-
-<!-- mdformat on -->
-
-### cpuinfo
-
-```bash
-$ cat /proc/cpuinfo
-processor : 0
-vendor_id : GenuineIntel
-cpu family : 6
-model : 45
-model name : unknown
-stepping : unknown
-cpu MHz : 1234.588
-fpu : yes
-fpu_exception : yes
-cpuid level : 13
-wp : yes
-flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx xsaveopt
-bogomips : 1234.59
-clflush size : 64
-cache_alignment : 64
-address sizes : 46 bits physical, 48 bits virtual
-power management:
-
-...
-```
-
-Notable divergences:
-
-Field name | Notes
-:--------------- | :---------------------------------------
-model name | Always unknown
-stepping | Always unknown
-fpu | Always yes
-fpu_exception | Always yes
-wp | Always yes
-bogomips | Bogus value (matches cpu MHz)
-clflush size | Always 64
-cache_alignment | Always 64
-address sizes | Always 46 bits physical, 48 bits virtual
-power management | Always blank
-
-Otherwise fields are derived from the sentry configuration.
-
-### filesystems
-
-```bash
-$ cat /proc/filesystems
-nodev 9p
-nodev devpts
-nodev devtmpfs
-nodev proc
-nodev sysfs
-nodev tmpfs
-```
-
-### loadavg
-
-```bash
-$ cat /proc/loadavg
-0.00 0.00 0.00 0/0 0
-```
-
-Column | Notes
-:------------------------------------ | :----------
-CPU.IO utilization in last 1 minute | Always zero
-CPU.IO utilization in last 5 minutes | Always zero
-CPU.IO utilization in last 10 minutes | Always zero
-Num currently running processes | Always zero
-Total num processes | Always zero
-
-TODO(b/62345059): Populate the columns with accurate statistics.
-
-### meminfo
-
-```bash
-$ cat /proc/meminfo
-MemTotal: 2097152 kB
-MemFree: 2083540 kB
-MemAvailable: 2083540 kB
-Buffers: 0 kB
-Cached: 4428 kB
-SwapCache: 0 kB
-Active: 10812 kB
-Inactive: 2216 kB
-Active(anon): 8600 kB
-Inactive(anon): 0 kB
-Active(file): 2212 kB
-Inactive(file): 2216 kB
-Unevictable: 0 kB
-Mlocked: 0 kB
-SwapTotal: 0 kB
-SwapFree: 0 kB
-Dirty: 0 kB
-Writeback: 0 kB
-AnonPages: 8600 kB
-Mapped: 4428 kB
-Shmem: 0 kB
-
-```
-
-Notable divergences:
-
-Field name | Notes
-:---------------- | :-----------------------------------------------------
-Buffers | Always zero, no block devices
-SwapCache | Always zero, no swap
-Inactive(anon) | Always zero, see SwapCache
-Unevictable | Always zero TODO(b/31823263)
-Mlocked | Always zero TODO(b/31823263)
-SwapTotal | Always zero, no swap
-SwapFree | Always zero, no swap
-Dirty | Always zero TODO(b/31823263)
-Writeback | Always zero TODO(b/31823263)
-MemAvailable | Uses the same value as MemFree since there is no swap.
-Slab | Missing
-SReclaimable | Missing
-SUnreclaim | Missing
-KernelStack | Missing
-PageTables | Missing
-NFS_Unstable | Missing
-Bounce | Missing
-WritebackTmp | Missing
-CommitLimit | Missing
-Committed_AS | Missing
-VmallocTotal | Missing
-VmallocUsed | Missing
-VmallocChunk | Missing
-HardwareCorrupted | Missing
-AnonHugePages | Missing
-ShmemHugePages | Missing
-ShmemPmdMapped | Missing
-HugePages_Total | Missing
-HugePages_Free | Missing
-HugePages_Rsvd | Missing
-HugePages_Surp | Missing
-Hugepagesize | Missing
-DirectMap4k | Missing
-DirectMap2M | Missing
-DirectMap1G | Missing
-
-### stat
-
-```bash
-$ cat /proc/stat
-cpu 0 0 0 0 0 0 0 0 0 0
-cpu0 0 0 0 0 0 0 0 0 0 0
-cpu1 0 0 0 0 0 0 0 0 0 0
-cpu2 0 0 0 0 0 0 0 0 0 0
-cpu3 0 0 0 0 0 0 0 0 0 0
-cpu4 0 0 0 0 0 0 0 0 0 0
-cpu5 0 0 0 0 0 0 0 0 0 0
-cpu6 0 0 0 0 0 0 0 0 0 0
-cpu7 0 0 0 0 0 0 0 0 0 0
-intr 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-ctxt 0
-btime 1504040968
-processes 0
-procs_running 0
-procs_blokkcked 0
-softirq 0 0 0 0 0 0 0 0 0 0 0
-```
-
-All fields except for `btime` are always zero.
-
-TODO(b/37226836): Populate with accurate fields.
-
-### sys
-
-```bash
-$ ls /proc/sys
-kernel vm
-```
-
-Directory | Notes
-:-------- | :----------------------------
-abi | Missing
-debug | Missing
-dev | Missing
-fs | Missing
-kernel | Contains hostname (only)
-net | Missing
-user | Missing
-vm | Contains mmap_min_addr (only)
-
-### uptime
-
-```bash
-$ cat /proc/uptime
-3204.62 0.00
-```
-
-Column | Notes
-:------------------------------- | :----------------------------
-Total num seconds system running | Time since procfs was mounted
-Number of seconds idle | Always zero
-
-### version
-
-```bash
-$ cat /proc/version
-Linux version 4.4 #1 SMP Sun Jan 10 15:06:54 PST 2016
-```
-
-## Process-specific data
-
-The following files are implemented:
-
-File /proc/PID | Content
-:---------------------- | :---------------------------------------------------
-[auxv](#auxv) | Copy of auxiliary vector for the process
-[cmdline](#cmdline) | Command line arguments
-[comm](#comm) | Command name associated with the process
-[environ](#environ) | Process environment
-[exe](#exe) | Symlink to the process's executable
-[fd](#fd) | Directory containing links to open file descriptors
-[fdinfo](#fdinfo) | Information associated with open file descriptors
-[gid_map](#gid_map) | Mappings for group IDs inside the user namespace
-[io](#io) | IO statistics
-[maps](#maps) | Memory mappings (anon, executables, library files)
-[mounts](#mounts) | Mounted filesystems
-[mountinfo](#mountinfo) | Information about mounts
-[ns](#ns) | Directory containing info about supported namespaces
-[stat](#stat) | Process statistics
-[statm](#statm) | Process memory statistics
-[status](#status) | Process status in human readable format
-[task](#task) | Directory containing info about running threads
-[uid_map](#uid_map) | Mappings for user IDs inside the user namespace
-
-### auxv
-
-TODO
-
-### cmdline
-
-TODO
-
-### comm
-
-TODO
-
-### environment
-
-TODO
-
-### exe
-
-TODO
-
-### fd
-
-TODO
-
-### fdinfo
-
-TODO
-
-### gid_map
-
-TODO
-
-### io
-
-Only has data for rchar, wchar, syscr, and syscw.
-
-TODO: add more detail.
-
-### maps
-
-TODO
-
-### mounts
-
-TODO
-
-### mountinfo
-
-TODO
-
-### ns
-
-TODO
-
-### stat
-
-Only has data for pid, comm, state, ppid, utime, stime, cutime, cstime,
-num_threads, and exit_signal.
-
-TODO: add more detail.
-
-### statm
-
-Only has data for vss and rss.
-
-TODO: add more detail.
-
-### status
-
-Contains data for Name, State, Tgid, Pid, Ppid, TracerPid, FDSize, VmSize,
-VmRSS, Threads, CapInh, CapPrm, CapEff, CapBnd, Seccomp.
-
-TODO: add more detail.
-
-### task
-
-TODO
-
-### uid_map
-
-TODO
diff --git a/pkg/sentry/fs/proc/device/BUILD b/pkg/sentry/fs/proc/device/BUILD
deleted file mode 100644
index 52c9aa93d..000000000
--- a/pkg/sentry/fs/proc/device/BUILD
+++ /dev/null
@@ -1,10 +0,0 @@
-load("//tools:defs.bzl", "go_library")
-
-package(licenses = ["notice"])
-
-go_library(
- name = "device",
- srcs = ["device.go"],
- visibility = ["//pkg/sentry:internal"],
- deps = ["//pkg/sentry/device"],
-)
diff --git a/pkg/sentry/fs/proc/device/device_state_autogen.go b/pkg/sentry/fs/proc/device/device_state_autogen.go
new file mode 100644
index 000000000..4a5e3cc88
--- /dev/null
+++ b/pkg/sentry/fs/proc/device/device_state_autogen.go
@@ -0,0 +1,3 @@
+// automatically generated by stateify.
+
+package device
diff --git a/pkg/sentry/fs/proc/net_test.go b/pkg/sentry/fs/proc/net_test.go
deleted file mode 100644
index f18681405..000000000
--- a/pkg/sentry/fs/proc/net_test.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2018 The gVisor Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package proc
-
-import (
- "reflect"
- "testing"
-
- "gvisor.dev/gvisor/pkg/abi/linux"
- "gvisor.dev/gvisor/pkg/sentry/inet"
-)
-
-func newIPv6TestStack() *inet.TestStack {
- s := inet.NewTestStack()
- s.SupportsIPv6Flag = true
- return s
-}
-
-func TestIfinet6NoAddresses(t *testing.T) {
- n := &ifinet6{s: newIPv6TestStack()}
- if got := n.contents(); got != nil {
- t.Errorf("Got n.contents() = %v, want = %v", got, nil)
- }
-}
-
-func TestIfinet6(t *testing.T) {
- s := newIPv6TestStack()
- s.InterfacesMap[1] = inet.Interface{Name: "eth0"}
- s.InterfaceAddrsMap[1] = []inet.InterfaceAddr{
- {
- Family: linux.AF_INET6,
- PrefixLen: 128,
- Addr: []byte("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"),
- },
- }
- s.InterfacesMap[2] = inet.Interface{Name: "eth1"}
- s.InterfaceAddrsMap[2] = []inet.InterfaceAddr{
- {
- Family: linux.AF_INET6,
- PrefixLen: 128,
- Addr: []byte("\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"),
- },
- }
- want := map[string]struct{}{
- "000102030405060708090a0b0c0d0e0f 01 80 00 00 eth0\n": {},
- "101112131415161718191a1b1c1d1e1f 02 80 00 00 eth1\n": {},
- }
-
- n := &ifinet6{s: s}
- contents := n.contents()
- if len(contents) != len(want) {
- t.Errorf("Got len(n.contents()) = %d, want = %d", len(contents), len(want))
- }
- got := map[string]struct{}{}
- for _, l := range contents {
- got[l] = struct{}{}
- }
-
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Got n.contents() = %v, want = %v", got, want)
- }
-}
diff --git a/pkg/sentry/fs/proc/proc_state_autogen.go b/pkg/sentry/fs/proc/proc_state_autogen.go
new file mode 100644
index 000000000..87c979909
--- /dev/null
+++ b/pkg/sentry/fs/proc/proc_state_autogen.go
@@ -0,0 +1,1435 @@
+// automatically generated by stateify.
+
+package proc
+
+import (
+ "gvisor.dev/gvisor/pkg/state"
+)
+
+func (x *execArgInode) StateTypeName() string {
+ return "pkg/sentry/fs/proc.execArgInode"
+}
+
+func (x *execArgInode) StateFields() []string {
+ return []string{
+ "SimpleFileInode",
+ "arg",
+ "t",
+ }
+}
+
+func (x *execArgInode) beforeSave() {}
+
+func (x *execArgInode) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.SimpleFileInode)
+ m.Save(1, &x.arg)
+ m.Save(2, &x.t)
+}
+
+func (x *execArgInode) afterLoad() {}
+
+func (x *execArgInode) StateLoad(m state.Source) {
+ m.Load(0, &x.SimpleFileInode)
+ m.Load(1, &x.arg)
+ m.Load(2, &x.t)
+}
+
+func (x *execArgFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.execArgFile"
+}
+
+func (x *execArgFile) StateFields() []string {
+ return []string{
+ "arg",
+ "t",
+ }
+}
+
+func (x *execArgFile) beforeSave() {}
+
+func (x *execArgFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.arg)
+ m.Save(1, &x.t)
+}
+
+func (x *execArgFile) afterLoad() {}
+
+func (x *execArgFile) StateLoad(m state.Source) {
+ m.Load(0, &x.arg)
+ m.Load(1, &x.t)
+}
+
+func (x *fdDir) StateTypeName() string {
+ return "pkg/sentry/fs/proc.fdDir"
+}
+
+func (x *fdDir) StateFields() []string {
+ return []string{
+ "Dir",
+ "t",
+ }
+}
+
+func (x *fdDir) beforeSave() {}
+
+func (x *fdDir) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.Dir)
+ m.Save(1, &x.t)
+}
+
+func (x *fdDir) afterLoad() {}
+
+func (x *fdDir) StateLoad(m state.Source) {
+ m.Load(0, &x.Dir)
+ m.Load(1, &x.t)
+}
+
+func (x *fdDirFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.fdDirFile"
+}
+
+func (x *fdDirFile) StateFields() []string {
+ return []string{
+ "isInfoFile",
+ "t",
+ }
+}
+
+func (x *fdDirFile) beforeSave() {}
+
+func (x *fdDirFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.isInfoFile)
+ m.Save(1, &x.t)
+}
+
+func (x *fdDirFile) afterLoad() {}
+
+func (x *fdDirFile) StateLoad(m state.Source) {
+ m.Load(0, &x.isInfoFile)
+ m.Load(1, &x.t)
+}
+
+func (x *fdInfoDir) StateTypeName() string {
+ return "pkg/sentry/fs/proc.fdInfoDir"
+}
+
+func (x *fdInfoDir) StateFields() []string {
+ return []string{
+ "Dir",
+ "t",
+ }
+}
+
+func (x *fdInfoDir) beforeSave() {}
+
+func (x *fdInfoDir) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.Dir)
+ m.Save(1, &x.t)
+}
+
+func (x *fdInfoDir) afterLoad() {}
+
+func (x *fdInfoDir) StateLoad(m state.Source) {
+ m.Load(0, &x.Dir)
+ m.Load(1, &x.t)
+}
+
+func (x *filesystemsData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.filesystemsData"
+}
+
+func (x *filesystemsData) StateFields() []string {
+ return []string{}
+}
+
+func (x *filesystemsData) beforeSave() {}
+
+func (x *filesystemsData) StateSave(m state.Sink) {
+ x.beforeSave()
+}
+
+func (x *filesystemsData) afterLoad() {}
+
+func (x *filesystemsData) StateLoad(m state.Source) {
+}
+
+func (x *filesystem) StateTypeName() string {
+ return "pkg/sentry/fs/proc.filesystem"
+}
+
+func (x *filesystem) StateFields() []string {
+ return []string{}
+}
+
+func (x *filesystem) beforeSave() {}
+
+func (x *filesystem) StateSave(m state.Sink) {
+ x.beforeSave()
+}
+
+func (x *filesystem) afterLoad() {}
+
+func (x *filesystem) StateLoad(m state.Source) {
+}
+
+func (x *taskOwnedInodeOps) StateTypeName() string {
+ return "pkg/sentry/fs/proc.taskOwnedInodeOps"
+}
+
+func (x *taskOwnedInodeOps) StateFields() []string {
+ return []string{
+ "InodeOperations",
+ "t",
+ }
+}
+
+func (x *taskOwnedInodeOps) beforeSave() {}
+
+func (x *taskOwnedInodeOps) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.InodeOperations)
+ m.Save(1, &x.t)
+}
+
+func (x *taskOwnedInodeOps) afterLoad() {}
+
+func (x *taskOwnedInodeOps) StateLoad(m state.Source) {
+ m.Load(0, &x.InodeOperations)
+ m.Load(1, &x.t)
+}
+
+func (x *staticFileInodeOps) StateTypeName() string {
+ return "pkg/sentry/fs/proc.staticFileInodeOps"
+}
+
+func (x *staticFileInodeOps) StateFields() []string {
+ return []string{
+ "InodeSimpleAttributes",
+ "InodeStaticFileGetter",
+ }
+}
+
+func (x *staticFileInodeOps) beforeSave() {}
+
+func (x *staticFileInodeOps) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.InodeSimpleAttributes)
+ m.Save(1, &x.InodeStaticFileGetter)
+}
+
+func (x *staticFileInodeOps) afterLoad() {}
+
+func (x *staticFileInodeOps) StateLoad(m state.Source) {
+ m.Load(0, &x.InodeSimpleAttributes)
+ m.Load(1, &x.InodeStaticFileGetter)
+}
+
+func (x *loadavgData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.loadavgData"
+}
+
+func (x *loadavgData) StateFields() []string {
+ return []string{}
+}
+
+func (x *loadavgData) beforeSave() {}
+
+func (x *loadavgData) StateSave(m state.Sink) {
+ x.beforeSave()
+}
+
+func (x *loadavgData) afterLoad() {}
+
+func (x *loadavgData) StateLoad(m state.Source) {
+}
+
+func (x *meminfoData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.meminfoData"
+}
+
+func (x *meminfoData) StateFields() []string {
+ return []string{
+ "k",
+ }
+}
+
+func (x *meminfoData) beforeSave() {}
+
+func (x *meminfoData) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.k)
+}
+
+func (x *meminfoData) afterLoad() {}
+
+func (x *meminfoData) StateLoad(m state.Source) {
+ m.Load(0, &x.k)
+}
+
+func (x *mountInfoFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.mountInfoFile"
+}
+
+func (x *mountInfoFile) StateFields() []string {
+ return []string{
+ "t",
+ }
+}
+
+func (x *mountInfoFile) beforeSave() {}
+
+func (x *mountInfoFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.t)
+}
+
+func (x *mountInfoFile) afterLoad() {}
+
+func (x *mountInfoFile) StateLoad(m state.Source) {
+ m.Load(0, &x.t)
+}
+
+func (x *mountsFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.mountsFile"
+}
+
+func (x *mountsFile) StateFields() []string {
+ return []string{
+ "t",
+ }
+}
+
+func (x *mountsFile) beforeSave() {}
+
+func (x *mountsFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.t)
+}
+
+func (x *mountsFile) afterLoad() {}
+
+func (x *mountsFile) StateLoad(m state.Source) {
+ m.Load(0, &x.t)
+}
+
+func (x *ifinet6) StateTypeName() string {
+ return "pkg/sentry/fs/proc.ifinet6"
+}
+
+func (x *ifinet6) StateFields() []string {
+ return []string{
+ "s",
+ }
+}
+
+func (x *ifinet6) beforeSave() {}
+
+func (x *ifinet6) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.s)
+}
+
+func (x *ifinet6) afterLoad() {}
+
+func (x *ifinet6) StateLoad(m state.Source) {
+ m.Load(0, &x.s)
+}
+
+func (x *netDev) StateTypeName() string {
+ return "pkg/sentry/fs/proc.netDev"
+}
+
+func (x *netDev) StateFields() []string {
+ return []string{
+ "s",
+ }
+}
+
+func (x *netDev) beforeSave() {}
+
+func (x *netDev) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.s)
+}
+
+func (x *netDev) afterLoad() {}
+
+func (x *netDev) StateLoad(m state.Source) {
+ m.Load(0, &x.s)
+}
+
+func (x *netSnmp) StateTypeName() string {
+ return "pkg/sentry/fs/proc.netSnmp"
+}
+
+func (x *netSnmp) StateFields() []string {
+ return []string{
+ "s",
+ }
+}
+
+func (x *netSnmp) beforeSave() {}
+
+func (x *netSnmp) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.s)
+}
+
+func (x *netSnmp) afterLoad() {}
+
+func (x *netSnmp) StateLoad(m state.Source) {
+ m.Load(0, &x.s)
+}
+
+func (x *netRoute) StateTypeName() string {
+ return "pkg/sentry/fs/proc.netRoute"
+}
+
+func (x *netRoute) StateFields() []string {
+ return []string{
+ "s",
+ }
+}
+
+func (x *netRoute) beforeSave() {}
+
+func (x *netRoute) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.s)
+}
+
+func (x *netRoute) afterLoad() {}
+
+func (x *netRoute) StateLoad(m state.Source) {
+ m.Load(0, &x.s)
+}
+
+func (x *netUnix) StateTypeName() string {
+ return "pkg/sentry/fs/proc.netUnix"
+}
+
+func (x *netUnix) StateFields() []string {
+ return []string{
+ "k",
+ }
+}
+
+func (x *netUnix) beforeSave() {}
+
+func (x *netUnix) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.k)
+}
+
+func (x *netUnix) afterLoad() {}
+
+func (x *netUnix) StateLoad(m state.Source) {
+ m.Load(0, &x.k)
+}
+
+func (x *netTCP) StateTypeName() string {
+ return "pkg/sentry/fs/proc.netTCP"
+}
+
+func (x *netTCP) StateFields() []string {
+ return []string{
+ "k",
+ }
+}
+
+func (x *netTCP) beforeSave() {}
+
+func (x *netTCP) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.k)
+}
+
+func (x *netTCP) afterLoad() {}
+
+func (x *netTCP) StateLoad(m state.Source) {
+ m.Load(0, &x.k)
+}
+
+func (x *netTCP6) StateTypeName() string {
+ return "pkg/sentry/fs/proc.netTCP6"
+}
+
+func (x *netTCP6) StateFields() []string {
+ return []string{
+ "k",
+ }
+}
+
+func (x *netTCP6) beforeSave() {}
+
+func (x *netTCP6) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.k)
+}
+
+func (x *netTCP6) afterLoad() {}
+
+func (x *netTCP6) StateLoad(m state.Source) {
+ m.Load(0, &x.k)
+}
+
+func (x *netUDP) StateTypeName() string {
+ return "pkg/sentry/fs/proc.netUDP"
+}
+
+func (x *netUDP) StateFields() []string {
+ return []string{
+ "k",
+ }
+}
+
+func (x *netUDP) beforeSave() {}
+
+func (x *netUDP) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.k)
+}
+
+func (x *netUDP) afterLoad() {}
+
+func (x *netUDP) StateLoad(m state.Source) {
+ m.Load(0, &x.k)
+}
+
+func (x *proc) StateTypeName() string {
+ return "pkg/sentry/fs/proc.proc"
+}
+
+func (x *proc) StateFields() []string {
+ return []string{
+ "Dir",
+ "k",
+ "pidns",
+ "cgroupControllers",
+ }
+}
+
+func (x *proc) beforeSave() {}
+
+func (x *proc) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.Dir)
+ m.Save(1, &x.k)
+ m.Save(2, &x.pidns)
+ m.Save(3, &x.cgroupControllers)
+}
+
+func (x *proc) afterLoad() {}
+
+func (x *proc) StateLoad(m state.Source) {
+ m.Load(0, &x.Dir)
+ m.Load(1, &x.k)
+ m.Load(2, &x.pidns)
+ m.Load(3, &x.cgroupControllers)
+}
+
+func (x *self) StateTypeName() string {
+ return "pkg/sentry/fs/proc.self"
+}
+
+func (x *self) StateFields() []string {
+ return []string{
+ "Symlink",
+ "pidns",
+ }
+}
+
+func (x *self) beforeSave() {}
+
+func (x *self) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.Symlink)
+ m.Save(1, &x.pidns)
+}
+
+func (x *self) afterLoad() {}
+
+func (x *self) StateLoad(m state.Source) {
+ m.Load(0, &x.Symlink)
+ m.Load(1, &x.pidns)
+}
+
+func (x *threadSelf) StateTypeName() string {
+ return "pkg/sentry/fs/proc.threadSelf"
+}
+
+func (x *threadSelf) StateFields() []string {
+ return []string{
+ "Symlink",
+ "pidns",
+ }
+}
+
+func (x *threadSelf) beforeSave() {}
+
+func (x *threadSelf) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.Symlink)
+ m.Save(1, &x.pidns)
+}
+
+func (x *threadSelf) afterLoad() {}
+
+func (x *threadSelf) StateLoad(m state.Source) {
+ m.Load(0, &x.Symlink)
+ m.Load(1, &x.pidns)
+}
+
+func (x *rootProcFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.rootProcFile"
+}
+
+func (x *rootProcFile) StateFields() []string {
+ return []string{
+ "iops",
+ }
+}
+
+func (x *rootProcFile) beforeSave() {}
+
+func (x *rootProcFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.iops)
+}
+
+func (x *rootProcFile) afterLoad() {}
+
+func (x *rootProcFile) StateLoad(m state.Source) {
+ m.Load(0, &x.iops)
+}
+
+func (x *statData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.statData"
+}
+
+func (x *statData) StateFields() []string {
+ return []string{
+ "k",
+ }
+}
+
+func (x *statData) beforeSave() {}
+
+func (x *statData) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.k)
+}
+
+func (x *statData) afterLoad() {}
+
+func (x *statData) StateLoad(m state.Source) {
+ m.Load(0, &x.k)
+}
+
+func (x *mmapMinAddrData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.mmapMinAddrData"
+}
+
+func (x *mmapMinAddrData) StateFields() []string {
+ return []string{
+ "k",
+ }
+}
+
+func (x *mmapMinAddrData) beforeSave() {}
+
+func (x *mmapMinAddrData) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.k)
+}
+
+func (x *mmapMinAddrData) afterLoad() {}
+
+func (x *mmapMinAddrData) StateLoad(m state.Source) {
+ m.Load(0, &x.k)
+}
+
+func (x *overcommitMemory) StateTypeName() string {
+ return "pkg/sentry/fs/proc.overcommitMemory"
+}
+
+func (x *overcommitMemory) StateFields() []string {
+ return []string{}
+}
+
+func (x *overcommitMemory) beforeSave() {}
+
+func (x *overcommitMemory) StateSave(m state.Sink) {
+ x.beforeSave()
+}
+
+func (x *overcommitMemory) afterLoad() {}
+
+func (x *overcommitMemory) StateLoad(m state.Source) {
+}
+
+func (x *hostname) StateTypeName() string {
+ return "pkg/sentry/fs/proc.hostname"
+}
+
+func (x *hostname) StateFields() []string {
+ return []string{
+ "SimpleFileInode",
+ }
+}
+
+func (x *hostname) beforeSave() {}
+
+func (x *hostname) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.SimpleFileInode)
+}
+
+func (x *hostname) afterLoad() {}
+
+func (x *hostname) StateLoad(m state.Source) {
+ m.Load(0, &x.SimpleFileInode)
+}
+
+func (x *hostnameFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.hostnameFile"
+}
+
+func (x *hostnameFile) StateFields() []string {
+ return []string{}
+}
+
+func (x *hostnameFile) beforeSave() {}
+
+func (x *hostnameFile) StateSave(m state.Sink) {
+ x.beforeSave()
+}
+
+func (x *hostnameFile) afterLoad() {}
+
+func (x *hostnameFile) StateLoad(m state.Source) {
+}
+
+func (x *tcpMemInode) StateTypeName() string {
+ return "pkg/sentry/fs/proc.tcpMemInode"
+}
+
+func (x *tcpMemInode) StateFields() []string {
+ return []string{
+ "SimpleFileInode",
+ "dir",
+ "s",
+ "size",
+ }
+}
+
+func (x *tcpMemInode) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.SimpleFileInode)
+ m.Save(1, &x.dir)
+ m.Save(2, &x.s)
+ m.Save(3, &x.size)
+}
+
+func (x *tcpMemInode) StateLoad(m state.Source) {
+ m.Load(0, &x.SimpleFileInode)
+ m.Load(1, &x.dir)
+ m.LoadWait(2, &x.s)
+ m.Load(3, &x.size)
+ m.AfterLoad(x.afterLoad)
+}
+
+func (x *tcpMemFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.tcpMemFile"
+}
+
+func (x *tcpMemFile) StateFields() []string {
+ return []string{
+ "tcpMemInode",
+ }
+}
+
+func (x *tcpMemFile) beforeSave() {}
+
+func (x *tcpMemFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.tcpMemInode)
+}
+
+func (x *tcpMemFile) afterLoad() {}
+
+func (x *tcpMemFile) StateLoad(m state.Source) {
+ m.Load(0, &x.tcpMemInode)
+}
+
+func (x *tcpSack) StateTypeName() string {
+ return "pkg/sentry/fs/proc.tcpSack"
+}
+
+func (x *tcpSack) StateFields() []string {
+ return []string{
+ "SimpleFileInode",
+ "stack",
+ "enabled",
+ }
+}
+
+func (x *tcpSack) beforeSave() {}
+
+func (x *tcpSack) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.SimpleFileInode)
+ m.Save(1, &x.stack)
+ m.Save(2, &x.enabled)
+}
+
+func (x *tcpSack) StateLoad(m state.Source) {
+ m.Load(0, &x.SimpleFileInode)
+ m.LoadWait(1, &x.stack)
+ m.Load(2, &x.enabled)
+ m.AfterLoad(x.afterLoad)
+}
+
+func (x *tcpSackFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.tcpSackFile"
+}
+
+func (x *tcpSackFile) StateFields() []string {
+ return []string{
+ "tcpSack",
+ "stack",
+ }
+}
+
+func (x *tcpSackFile) beforeSave() {}
+
+func (x *tcpSackFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.tcpSack)
+ m.Save(1, &x.stack)
+}
+
+func (x *tcpSackFile) afterLoad() {}
+
+func (x *tcpSackFile) StateLoad(m state.Source) {
+ m.Load(0, &x.tcpSack)
+ m.LoadWait(1, &x.stack)
+}
+
+func (x *taskDir) StateTypeName() string {
+ return "pkg/sentry/fs/proc.taskDir"
+}
+
+func (x *taskDir) StateFields() []string {
+ return []string{
+ "Dir",
+ "t",
+ }
+}
+
+func (x *taskDir) beforeSave() {}
+
+func (x *taskDir) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.Dir)
+ m.Save(1, &x.t)
+}
+
+func (x *taskDir) afterLoad() {}
+
+func (x *taskDir) StateLoad(m state.Source) {
+ m.Load(0, &x.Dir)
+ m.Load(1, &x.t)
+}
+
+func (x *subtasks) StateTypeName() string {
+ return "pkg/sentry/fs/proc.subtasks"
+}
+
+func (x *subtasks) StateFields() []string {
+ return []string{
+ "Dir",
+ "t",
+ "p",
+ }
+}
+
+func (x *subtasks) beforeSave() {}
+
+func (x *subtasks) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.Dir)
+ m.Save(1, &x.t)
+ m.Save(2, &x.p)
+}
+
+func (x *subtasks) afterLoad() {}
+
+func (x *subtasks) StateLoad(m state.Source) {
+ m.Load(0, &x.Dir)
+ m.Load(1, &x.t)
+ m.Load(2, &x.p)
+}
+
+func (x *subtasksFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.subtasksFile"
+}
+
+func (x *subtasksFile) StateFields() []string {
+ return []string{
+ "t",
+ "pidns",
+ }
+}
+
+func (x *subtasksFile) beforeSave() {}
+
+func (x *subtasksFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.t)
+ m.Save(1, &x.pidns)
+}
+
+func (x *subtasksFile) afterLoad() {}
+
+func (x *subtasksFile) StateLoad(m state.Source) {
+ m.Load(0, &x.t)
+ m.Load(1, &x.pidns)
+}
+
+func (x *exe) StateTypeName() string {
+ return "pkg/sentry/fs/proc.exe"
+}
+
+func (x *exe) StateFields() []string {
+ return []string{
+ "Symlink",
+ "t",
+ }
+}
+
+func (x *exe) beforeSave() {}
+
+func (x *exe) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.Symlink)
+ m.Save(1, &x.t)
+}
+
+func (x *exe) afterLoad() {}
+
+func (x *exe) StateLoad(m state.Source) {
+ m.Load(0, &x.Symlink)
+ m.Load(1, &x.t)
+}
+
+func (x *namespaceSymlink) StateTypeName() string {
+ return "pkg/sentry/fs/proc.namespaceSymlink"
+}
+
+func (x *namespaceSymlink) StateFields() []string {
+ return []string{
+ "Symlink",
+ "t",
+ }
+}
+
+func (x *namespaceSymlink) beforeSave() {}
+
+func (x *namespaceSymlink) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.Symlink)
+ m.Save(1, &x.t)
+}
+
+func (x *namespaceSymlink) afterLoad() {}
+
+func (x *namespaceSymlink) StateLoad(m state.Source) {
+ m.Load(0, &x.Symlink)
+ m.Load(1, &x.t)
+}
+
+func (x *mapsData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.mapsData"
+}
+
+func (x *mapsData) StateFields() []string {
+ return []string{
+ "t",
+ }
+}
+
+func (x *mapsData) beforeSave() {}
+
+func (x *mapsData) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.t)
+}
+
+func (x *mapsData) afterLoad() {}
+
+func (x *mapsData) StateLoad(m state.Source) {
+ m.Load(0, &x.t)
+}
+
+func (x *smapsData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.smapsData"
+}
+
+func (x *smapsData) StateFields() []string {
+ return []string{
+ "t",
+ }
+}
+
+func (x *smapsData) beforeSave() {}
+
+func (x *smapsData) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.t)
+}
+
+func (x *smapsData) afterLoad() {}
+
+func (x *smapsData) StateLoad(m state.Source) {
+ m.Load(0, &x.t)
+}
+
+func (x *taskStatData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.taskStatData"
+}
+
+func (x *taskStatData) StateFields() []string {
+ return []string{
+ "t",
+ "tgstats",
+ "pidns",
+ }
+}
+
+func (x *taskStatData) beforeSave() {}
+
+func (x *taskStatData) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.t)
+ m.Save(1, &x.tgstats)
+ m.Save(2, &x.pidns)
+}
+
+func (x *taskStatData) afterLoad() {}
+
+func (x *taskStatData) StateLoad(m state.Source) {
+ m.Load(0, &x.t)
+ m.Load(1, &x.tgstats)
+ m.Load(2, &x.pidns)
+}
+
+func (x *statmData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.statmData"
+}
+
+func (x *statmData) StateFields() []string {
+ return []string{
+ "t",
+ }
+}
+
+func (x *statmData) beforeSave() {}
+
+func (x *statmData) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.t)
+}
+
+func (x *statmData) afterLoad() {}
+
+func (x *statmData) StateLoad(m state.Source) {
+ m.Load(0, &x.t)
+}
+
+func (x *statusData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.statusData"
+}
+
+func (x *statusData) StateFields() []string {
+ return []string{
+ "t",
+ "pidns",
+ }
+}
+
+func (x *statusData) beforeSave() {}
+
+func (x *statusData) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.t)
+ m.Save(1, &x.pidns)
+}
+
+func (x *statusData) afterLoad() {}
+
+func (x *statusData) StateLoad(m state.Source) {
+ m.Load(0, &x.t)
+ m.Load(1, &x.pidns)
+}
+
+func (x *ioData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.ioData"
+}
+
+func (x *ioData) StateFields() []string {
+ return []string{
+ "ioUsage",
+ }
+}
+
+func (x *ioData) beforeSave() {}
+
+func (x *ioData) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.ioUsage)
+}
+
+func (x *ioData) afterLoad() {}
+
+func (x *ioData) StateLoad(m state.Source) {
+ m.Load(0, &x.ioUsage)
+}
+
+func (x *comm) StateTypeName() string {
+ return "pkg/sentry/fs/proc.comm"
+}
+
+func (x *comm) StateFields() []string {
+ return []string{
+ "SimpleFileInode",
+ "t",
+ }
+}
+
+func (x *comm) beforeSave() {}
+
+func (x *comm) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.SimpleFileInode)
+ m.Save(1, &x.t)
+}
+
+func (x *comm) afterLoad() {}
+
+func (x *comm) StateLoad(m state.Source) {
+ m.Load(0, &x.SimpleFileInode)
+ m.Load(1, &x.t)
+}
+
+func (x *commFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.commFile"
+}
+
+func (x *commFile) StateFields() []string {
+ return []string{
+ "t",
+ }
+}
+
+func (x *commFile) beforeSave() {}
+
+func (x *commFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.t)
+}
+
+func (x *commFile) afterLoad() {}
+
+func (x *commFile) StateLoad(m state.Source) {
+ m.Load(0, &x.t)
+}
+
+func (x *auxvec) StateTypeName() string {
+ return "pkg/sentry/fs/proc.auxvec"
+}
+
+func (x *auxvec) StateFields() []string {
+ return []string{
+ "SimpleFileInode",
+ "t",
+ }
+}
+
+func (x *auxvec) beforeSave() {}
+
+func (x *auxvec) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.SimpleFileInode)
+ m.Save(1, &x.t)
+}
+
+func (x *auxvec) afterLoad() {}
+
+func (x *auxvec) StateLoad(m state.Source) {
+ m.Load(0, &x.SimpleFileInode)
+ m.Load(1, &x.t)
+}
+
+func (x *auxvecFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.auxvecFile"
+}
+
+func (x *auxvecFile) StateFields() []string {
+ return []string{
+ "t",
+ }
+}
+
+func (x *auxvecFile) beforeSave() {}
+
+func (x *auxvecFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.t)
+}
+
+func (x *auxvecFile) afterLoad() {}
+
+func (x *auxvecFile) StateLoad(m state.Source) {
+ m.Load(0, &x.t)
+}
+
+func (x *oomScoreAdj) StateTypeName() string {
+ return "pkg/sentry/fs/proc.oomScoreAdj"
+}
+
+func (x *oomScoreAdj) StateFields() []string {
+ return []string{
+ "SimpleFileInode",
+ "t",
+ }
+}
+
+func (x *oomScoreAdj) beforeSave() {}
+
+func (x *oomScoreAdj) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.SimpleFileInode)
+ m.Save(1, &x.t)
+}
+
+func (x *oomScoreAdj) afterLoad() {}
+
+func (x *oomScoreAdj) StateLoad(m state.Source) {
+ m.Load(0, &x.SimpleFileInode)
+ m.Load(1, &x.t)
+}
+
+func (x *oomScoreAdjFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.oomScoreAdjFile"
+}
+
+func (x *oomScoreAdjFile) StateFields() []string {
+ return []string{
+ "t",
+ }
+}
+
+func (x *oomScoreAdjFile) beforeSave() {}
+
+func (x *oomScoreAdjFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.t)
+}
+
+func (x *oomScoreAdjFile) afterLoad() {}
+
+func (x *oomScoreAdjFile) StateLoad(m state.Source) {
+ m.Load(0, &x.t)
+}
+
+func (x *idMapInodeOperations) StateTypeName() string {
+ return "pkg/sentry/fs/proc.idMapInodeOperations"
+}
+
+func (x *idMapInodeOperations) StateFields() []string {
+ return []string{
+ "InodeSimpleAttributes",
+ "InodeSimpleExtendedAttributes",
+ "t",
+ "gids",
+ }
+}
+
+func (x *idMapInodeOperations) beforeSave() {}
+
+func (x *idMapInodeOperations) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.InodeSimpleAttributes)
+ m.Save(1, &x.InodeSimpleExtendedAttributes)
+ m.Save(2, &x.t)
+ m.Save(3, &x.gids)
+}
+
+func (x *idMapInodeOperations) afterLoad() {}
+
+func (x *idMapInodeOperations) StateLoad(m state.Source) {
+ m.Load(0, &x.InodeSimpleAttributes)
+ m.Load(1, &x.InodeSimpleExtendedAttributes)
+ m.Load(2, &x.t)
+ m.Load(3, &x.gids)
+}
+
+func (x *idMapFileOperations) StateTypeName() string {
+ return "pkg/sentry/fs/proc.idMapFileOperations"
+}
+
+func (x *idMapFileOperations) StateFields() []string {
+ return []string{
+ "iops",
+ }
+}
+
+func (x *idMapFileOperations) beforeSave() {}
+
+func (x *idMapFileOperations) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.iops)
+}
+
+func (x *idMapFileOperations) afterLoad() {}
+
+func (x *idMapFileOperations) StateLoad(m state.Source) {
+ m.Load(0, &x.iops)
+}
+
+func (x *uptime) StateTypeName() string {
+ return "pkg/sentry/fs/proc.uptime"
+}
+
+func (x *uptime) StateFields() []string {
+ return []string{
+ "SimpleFileInode",
+ "startTime",
+ }
+}
+
+func (x *uptime) beforeSave() {}
+
+func (x *uptime) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.SimpleFileInode)
+ m.Save(1, &x.startTime)
+}
+
+func (x *uptime) afterLoad() {}
+
+func (x *uptime) StateLoad(m state.Source) {
+ m.Load(0, &x.SimpleFileInode)
+ m.Load(1, &x.startTime)
+}
+
+func (x *uptimeFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc.uptimeFile"
+}
+
+func (x *uptimeFile) StateFields() []string {
+ return []string{
+ "startTime",
+ }
+}
+
+func (x *uptimeFile) beforeSave() {}
+
+func (x *uptimeFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.startTime)
+}
+
+func (x *uptimeFile) afterLoad() {}
+
+func (x *uptimeFile) StateLoad(m state.Source) {
+ m.Load(0, &x.startTime)
+}
+
+func (x *versionData) StateTypeName() string {
+ return "pkg/sentry/fs/proc.versionData"
+}
+
+func (x *versionData) StateFields() []string {
+ return []string{
+ "k",
+ }
+}
+
+func (x *versionData) beforeSave() {}
+
+func (x *versionData) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.k)
+}
+
+func (x *versionData) afterLoad() {}
+
+func (x *versionData) StateLoad(m state.Source) {
+ m.Load(0, &x.k)
+}
+
+func init() {
+ state.Register((*execArgInode)(nil))
+ state.Register((*execArgFile)(nil))
+ state.Register((*fdDir)(nil))
+ state.Register((*fdDirFile)(nil))
+ state.Register((*fdInfoDir)(nil))
+ state.Register((*filesystemsData)(nil))
+ state.Register((*filesystem)(nil))
+ state.Register((*taskOwnedInodeOps)(nil))
+ state.Register((*staticFileInodeOps)(nil))
+ state.Register((*loadavgData)(nil))
+ state.Register((*meminfoData)(nil))
+ state.Register((*mountInfoFile)(nil))
+ state.Register((*mountsFile)(nil))
+ state.Register((*ifinet6)(nil))
+ state.Register((*netDev)(nil))
+ state.Register((*netSnmp)(nil))
+ state.Register((*netRoute)(nil))
+ state.Register((*netUnix)(nil))
+ state.Register((*netTCP)(nil))
+ state.Register((*netTCP6)(nil))
+ state.Register((*netUDP)(nil))
+ state.Register((*proc)(nil))
+ state.Register((*self)(nil))
+ state.Register((*threadSelf)(nil))
+ state.Register((*rootProcFile)(nil))
+ state.Register((*statData)(nil))
+ state.Register((*mmapMinAddrData)(nil))
+ state.Register((*overcommitMemory)(nil))
+ state.Register((*hostname)(nil))
+ state.Register((*hostnameFile)(nil))
+ state.Register((*tcpMemInode)(nil))
+ state.Register((*tcpMemFile)(nil))
+ state.Register((*tcpSack)(nil))
+ state.Register((*tcpSackFile)(nil))
+ state.Register((*taskDir)(nil))
+ state.Register((*subtasks)(nil))
+ state.Register((*subtasksFile)(nil))
+ state.Register((*exe)(nil))
+ state.Register((*namespaceSymlink)(nil))
+ state.Register((*mapsData)(nil))
+ state.Register((*smapsData)(nil))
+ state.Register((*taskStatData)(nil))
+ state.Register((*statmData)(nil))
+ state.Register((*statusData)(nil))
+ state.Register((*ioData)(nil))
+ state.Register((*comm)(nil))
+ state.Register((*commFile)(nil))
+ state.Register((*auxvec)(nil))
+ state.Register((*auxvecFile)(nil))
+ state.Register((*oomScoreAdj)(nil))
+ state.Register((*oomScoreAdjFile)(nil))
+ state.Register((*idMapInodeOperations)(nil))
+ state.Register((*idMapFileOperations)(nil))
+ state.Register((*uptime)(nil))
+ state.Register((*uptimeFile)(nil))
+ state.Register((*versionData)(nil))
+}
diff --git a/pkg/sentry/fs/proc/seqfile/BUILD b/pkg/sentry/fs/proc/seqfile/BUILD
deleted file mode 100644
index 21338d912..000000000
--- a/pkg/sentry/fs/proc/seqfile/BUILD
+++ /dev/null
@@ -1,35 +0,0 @@
-load("//tools:defs.bzl", "go_library", "go_test")
-
-package(licenses = ["notice"])
-
-go_library(
- name = "seqfile",
- srcs = ["seqfile.go"],
- visibility = ["//pkg/sentry:internal"],
- deps = [
- "//pkg/abi/linux",
- "//pkg/context",
- "//pkg/sentry/fs",
- "//pkg/sentry/fs/fsutil",
- "//pkg/sentry/fs/proc/device",
- "//pkg/sentry/kernel/time",
- "//pkg/sync",
- "//pkg/syserror",
- "//pkg/usermem",
- "//pkg/waiter",
- ],
-)
-
-go_test(
- name = "seqfile_test",
- size = "small",
- srcs = ["seqfile_test.go"],
- library = ":seqfile",
- deps = [
- "//pkg/context",
- "//pkg/sentry/contexttest",
- "//pkg/sentry/fs",
- "//pkg/sentry/fs/ramfs",
- "//pkg/usermem",
- ],
-)
diff --git a/pkg/sentry/fs/proc/seqfile/seqfile_state_autogen.go b/pkg/sentry/fs/proc/seqfile/seqfile_state_autogen.go
new file mode 100644
index 000000000..6f48a944a
--- /dev/null
+++ b/pkg/sentry/fs/proc/seqfile/seqfile_state_autogen.go
@@ -0,0 +1,100 @@
+// automatically generated by stateify.
+
+package seqfile
+
+import (
+ "gvisor.dev/gvisor/pkg/state"
+)
+
+func (x *SeqData) StateTypeName() string {
+ return "pkg/sentry/fs/proc/seqfile.SeqData"
+}
+
+func (x *SeqData) StateFields() []string {
+ return []string{
+ "Buf",
+ "Handle",
+ }
+}
+
+func (x *SeqData) beforeSave() {}
+
+func (x *SeqData) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.Buf)
+ m.Save(1, &x.Handle)
+}
+
+func (x *SeqData) afterLoad() {}
+
+func (x *SeqData) StateLoad(m state.Source) {
+ m.Load(0, &x.Buf)
+ m.Load(1, &x.Handle)
+}
+
+func (x *SeqFile) StateTypeName() string {
+ return "pkg/sentry/fs/proc/seqfile.SeqFile"
+}
+
+func (x *SeqFile) StateFields() []string {
+ return []string{
+ "InodeSimpleExtendedAttributes",
+ "InodeSimpleAttributes",
+ "SeqSource",
+ "source",
+ "generation",
+ "lastRead",
+ }
+}
+
+func (x *SeqFile) beforeSave() {}
+
+func (x *SeqFile) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.InodeSimpleExtendedAttributes)
+ m.Save(1, &x.InodeSimpleAttributes)
+ m.Save(2, &x.SeqSource)
+ m.Save(3, &x.source)
+ m.Save(4, &x.generation)
+ m.Save(5, &x.lastRead)
+}
+
+func (x *SeqFile) afterLoad() {}
+
+func (x *SeqFile) StateLoad(m state.Source) {
+ m.Load(0, &x.InodeSimpleExtendedAttributes)
+ m.Load(1, &x.InodeSimpleAttributes)
+ m.Load(2, &x.SeqSource)
+ m.Load(3, &x.source)
+ m.Load(4, &x.generation)
+ m.Load(5, &x.lastRead)
+}
+
+func (x *seqFileOperations) StateTypeName() string {
+ return "pkg/sentry/fs/proc/seqfile.seqFileOperations"
+}
+
+func (x *seqFileOperations) StateFields() []string {
+ return []string{
+ "seqFile",
+ }
+}
+
+func (x *seqFileOperations) beforeSave() {}
+
+func (x *seqFileOperations) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.seqFile)
+}
+
+func (x *seqFileOperations) afterLoad() {}
+
+func (x *seqFileOperations) StateLoad(m state.Source) {
+ m.Load(0, &x.seqFile)
+}
+
+func init() {
+ state.Register((*SeqData)(nil))
+ state.Register((*SeqFile)(nil))
+ state.Register((*seqFileOperations)(nil))
+}
diff --git a/pkg/sentry/fs/proc/seqfile/seqfile_test.go b/pkg/sentry/fs/proc/seqfile/seqfile_test.go
deleted file mode 100644
index 98e394569..000000000
--- a/pkg/sentry/fs/proc/seqfile/seqfile_test.go
+++ /dev/null
@@ -1,279 +0,0 @@
-// Copyright 2018 The gVisor Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package seqfile
-
-import (
- "bytes"
- "fmt"
- "io"
- "testing"
-
- "gvisor.dev/gvisor/pkg/context"
- "gvisor.dev/gvisor/pkg/sentry/contexttest"
- "gvisor.dev/gvisor/pkg/sentry/fs"
- "gvisor.dev/gvisor/pkg/sentry/fs/ramfs"
- "gvisor.dev/gvisor/pkg/usermem"
-)
-
-type seqTest struct {
- actual []SeqData
- update bool
-}
-
-func (s *seqTest) Init() {
- var sq []SeqData
- // Create some SeqData.
- for i := 0; i < 10; i++ {
- var b []byte
- for j := 0; j < 10; j++ {
- b = append(b, byte(i))
- }
- sq = append(sq, SeqData{
- Buf: b,
- Handle: &testHandle{i: i},
- })
- }
- s.actual = sq
-}
-
-// NeedsUpdate reports whether we need to update the data we've previously read.
-func (s *seqTest) NeedsUpdate(int64) bool {
- return s.update
-}
-
-// ReadSeqFiledata returns a slice of SeqData which contains elements
-// greater than the handle.
-func (s *seqTest) ReadSeqFileData(ctx context.Context, handle SeqHandle) ([]SeqData, int64) {
- if handle == nil {
- return s.actual, 0
- }
- h := *handle.(*testHandle)
- var ret []SeqData
- for _, b := range s.actual {
- // We want the next one.
- h2 := *b.Handle.(*testHandle)
- if h2.i > h.i {
- ret = append(ret, b)
- }
- }
- return ret, 0
-}
-
-// Flatten a slice of slices into one slice.
-func flatten(buf ...[]byte) []byte {
- var flat []byte
- for _, b := range buf {
- flat = append(flat, b...)
- }
- return flat
-}
-
-type testHandle struct {
- i int
-}
-
-type testTable struct {
- offset int64
- readBufferSize int
- expectedData []byte
- expectedError error
-}
-
-func runTableTests(ctx context.Context, table []testTable, dirent *fs.Dirent) error {
- for _, tt := range table {
- file, err := dirent.Inode.InodeOperations.GetFile(ctx, dirent, fs.FileFlags{Read: true})
- if err != nil {
- return fmt.Errorf("GetFile returned error: %v", err)
- }
-
- data := make([]byte, tt.readBufferSize)
- resultLen, err := file.Preadv(ctx, usermem.BytesIOSequence(data), tt.offset)
- if err != tt.expectedError {
- return fmt.Errorf("t.Preadv(len: %v, offset: %v) (error) => %v expected %v", tt.readBufferSize, tt.offset, err, tt.expectedError)
- }
- expectedLen := int64(len(tt.expectedData))
- if resultLen != expectedLen {
- // We make this just an error so we wall through and print the data below.
- return fmt.Errorf("t.Preadv(len: %v, offset: %v) (size) => %v expected %v", tt.readBufferSize, tt.offset, resultLen, expectedLen)
- }
- if !bytes.Equal(data[:expectedLen], tt.expectedData) {
- return fmt.Errorf("t.Preadv(len: %v, offset: %v) (data) => %v expected %v", tt.readBufferSize, tt.offset, data[:expectedLen], tt.expectedData)
- }
- }
- return nil
-}
-
-func TestSeqFile(t *testing.T) {
- testSource := &seqTest{}
- testSource.Init()
-
- // Create a file that can be R/W.
- ctx := contexttest.Context(t)
- m := fs.NewPseudoMountSource(ctx)
- contents := map[string]*fs.Inode{
- "foo": NewSeqFileInode(ctx, testSource, m),
- }
- root := ramfs.NewDir(ctx, contents, fs.RootOwner, fs.FilePermsFromMode(0777))
-
- // How about opening it?
- inode := fs.NewInode(ctx, root, m, fs.StableAttr{Type: fs.Directory})
- dirent2, err := root.Lookup(ctx, inode, "foo")
- if err != nil {
- t.Fatalf("failed to walk to foo for n2: %v", err)
- }
- n2 := dirent2.Inode.InodeOperations
- file2, err := n2.GetFile(ctx, dirent2, fs.FileFlags{Read: true, Write: true})
- if err != nil {
- t.Fatalf("GetFile returned error: %v", err)
- }
-
- // Writing?
- if _, err := file2.Writev(ctx, usermem.BytesIOSequence([]byte("test"))); err == nil {
- t.Fatalf("managed to write to n2: %v", err)
- }
-
- // How about reading?
- dirent3, err := root.Lookup(ctx, inode, "foo")
- if err != nil {
- t.Fatalf("failed to walk to foo: %v", err)
- }
- n3 := dirent3.Inode.InodeOperations
- if n2 != n3 {
- t.Error("got n2 != n3, want same")
- }
-
- testSource.update = true
-
- table := []testTable{
- // Read past the end.
- {100, 4, []byte{}, io.EOF},
- {110, 4, []byte{}, io.EOF},
- {200, 4, []byte{}, io.EOF},
- // Read a truncated first line.
- {0, 4, testSource.actual[0].Buf[:4], nil},
- // Read the whole first line.
- {0, 10, testSource.actual[0].Buf, nil},
- // Read the whole first line + 5 bytes of second line.
- {0, 15, flatten(testSource.actual[0].Buf, testSource.actual[1].Buf[:5]), nil},
- // First 4 bytes of the second line.
- {10, 4, testSource.actual[1].Buf[:4], nil},
- // Read the two first lines.
- {0, 20, flatten(testSource.actual[0].Buf, testSource.actual[1].Buf), nil},
- // Read three lines.
- {0, 30, flatten(testSource.actual[0].Buf, testSource.actual[1].Buf, testSource.actual[2].Buf), nil},
- // Read everything, but use a bigger buffer than necessary.
- {0, 150, flatten(testSource.actual[0].Buf, testSource.actual[1].Buf, testSource.actual[2].Buf, testSource.actual[3].Buf, testSource.actual[4].Buf, testSource.actual[5].Buf, testSource.actual[6].Buf, testSource.actual[7].Buf, testSource.actual[8].Buf, testSource.actual[9].Buf), nil},
- // Read the last 3 bytes.
- {97, 10, testSource.actual[9].Buf[7:], nil},
- }
- if err := runTableTests(ctx, table, dirent2); err != nil {
- t.Errorf("runTableTest failed with testSource.update = %v : %v", testSource.update, err)
- }
-
- // Disable updates and do it again.
- testSource.update = false
- if err := runTableTests(ctx, table, dirent2); err != nil {
- t.Errorf("runTableTest failed with testSource.update = %v: %v", testSource.update, err)
- }
-}
-
-// Test that we behave correctly when the file is updated.
-func TestSeqFileFileUpdated(t *testing.T) {
- testSource := &seqTest{}
- testSource.Init()
- testSource.update = true
-
- // Create a file that can be R/W.
- ctx := contexttest.Context(t)
- m := fs.NewPseudoMountSource(ctx)
- contents := map[string]*fs.Inode{
- "foo": NewSeqFileInode(ctx, testSource, m),
- }
- root := ramfs.NewDir(ctx, contents, fs.RootOwner, fs.FilePermsFromMode(0777))
-
- // How about opening it?
- inode := fs.NewInode(ctx, root, m, fs.StableAttr{Type: fs.Directory})
- dirent2, err := root.Lookup(ctx, inode, "foo")
- if err != nil {
- t.Fatalf("failed to walk to foo for dirent2: %v", err)
- }
-
- table := []testTable{
- {0, 16, flatten(testSource.actual[0].Buf, testSource.actual[1].Buf[:6]), nil},
- }
- if err := runTableTests(ctx, table, dirent2); err != nil {
- t.Errorf("runTableTest failed: %v", err)
- }
- // Delete the first entry.
- cut := testSource.actual[0].Buf
- testSource.actual = testSource.actual[1:]
-
- table = []testTable{
- // Try reading buffer 0 with an offset. This will not delete the old data.
- {1, 5, cut[1:6], nil},
- // Reset our file by reading at offset 0.
- {0, 10, testSource.actual[0].Buf, nil},
- {16, 14, flatten(testSource.actual[1].Buf[6:], testSource.actual[2].Buf), nil},
- // Read the same data a second time.
- {16, 14, flatten(testSource.actual[1].Buf[6:], testSource.actual[2].Buf), nil},
- // Read the following two lines.
- {30, 20, flatten(testSource.actual[3].Buf, testSource.actual[4].Buf), nil},
- }
- if err := runTableTests(ctx, table, dirent2); err != nil {
- t.Errorf("runTableTest failed after removing first entry: %v", err)
- }
-
- // Add a new duplicate line in the middle (6666...)
- after := testSource.actual[5:]
- testSource.actual = testSource.actual[:4]
- // Note the list must be sorted.
- testSource.actual = append(testSource.actual, after[0])
- testSource.actual = append(testSource.actual, after...)
-
- table = []testTable{
- {50, 20, flatten(testSource.actual[4].Buf, testSource.actual[5].Buf), nil},
- }
- if err := runTableTests(ctx, table, dirent2); err != nil {
- t.Errorf("runTableTest failed after adding middle entry: %v", err)
- }
- // This will be used in a later test.
- oldTestData := testSource.actual
-
- // Delete everything.
- testSource.actual = testSource.actual[:0]
- table = []testTable{
- {20, 20, []byte{}, io.EOF},
- }
- if err := runTableTests(ctx, table, dirent2); err != nil {
- t.Errorf("runTableTest failed after removing all entries: %v", err)
- }
- // Restore some of the data.
- testSource.actual = oldTestData[:1]
- table = []testTable{
- {6, 20, testSource.actual[0].Buf[6:], nil},
- }
- if err := runTableTests(ctx, table, dirent2); err != nil {
- t.Errorf("runTableTest failed after adding first entry back: %v", err)
- }
-
- // Re-extend the data
- testSource.actual = oldTestData
- table = []testTable{
- {30, 20, flatten(testSource.actual[3].Buf, testSource.actual[4].Buf), nil},
- }
- if err := runTableTests(ctx, table, dirent2); err != nil {
- t.Errorf("runTableTest failed after extending testSource: %v", err)
- }
-}
diff --git a/pkg/sentry/fs/proc/sys_net_test.go b/pkg/sentry/fs/proc/sys_net_test.go
deleted file mode 100644
index 355e83d47..000000000
--- a/pkg/sentry/fs/proc/sys_net_test.go
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2018 The gVisor Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package proc
-
-import (
- "testing"
-
- "gvisor.dev/gvisor/pkg/context"
- "gvisor.dev/gvisor/pkg/sentry/inet"
- "gvisor.dev/gvisor/pkg/usermem"
-)
-
-func TestQuerySendBufferSize(t *testing.T) {
- ctx := context.Background()
- s := inet.NewTestStack()
- s.TCPSendBufSize = inet.TCPBufferSize{100, 200, 300}
- tmi := &tcpMemInode{s: s, dir: tcpWMem}
- tmf := &tcpMemFile{tcpMemInode: tmi}
-
- buf := make([]byte, 100)
- dst := usermem.BytesIOSequence(buf)
- n, err := tmf.Read(ctx, nil, dst, 0)
- if err != nil {
- t.Fatalf("Read failed: %v", err)
- }
-
- if got, want := string(buf[:n]), "100\t200\t300\n"; got != want {
- t.Fatalf("Bad string: got %v, want %v", got, want)
- }
-}
-
-func TestQueryRecvBufferSize(t *testing.T) {
- ctx := context.Background()
- s := inet.NewTestStack()
- s.TCPRecvBufSize = inet.TCPBufferSize{100, 200, 300}
- tmi := &tcpMemInode{s: s, dir: tcpRMem}
- tmf := &tcpMemFile{tcpMemInode: tmi}
-
- buf := make([]byte, 100)
- dst := usermem.BytesIOSequence(buf)
- n, err := tmf.Read(ctx, nil, dst, 0)
- if err != nil {
- t.Fatalf("Read failed: %v", err)
- }
-
- if got, want := string(buf[:n]), "100\t200\t300\n"; got != want {
- t.Fatalf("Bad string: got %v, want %v", got, want)
- }
-}
-
-var cases = []struct {
- str string
- initial inet.TCPBufferSize
- final inet.TCPBufferSize
-}{
- {
- str: "",
- initial: inet.TCPBufferSize{1, 2, 3},
- final: inet.TCPBufferSize{1, 2, 3},
- },
- {
- str: "100\n",
- initial: inet.TCPBufferSize{1, 100, 200},
- final: inet.TCPBufferSize{100, 100, 200},
- },
- {
- str: "100 200 300\n",
- initial: inet.TCPBufferSize{1, 2, 3},
- final: inet.TCPBufferSize{100, 200, 300},
- },
-}
-
-func TestConfigureSendBufferSize(t *testing.T) {
- ctx := context.Background()
- s := inet.NewTestStack()
- for _, c := range cases {
- s.TCPSendBufSize = c.initial
- tmi := &tcpMemInode{s: s, dir: tcpWMem}
- tmf := &tcpMemFile{tcpMemInode: tmi}
-
- // Write the values.
- src := usermem.BytesIOSequence([]byte(c.str))
- if n, err := tmf.Write(ctx, nil, src, 0); n != int64(len(c.str)) || err != nil {
- t.Errorf("Write, case = %q: got (%d, %v), wanted (%d, nil)", c.str, n, err, len(c.str))
- }
-
- // Read the values from the stack and check them.
- if s.TCPSendBufSize != c.final {
- t.Errorf("TCPSendBufferSize, case = %q: got %v, wanted %v", c.str, s.TCPSendBufSize, c.final)
- }
- }
-}
-
-func TestConfigureRecvBufferSize(t *testing.T) {
- ctx := context.Background()
- s := inet.NewTestStack()
- for _, c := range cases {
- s.TCPRecvBufSize = c.initial
- tmi := &tcpMemInode{s: s, dir: tcpRMem}
- tmf := &tcpMemFile{tcpMemInode: tmi}
-
- // Write the values.
- src := usermem.BytesIOSequence([]byte(c.str))
- if n, err := tmf.Write(ctx, nil, src, 0); n != int64(len(c.str)) || err != nil {
- t.Errorf("Write, case = %q: got (%d, %v), wanted (%d, nil)", c.str, n, err, len(c.str))
- }
-
- // Read the values from the stack and check them.
- if s.TCPRecvBufSize != c.final {
- t.Errorf("TCPRecvBufferSize, case = %q: got %v, wanted %v", c.str, s.TCPRecvBufSize, c.final)
- }
- }
-}