qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/4] update get_file_size to not throw error on non-


From: Ryan Harper
Subject: [Qemu-devel] [PATCH 1/4] update get_file_size to not throw error on non-existant files
Date: Fri, 13 Jan 2012 16:05:18 -0600

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 <address@hidden>
---
 qemu-test |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

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
 }
 
-- 
1.7.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]