oem: ibm: Use `truncate(1)` to create NVRAM related files
Use of `dd(1)` results in back-to-back `read(2)` and `write(2)` syscalls;
the performance of `dd(1)` is O(n) with respect to the file size. Poor
choice of the `bs=` parameter to `dd(1)` can significantly amplify the
amount of syscalls required to achieve the task.
By contrast, `truncate(1)` generally invokes a single syscall, either
`truncate(2)` or `ftruncate(2)`. As a consequence, `truncate(1)` is O(1)
with respect to file size.
Switch to `truncate(1)` to improve runtime efficiency of the scripts.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I69dd925f36e733fc2a1ee71cb8354ee04ee8871b
diff --git a/oem/ibm/service_files/scripts/create-NVRAM-cksum-file b/oem/ibm/service_files/scripts/create-NVRAM-cksum-file
index 276f824..e33054f 100755
--- a/oem/ibm/service_files/scripts/create-NVRAM-cksum-file
+++ b/oem/ibm/service_files/scripts/create-NVRAM-cksum-file
@@ -3,5 +3,5 @@
if [ -f /var/lib/pldm/PHYP-NVRAM-CKSUM ]; then
mv /var/lib/pldm/PHYP-NVRAM-CKSUM /var/lib/phosphor-software-manager/hostfw/nvram/PHYP-NVRAM-CKSUM;
else
- dd if=/dev/zero of=/var/lib/phosphor-software-manager/hostfw/nvram/PHYP-NVRAM-CKSUM bs=16 count=1;
+ truncate -s 16 /var/lib/phosphor-software-manager/hostfw/nvram/PHYP-NVRAM-CKSUM
fi