Skip to content

Commit

Permalink
fix: Fix issue #281
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese committed Jul 3, 2023
1 parent f3f9a9f commit d1957f5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions run/disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ if [ -f "${DATA}" ]; then
if [[ "${ALLOCATE}" == [Nn]* ]]; then

# Resize file by changing its length
truncate -s "${DATA_SIZE}" "${DATA}";
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
error "Could not resize the file for the virtual disk." && exit 85
fi

else

Expand All @@ -55,7 +57,9 @@ if [ -f "${DATA}" ]; then

# Resize file by allocating more space
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
error "Could not allocate a file for the virtual disk." && exit 85
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
error "Could not resize the file for the virtual disk." && exit 85
fi
fi

if [[ "${ALLOCATE}" == [Zz]* ]]; then
Expand Down Expand Up @@ -84,7 +88,10 @@ if [ ! -f "${DATA}" ]; then
if [[ "${ALLOCATE}" == [Nn]* ]]; then

# Create an empty file
truncate -s "${DATA_SIZE}" "${DATA}"
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
rm -f "${DATA}"
error "Could not create a file for the virtual disk." && exit 87
fi

else

Expand All @@ -98,8 +105,10 @@ if [ ! -f "${DATA}" ]; then

# Create an empty file
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
rm -f "${DATA}"
error "Could not allocate a file for the virtual disk." && exit 87
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
rm -f "${DATA}"
error "Could not create a file for the virtual disk." && exit 87
fi
fi

if [[ "${ALLOCATE}" == [Zz]* ]]; then
Expand Down

0 comments on commit d1957f5

Please sign in to comment.