Blame SOURCES/0030-tests-t3000-resize-fs.sh-Add-very-deep-directory.patch

7fd79c
From 599ce25c802fc1154ed619fde4249bb381430407 Mon Sep 17 00:00:00 2001
7fd79c
From: Mike Fleetwood <mike.fleetwood@googlemail.com>
7fd79c
Date: Sun, 28 Feb 2016 15:36:11 +0000
7fd79c
Subject: [PATCH 30/30] tests: t3000-resize-fs.sh: Add very deep directory
7fd79c
7fd79c
Create 500 deep directory tree, with longest name of 4000 characters, to
7fd79c
the file system being resized to test the fix to prevent crash when
7fd79c
resizing a FAT file system with such a long path.
7fd79c
---
7fd79c
 tests/t3000-resize-fs.sh | 16 ++++++++++++++++
7fd79c
 1 file changed, 16 insertions(+)
7fd79c
7fd79c
diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh
7fd79c
index a79a307..608871c 100755
7fd79c
--- a/tests/t3000-resize-fs.sh
7fd79c
+++ b/tests/t3000-resize-fs.sh
7fd79c
@@ -46,6 +46,13 @@ device_sectors_required=$(echo $default_end | sed 's/s$//')
7fd79c
 # Ensure that $dev is large enough for this test
7fd79c
 test $device_sectors_required -le $dev_n_sectors || fail=1
7fd79c
 
7fd79c
+# create mount point dir
7fd79c
+mount_point="`pwd`/mnt"
7fd79c
+mkdir "$mount_point" || fail=1
7fd79c
+
7fd79c
+# be sure to unmount upon interrupt, failure, etc.
7fd79c
+cleanup_fn_() { umount "${dev}1" > /dev/null 2>&1; }
7fd79c
+
7fd79c
 for fs_type in hfs+ fat32 fat16; do
7fd79c
   echo "fs_type=$fs_type"
7fd79c
 
7fd79c
@@ -69,6 +76,15 @@ for fs_type in hfs+ fat32 fat16; do
7fd79c
   # create the file system
7fd79c
   $mkfs_cmd ${dev}1 || fail=1
7fd79c
 
7fd79c
+  # create 500 deep directory tree with longest name 4000 characters
7fd79c
+  # to catch core dump in libparted/fs/r/fat/count.c flag_traverse_dir()
7fd79c
+  # overflowing 512 byte file_name local buffer.
7fd79c
+  mount "${dev}1" "$mount_point" || fail=1
7fd79c
+  cat /dev/null > exp
7fd79c
+  ( cd "$mount_point"; for d in `seq 500`; do mkdir TESTDIR; cd TESTDIR; done ) > out
7fd79c
+  compare exp out || fail=1   # Ensure no errors creating directory tree
7fd79c
+  umount "${dev}1" || fail=1
7fd79c
+
7fd79c
   # NOTE: shrinking is the only type of resizing that works.
7fd79c
   # resize that file system to be one cylinder (8MiB) smaller
7fd79c
   fs-resize ${dev}1 0 $new_end > out 2>&1 || fail=1
7fd79c
-- 
7fd79c
2.5.0
7fd79c