diff mbox

[1/4] update get_file_size to not throw error on non-existant files

Message ID 1326492321-13540-2-git-send-email-ryanh@us.ibm.com
State New
Headers show

Commit Message

Ryan Harper Jan. 13, 2012, 10:05 p.m. UTC
In some cases, when qemu is just starting up the logfile hasn't yet
been created and will throw an error message into the output:

ls: cannot access .tmp-3070/logfile-3070.log: No such file or directory

if we check to see if the file is readable first then we know the file
is present and we can extract the size.

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
---
 qemu-test |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/qemu-test b/qemu-test
index c6ea595..cd102a7 100755
--- a/qemu-test
+++ b/qemu-test
@@ -54,9 +54,10 @@  checkpid() {
 }
 
 get_file_size() {
-    ls -al $1 | cut -f5 -d' ' 2>/dev/null
-    if test $? != 0; then
-	echo 0
+    if test -r "${1}" ; then
+    ls -al $1 | cut -f5 -d' '
+    else
+    echo 0
     fi
 }