1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

feature #1782: datastore stat compatible with both GNU and BSD stat

This commit is contained in:
Javi Fontan 2013-02-25 21:24:56 +01:00
parent 4454909138
commit 455d56f97b

View File

@ -124,6 +124,24 @@ function set_downloader_args {
echo "$HASHES $5 $6"
}
#------------------------------------------------------------------------------
# Gets the size in bytes of a file
# @param $1 - Path to the image
# @return size of the image in bytes
#------------------------------------------------------------------------------
function file_size {
stat --version &> /dev/null
if [ $? = 0 ]; then
STAT_CMD="stat -c %s"
else
STAT_CMD="stat -f %z"
fi
$STAT_CMD "$*"
}
#-------------------------------------------------------------------------------
# Computes the size of an image
# @param $1 - Path to the image
@ -156,7 +174,7 @@ function fs_size {
SIZE=`du -sb "$1" | cut -f1`
error=$?
else
SIZE=`stat -c %s "$1"`
SIZE=$(file_size "$1")
error=$?
fi
;;