lkml.org 
[lkml]   [2019]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[PATCH 0/1] udf: Incorrect final NOT_ALLOCATED (hole) extent length
Date
The following script reveals some errors in the final
NOT_RECORDED_NOT_ALLOCATED extent of a file following use of truncate(1)
to extend the file by adding or manipulating a hole at the end.

The script produces the following output:

Now testing NOT ALLOCATED extent.
Testing 0 --> 300 : FAILED - bad extent type/length: expected 8000012C, actual 80000200
Testing 300 --> 301 : PASSED
Testing 301 --> 302 : FAILED - bad extent type/length: expected 8000012E, actual 8000012D
Testing 302 --> 511 : FAILED - bad extent type/length: expected 800001FF, actual 8000012D
Testing 511 --> 512 : FAILED - bad extent type/length: expected 80000200, actual 8000012D
Testing 512 --> 513 : FAILED - bad extent type/length: expected 80000201, actual 80000400
Testing 513 --> 514 : PASSED
Testing 514 --> 1023 : FAILED - bad extent type/length: expected 800003FF, actual 80000202
Testing 1023 --> 1024 : FAILED - bad extent type/length: expected 80000400, actual 80000202
Testing 1024 --> 1026 : FAILED - bad extent type/length: expected 80000402, actual 80000600
Testing 1026 --> 1538 : FAILED - bad extent type/length: expected 80000602, actual 80000800
Testing 1538 --> 4096 : PASSED
Testing 4096 --> 0 : PASSED
Testing 0 --> 4096 : PASSED
Testing 4096 --> 0 : PASSED
Testing 0 --> 4097 : FAILED - bad extent type/length: expected 80001001, actual 80001200
Testing 4097 --> 0 : PASSED

Now testing RECORDED extent.
Testing 512 --> 512 : PASSED
Testing 512 --> 511 : PASSED
Testing 511 --> 300 : PASSED
Testing 300 --> 512 : FAILED - bad extent type/length: expected 00000200, actual 0000012C

Now testing NOT ALLOCATED beyond RECORDED.
Testing 512 --> 513 : FAILED - bad extent type/length: expected 00000200 80000001, actual 00000200 80000200
Testing 513 --> 512 : PASSED
Testing 512 --> 300 : PASSED
Testing 300 --> 513 : FAILED - bad extent type/length: expected 00000200 80000001, actual 00000200 80000200
Testing 513 --> 300 : PASSED
Testing 300 --> 1538 : FAILED - bad extent type/length: expected 00000200 80000402, actual 00000200 80000600
Testing 1538 --> 0 : PASSED

Now testing multiple NOT ALLOCATED.
Testing 0 --> 1073741312 : PASSED
Testing 1073741312 --> 0 : PASSED
Testing 0 --> 1073741313 : FAILED - bad extent type/length: expected BFFFFE00 80000001, actual BFFFFE00 80000200
Testing 1073741313 --> 0 : PASSED
Testing 0 --> 1073741824 : PASSED

#!/bin/bash

FS_SIZE=256K
FS_FILE=/tmp/test.udf
MNT=/mnt
ICB_LSN=261
XXD=/usr/bin/xxd

truncate_test()
{
local prev_size=`ls -l ${MNT}/truncate.test | cut -d' ' -f5`
printf "Testing %4u --> %4u : " $prev_size $1
truncate --size=$1 ${MNT}/truncate.test
sync
local new_size=`ls -l ${MNT}/truncate.test | cut -d' ' -f5`

if [ $new_size -ne $1 ] ; then
echo FAILED - bad information length
else
local ext_type_and_len=`dd if=${FS_FILE} skip=${ICB_LSN} count=1 2> /dev/null | dd bs=1 skip=216 count=4 2> /dev/null | ${XXD} -g4 -e -u | cut -c11-18`
if [ "$ext_type_and_len" = "$2" ] ; then
if [ -z "$3" ] ; then
echo PASSED
else
ext_type_and_len=`dd if=${FS_FILE} skip=${ICB_LSN} count=1 2> /dev/null | dd bs=1 skip=232 count=4 2> /dev/null | ${XXD} -g4 -e -u | cut -c11-18`
if [ "$ext_type_and_len" = "$3" ] ; then
echo PASSED
else
echo FAILED - bad extent type/length: expected $2 $3, actual $2 $ext_type_and_len
fi
fi
else
echo FAILED - bad extent type/length: expected $2, actual $ext_type_and_len
fi
fi
}


### MAIN

rm -f $FS_FILE

truncate --size=${FS_SIZE} $FS_FILE
mkudffs --label=TRUNCATE --media-type=hd --uid=1000 --gid=1000 $FS_FILE > /dev/null
echo -n Mounting test filesystem...
sudo mount $FS_FILE $MNT -o loop
echo
touch ${MNT}/truncate.test

echo
echo Now testing NOT ALLOCATED extent.
truncate_test 300 8000012C
truncate_test 301 8000012D
truncate_test 302 8000012E
truncate_test 511 800001FF
truncate_test 512 80000200
truncate_test 513 80000201
truncate_test 514 80000202
truncate_test 1023 800003FF
truncate_test 1024 80000400
truncate_test 1026 80000402
truncate_test 1538 80000602
truncate_test 4096 80001000
truncate_test 0 00000000
truncate_test 4096 80001000
truncate_test 0 00000000
truncate_test 4097 80001001
truncate_test 0 00000000

dd if=/dev/zero of=${MNT}/truncate.test bs=512 count=1 2> /dev/null
echo
echo Now testing RECORDED extent.
truncate_test 512 00000200
truncate_test 511 000001FF
truncate_test 300 0000012C
truncate_test 512 00000200
echo
echo Now testing NOT ALLOCATED beyond RECORDED.
truncate_test 513 00000200 80000001
truncate_test 512 00000200 00000000
truncate_test 300 0000012C
truncate_test 513 00000200 80000001
truncate_test 300 0000012C 00000000
truncate_test 1538 00000200 80000402
truncate_test 0 00000000

echo
echo Now testing multiple NOT ALLOCATED.
truncate_test 1073741312 BFFFFE00
truncate_test 0 00000000
truncate_test 1073741313 BFFFFE00 80000001
truncate_test 0 00000000
truncate_test 1073741824 BFFFFE00 80000200

sudo umount $FS_FILE

------------------------------------------------------------------------
Steven J. Magnani "I claim this network for MARS!
www.digidescorp.com Earthling, return my space modulator!"

#include <standard.disclaimer>

\
 
 \ /
  Last update: 2019-06-04 14:32    [W:0.068 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site