KernelRandom returns values from /proc/sys/kernel/random.
()
| 39 | |
| 40 | // KernelRandom returns values from /proc/sys/kernel/random. |
| 41 | func (fs FS) KernelRandom() (KernelRandom, error) { |
| 42 | random := KernelRandom{} |
| 43 | |
| 44 | for file, p := range map[string]**uint64{ |
| 45 | "entropy_avail": &random.EntropyAvaliable, |
| 46 | "poolsize": &random.PoolSize, |
| 47 | "urandom_min_reseed_secs": &random.URandomMinReseedSeconds, |
| 48 | "write_wakeup_threshold": &random.WriteWakeupThreshold, |
| 49 | "read_wakeup_threshold": &random.ReadWakeupThreshold, |
| 50 | } { |
| 51 | val, err := util.ReadUintFromFile(fs.proc.Path("sys", "kernel", "random", file)) |
| 52 | if os.IsNotExist(err) { |
| 53 | continue |
| 54 | } |
| 55 | if err != nil { |
| 56 | return random, err |
| 57 | } |
| 58 | *p = &val |
| 59 | } |
| 60 | |
| 61 | return random, nil |
| 62 | } |