whiteout file utilities - 'lswhiteout' and 'rmdeadwhiteout'

Miscellaneous tools
Post Reply
Message
Author
gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

whiteout file utilities - 'lswhiteout' and 'rmdeadwhiteout'

#1 Post by gyro »

Here are a couple of scripts to help with whiteout files:

Edit: Uploaded new version of scripts. Changed output format to cope better with long lines (mavrothal ). See post below.

1) 'lswhiteout'
This script lists all ordinary ".wh." files, along with the file they cover (if it exists), and the layer in which the hidden file was found.
Example output:

Code: Select all

# ./lswhiteout
Whiteout files in  /initrd/mnt/dev_save/puppy/tahr/tahrsave
/.wh.pinstall.sh
    covers  /pinstall.sh
    in  devx_tahr_6.0.2.sfs
It accepts a "-q" parameter which suppresses the heading line(s).

Code: Select all

# ./lswhiteout -q
/.wh.pinstall.sh
    covers  /pinstall.sh
    in  devx_tahr_6.0.2.sfs
2) 'rmdeadwhiteout'
This is a clean-up script that removes all ordinary ".wh." files that don't cover any file in a lower layer. So they don't actually do anything in the current system, but can cause problems in the future if the file they are supposed to cover gets re-introduced into a lower layer.
Example output:

Code: Select all

# ./rmdeadwhiteout
Searching whiteout files...
/root/.wh.zxzx.txt
    removed from  /initrd/mnt/dev_save/puppy/tahr/tahrsave
It accepts a "-q" parameter which suppresses all output.

Note: Both these scripts contain a 'find' command which can take a while to complete, so they each output a header line before the 'find' starts, to reassure the user that the script is functioning.

To use:
Dwonload the appropriate ".gz" file and move it to the directory you want to contain the utility.
Then gunzip the downloaded file.

gyro
Attachments
lswhiteout.gz
gunzip to produce the script file
(904 Bytes) Downloaded 192 times
rmdeadwhiteout.gz
gunzip to produce the script file
(819 Bytes) Downloaded 206 times
Last edited by gyro on Tue 21 Apr 2015, 10:24, edited 2 times in total.

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#2 Post by mavrothal »

Very handy!
You might want to consider these changes

Code: Select all

--- a/lswhiteout	2015-04-21
+++ b/lswhiteout	2015-04-21
@@ -45,15 +45,15 @@
 					[ "${BP: -3}" = "sfs" ] && BP="${BP##*/}"
 				fi
 				if [ $BP ]; then
-					echo "\"${W:1}\" covers \"${D:1}/${B:4}\" in \"${BP}\""
+					echo -e "\"${W:1}\" \n  covers \"${D:1}/${B:4}\" \n  in \"${BP}\"\n" >> /tmp/whiteouts
 				else
-					echo "\"${W:1}\" covers \"${D:1}/${B:4}\" in \"${BD}\""
+					echo -e "\"${W:1}\" \n  covers \"${D:1}/${B:4}\" \n  in \"${BD}\"\n" >> /tmp/whiteouts
 				fi
 				break
 			fi
 		done
 		if [ "$XFFND" != "yes" ]; then
-			echo "\"${W:1}\" covers nothing."
+			echo -e "\"${W:1}\" covers nothing.\n" >> /tmp/whiteouts
 		fi
 	done 
 	# return delimiter to previous value
@@ -83,4 +83,8 @@
 	check_branch
 fi
 
+[ -f /tmp/whiteouts ] && nohup defaulttextviewer /tmp/whiteouts &
+sleep 0.5
+rm -f /tmp/whiteouts 2>/dev/null
+
 exit

Code: Select all

--- a/rmdeadwhiteout	2015-04-21
+++ b/rmdeadwhiteout	2015-04-21
@@ -40,7 +40,8 @@
 		if [ "$XFFND" != "yes" ]; then
 			rm -f "$W"
 			XFDEL="yes"
-			[ "$XQU" != "yes" ] && echo "\"${W:1}\" removed from \"${BASEDIR}\"."
+			[ "$XQU" != "yes" ] && echo -e "\"${W:1}\" removed from \n \"${BASEDIR}\".\n" \
+			 >> /tmp/removed_whiteouts
 		fi
 	done 
 	# return delimiter to previous value
@@ -74,4 +75,8 @@
 	check_branch
 fi
 
+[ -f /tmp/removed_whiteouts ] && nohup defaulttextviewer /tmp/removed_whiteouts &
+sleep 0.5
+rm -f /tmp/removed_whiteouts 2>/dev/null
+
 exit
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#3 Post by gyro »

mavrothal wrote:Very handy!
You might want to consider these changes
Thanks.
I've incorporated the idea of breaking up the long lines. But I still just write to standard output.

The previous single line of output is broken into several lines with subsequent lines for the same whiteout file being indented.
Also removed quotes, file names now continue until the end of the current line.

New versions of scripts available from first post.

gyro

Post Reply