Changeset View
Changeset View
Standalone View
Standalone View
libexec/save-entropy/save-entropy.sh
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
done | done | ||||
umask 377 | umask 377 | ||||
n=$(( ${entropy_save_num} - 1 )) | n=$(( ${entropy_save_num} - 1 )) | ||||
while [ ${n} -ge 1 ]; do | while [ ${n} -ge 1 ]; do | ||||
if [ -f "saved-entropy.${n}" ]; then | if [ -f "saved-entropy.${n}" ]; then | ||||
mv "saved-entropy.${n}" "saved-entropy.$(( ${n} + 1 ))" | mv "saved-entropy.${n}" "saved-entropy.$(( ${n} + 1 ))" | ||||
fsync . | |||||
delphij: fsync'ing the directory node would result in more writes and I think we can tolerate if it… | |||||
cemAuthorUnsubmitted Done Inline ActionsIf a small number of additional writes is a problem, and we can tolerate losing every rotated file (by lost dirent reference), I propose that we can save even more writes by keeping only one entropy file. cem: If a small number of additional writes is a problem, and we can tolerate losing every rotated… | |||||
elif [ -e "saved-entropy.${n}" -o -L "saved-entropy.${n}" ]; then | elif [ -e "saved-entropy.${n}" -o -L "saved-entropy.${n}" ]; then | ||||
logger -is -t "$0" \ | logger -is -t "$0" \ | ||||
"${entropy_dir}/saved-entropy.${n}" is not a regular file, and so \ | "${entropy_dir}/saved-entropy.${n}" is not a regular file, and so \ | ||||
it will not be rotated. Entropy file rotation is aborted. | it will not be rotated. Entropy file rotation is aborted. | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
n=$(( ${n} - 1 )) | n=$(( ${n} - 1 )) | ||||
done | done | ||||
dd if=/dev/random of=saved-entropy.1 bs=${entropy_save_sz} count=1 2>/dev/null | dd if=/dev/random of=saved-entropy.1 bs=${entropy_save_sz} count=1 2>/dev/null | ||||
fsync saved-entropy.1 | |||||
delphijUnsubmitted Done Inline ActionsThis can be merged with the '.' (fsync saved-entropy.1 .). delphij: This can be merged with the '.' (fsync saved-entropy.1 .). | |||||
cemAuthorUnsubmitted Done Inline ActionsAh, I did not realize fsync(1) took a list of files! Thank you, I'll fix it. cem: Ah, I did not realize fsync(1) took a list of files! Thank you, I'll fix it. | |||||
fsync . | |||||
exit 0 | exit 0 |
fsync'ing the directory node would result in more writes and I think we can tolerate if it failed to sync.