sonic-buildimage/platform/marvell-armhf/sonic-platform-et6448m/entropy.py
Sabareesh-Kumar-Anandan 3cd70b88b7
[marvell][platform] Checking file presence before access (#6208)
In marvell_et644m platform scripts, I have added a check to confirm the file availability before accessing it.

Signed-off-by: Sabareesh Kumar Anandan <sanandan@marvell.com>
2020-12-15 08:43:12 -08:00

20 lines
579 B
Python

#!/usr/bin/python
import fcntl, struct
import time
from os import path
RNDADDENTROPY=0x40085203
def avail():
with open("/proc/sys/kernel/random/entropy_avail", mode='r') as avail:
return int(avail.read())
if path.exists("/proc/sys/kernel/random/entropy_avail"):
while 1:
while avail() < 2048:
with open('/dev/urandom', 'rb') as urnd, open("/dev/random", mode='wb') as rnd:
d = urnd.read(512)
t = struct.pack('ii', 4 * len(d), len(d)) + d
fcntl.ioctl(rnd, RNDADDENTROPY, t)
time.sleep(30)