public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/scripts fsadm.sh
@ 2010-10-08 11:18 zkabelac
  0 siblings, 0 replies; 5+ messages in thread
From: zkabelac @ 2010-10-08 11:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-10-08 11:18:29

Modified files:
	scripts        : fsadm.sh 

Log message:
	Replace  "can not" with "cannot"

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.12&r2=1.13

--- LVM2/scripts/fsadm.sh	2010/05/14 11:33:21	1.12
+++ LVM2/scripts/fsadm.sh	2010/10/08 11:18:29	1.13
@@ -227,7 +227,7 @@
 
 try_umount() {
 	yes_no "Do you want to unmount \"$MOUNTED\"" && dry $UMOUNT "$MOUNTED" && return 0
-	error "Can not proceed with mounted filesystem \"$MOUNTED\""
+	error "Cannot proceed with mounted filesystem \"$MOUNTED\""
 }
 
 validate_parsing() {
@@ -289,7 +289,7 @@
 ########################
 # Resize XFS filesystem
 # - mounted for upsize
-# - can not downsize
+# - cannot downsize
 ########################
 resize_xfs() {
 	detect_mounted
@@ -345,7 +345,7 @@
 ###################
 check() {
 	detect_fs "$1"
-	detect_mounted && error "Can not fsck device \"$VOLUME\", filesystem mounted on $MOUNTED"
+	detect_mounted && error "Cannot fsck device \"$VOLUME\", filesystem is mounted on $MOUNTED"
 	case "$FSTYPE" in
 	  "xfs") dry $XFS_CHECK "$VOLUME" ;;
 	  *) dry $FSCK $YES "$VOLUME" ;;


^ permalink raw reply	[flat|nested] 5+ messages in thread

* LVM2/scripts fsadm.sh
@ 2010-11-11 12:17 zkabelac
  0 siblings, 0 replies; 5+ messages in thread
From: zkabelac @ 2010-11-11 12:17 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-11-11 12:17:15

Modified files:
	scripts        : fsadm.sh 

Log message:
	Add date configurable variable DATE
	
	Follow the rule to run every command through variable dereference.
	Add a runtime check of translated date to seconds.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.23&r2=1.24

--- LVM2/scripts/fsadm.sh	2010/11/10 16:14:03	1.23
+++ LVM2/scripts/fsadm.sh	2010/11/11 12:17:15	1.24
@@ -47,6 +47,7 @@
 RMDIR=rmdir
 BLOCKDEV=blockdev
 BLKID=blkid
+DATE=date
 GREP=grep
 READLINK=readlink
 READLINK_E="-e"
@@ -386,7 +387,7 @@
 #  only one supported
 ####################################
 diff_dates() {
-         echo $(( $(date -u -d"$1" +%s 2>/dev/null) - $(date -u -d"$2" +%s 2>/dev/null) ))
+         echo $(( $($DATE -u -d"$1" +%s 2>/dev/null) - $($DATE -u -d"$2" +%s 2>/dev/null) ))
 }
 
 ###################
@@ -445,7 +446,7 @@
 test -n "$TUNE_EXT" -a -n "$RESIZE_EXT" -a -n "$TUNE_REISER" -a -n "$RESIZE_REISER" \
   -a -n "$TUNE_XFS" -a -n "$RESIZE_XFS" -a -n "$MOUNT" -a -n "$UMOUNT" -a -n "$MKDIR" \
   -a -n "$RMDIR" -a -n "$BLOCKDEV" -a -n "$BLKID" -a -n "$GREP" -a -n "$READLINK" \
-  -a -n "$FSCK" -a -n "$XFS_CHECK" -a -n "LVM" \
+  -a -n "$DATE" -a -n "$FSCK" -a -n "$XFS_CHECK" -a -n "LVM" \
   || error "Required command definitions in the script are missing!"
 
 $LVM version >/dev/null 2>&1 || error "Could not run lvm binary '$LVM'"
@@ -453,6 +454,7 @@
 TEST64BIT=$(( 1000 * 1000000000000 ))
 test $TEST64BIT -eq 1000000000000000 || error "Shell does not handle 64bit arithmetic"
 $(echo Y | $GREP Y >/dev/null) || error "Grep does not work properly"
+test $($DATE -u -d"Jan 01 00:00:01 1970" +%s) -eq 1 || error "Date translation does not work"
 
 
 if [ "$#" -eq 0 ] ; then


^ permalink raw reply	[flat|nested] 5+ messages in thread

* LVM2/scripts fsadm.sh
@ 2010-11-10 10:03 zkabelac
  0 siblings, 0 replies; 5+ messages in thread
From: zkabelac @ 2010-11-10 10:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-11-10 10:03:07

Modified files:
	scripts        : fsadm.sh 

Log message:
	Scan also 'mount' output for mounted filesystem.
	
	As util-linux package seems to give all the time different names,
	try harder to figure out, where is the given lv possible mounted
	and scan /proc/mounts and if not found there, test also 'mount' output.
	
	/dev/dm-xxx
	/dev/mapper/vg-lv
	/dev/vg/lv
	
	All of them could be used different combination in /proc/mount and mount output.
	
	Patch fixes regression for older systems where new detection code failed to
	find valid combination.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.21&r2=1.22

--- LVM2/scripts/fsadm.sh	2010/11/01 14:08:52	1.21
+++ LVM2/scripts/fsadm.sh	2010/11/10 10:03:07	1.22
@@ -199,6 +199,10 @@
 	# for empty string try again with real volume name
 	test -z "$MOUNTED" && MOUNTED=$($GREP ^"$RVOLUME" $PROCMOUNTS)
 
+	# for systems with different device names - check also mount output
+	test -z "$MOUNTED" && MOUNTED=$($MOUNT | $GREP ^"$VOLUME")
+	test -z "$MOUNTED" && MOUNTED=$($MOUNT | $GREP ^"$RVOLUME")
+
 	# cut device name prefix and trim everything past mountpoint
 	# echo translates \040 to spaces
 	MOUNTED=${MOUNTED#* }


^ permalink raw reply	[flat|nested] 5+ messages in thread

* LVM2/scripts fsadm.sh
@ 2008-01-08 16:45 zkabelac
  0 siblings, 0 replies; 5+ messages in thread
From: zkabelac @ 2008-01-08 16:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2008-01-08 16:45:43

Modified files:
	scripts        : fsadm.sh 

Log message:
	added more safety checks
	fixed error reporting commands
	extended with Exa and Peta support

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4

--- LVM2/scripts/fsadm.sh	2007/12/20 15:42:55	1.3
+++ LVM2/scripts/fsadm.sh	2008/01/08 16:45:43	1.4
@@ -12,7 +12,7 @@
 # along with this program; if not, write to the Free Software Foundation,
 # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
-# Author: Zdenek Kabelac <zkabelac@redhat.com>
+# Author: Zdenek Kabelac <zkabelac at redhat.com>
 #
 # Script for resizing devices (usable for LVM resize)
 #
@@ -39,9 +39,9 @@
 MOUNT=mount
 UMOUNT=umount
 MKDIR=mkdir
-RM=rm
-BLOCKDEV=echo 
-BLKID=echo
+RMDIR=rmdir
+BLOCKDEV=blockdev
+BLKID=blkid
 GREP=grep
 READLINK=readlink
 FSCK=fsck
@@ -69,7 +69,7 @@
 	echo "  ${TOOL} [options] check device"
 	echo "    - Check the filesystem on device using fsck"
 	echo
-	echo "  ${TOOL} [options] resize device [new_size[BKMGT]]"
+	echo "  ${TOOL} [options] resize device [new_size[BKMGTPE]]"
 	echo "    - Change the size of the filesystem on device to new_size"
 	echo
 	echo "  Options:"
@@ -97,8 +97,11 @@
 }
 
 dry() {
+	if [ "$DRY" -ne 0 ]; then
+		verbose "Dry execution $@"
+		return 0
+	fi
 	verbose "Executing $@"
-	test "$DRY" -ne 0 && return 0
 	$@
 }
 
@@ -115,10 +118,12 @@
 	exit $1
 }
 
-# convert parameters from Mega/Kilo/Bytes/Blocks
-# and print number of bytes
+# convert parameter from Exa/Peta/Tera/Giga/Mega/Kilo/Bytes and blocks
+# (2^(60/50/40/30/20/10/0))
 decode_size() {
 	case "$1" in
+	 *[eE]) NEWSIZE=$(( ${1%[eE]} * 1152921504606846976 )) ;;
+	 *[pP]) NEWSIZE=$(( ${1%[pP]} * 1125899906842624 )) ;;
 	 *[tT]) NEWSIZE=$(( ${1%[tT]} * 1099511627776 )) ;;
 	 *[gG]) NEWSIZE=$(( ${1%[gG]} * 1073741824 )) ;;
 	 *[mM]) NEWSIZE=$(( ${1%[mM]} * 1048576 )) ;;
@@ -133,14 +138,15 @@
 # detect filesystem on the given device
 # dereference device name if it is symbolic link
 detect_fs() {
-	VOLUME=$($READLINK -n "$1")
+	VOLUME=$($READLINK -e -n "$1") || error "Cannot get readlink $1"
 	# use /dev/null as cache file to be sure about the result
-	FSTYPE=$($BLKID -c /dev/null -o value -s TYPE "$VOLUME" || error "Cannot get FSTYPE of \"$VOLUME\"")
+	FSTYPE=$($BLKID -c /dev/null -o value -s TYPE "$VOLUME") || error "Cannot get FSTYPE of \"$VOLUME\""
 	verbose "\"$FSTYPE\" filesystem found on \"$VOLUME\""
 }
 
 # check if the given device is already mounted and where
 detect_mounted()  {
+	$MOUNT >/dev/null || error "Cannot detect mounted device $VOLUME"
 	MOUNTED=$($MOUNT | $GREP "$VOLUME")
 	MOUNTED=${MOUNTED##* on }
 	MOUNTED=${MOUNTED% type *} # allow type in the mount name
@@ -165,7 +171,9 @@
 }
 
 temp_umount() {
-	dry $UMOUNT "$TEMPDIR" && dry $RM -r "${TEMPDIR%%m}" || error "Failed to umount $TEMPDIR"
+	dry $UMOUNT "$TEMPDIR" || error "Failed to umount $TEMPDIR"
+	dry $RMDIR "${TEMPDIR}" || error "Failed to remove $TEMPDIR"
+	dry $RMDIR "${TEMPDIR%%m}" || error "Failed to remove ${TEMPDIR%%m}"
 }
 
 yes_no() {
@@ -207,7 +215,7 @@
 	decode_size $1 $BLOCKSIZE
 	FSFORCE=$FORCE
 
-	if [ $NEWBLOCKCOUNT -lt $BLOCKCOUNT -o $EXTOFF -eq 1 ]; then
+	if [ "$NEWBLOCKCOUNT" -lt "$BLOCKCOUNT" -o "$EXTOFF" -eq 1 ]; then
 		detect_mounted && verbose "$RESIZE_EXT needs unmounted filesystem" && try_umount
 		REMOUNT=$MOUNTED
 		# CHECKME: after umount resize2fs requires fsck or -f flag.
@@ -288,7 +296,7 @@
 	verbose "Device \"$VOLUME\" has $DEVSIZE bytes"
 	# if the size parameter is missing use device size
 	NEWSIZE=$2
-	test -z $NEWSIZE && NEWSIZE=${DEVSIZE}b
+	test -z "$NEWSIZE" && NEWSIZE=${DEVSIZE}b
 	trap cleanup 2
 	#IFS=$'\n'  # don't use bash-ism ??
 	IFS="$(printf \"\\n\")"  # needed for parsing output
@@ -316,6 +324,18 @@
 # start point of this script
 # - parsing parameters
 #############################
+
+# test some prerequisities
+test -n "$TUNE_EXT" -a -n "$RESIZE_EXT" -a -n "$TUNE_REISER" -a -n "$RESIZE_REISER" \
+  -a -n "$TUNE_XFS" -a -n "$RESIZE_XFS" -a -n "$MOUNT" -a -n "$UMOUNT" -a -n "$MKDIR" \
+  -a -n "$RMDIR" -a -n "$BLOCKDEV" -a -n "$BLKID" -a -n "$GREP" -a -n "$READLINK" \
+  -a -n "$FSCK" -a -n "$XFS_CHECK" || error "Required command definitions in the script are missing!"
+$($READLINK -e -n / >/dev/null 2>&1) || error "$READLINK does not support options -e -n"
+TEST64BIT=$(( 1000 * 1000000000000 ))
+test $TEST64BIT -eq 1000000000000000 || error "Shell does not handle 64bit arithmetic"
+$(echo Y | $GREP Y >/dev/null) || error "Grep does not work properly"
+
+
 if [ "$1" = "" ] ; then
 	tool_usage
 fi


^ permalink raw reply	[flat|nested] 5+ messages in thread

* LVM2/scripts fsadm.sh
@ 2007-12-17 14:47 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-12-17 14:47 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-12-17 14:47:24

Modified files:
	scripts        : fsadm.sh 

Log message:
	tweak usage text

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2

--- LVM2/scripts/fsadm.sh	2007/12/17 12:31:50	1.1
+++ LVM2/scripts/fsadm.sh	2007/12/17 14:47:22	1.2
@@ -64,24 +64,26 @@
 IFS_OLD=$IFS
 
 tool_usage() {
-	echo "${TOOL}: Utility to resize underlying filesystem"
-	echo "Usage:"
-	echo "  ${TOOL} [options] check|resize device [size]"
-	echo "    -h | --help		  show this help"
-	echo "    -v | --verbose	  be verbose"
-	echo "    -f | --force 	  forces to proceed"
-	echo "    -e | --ext-offline 	  unmount filesystem before Ext2/3 resize"
-	echo "    -n | --dry-run	  print commands rather than running them"
-	echo "    -y | --yes		  answer \"yes\" to automatically proceed"
-	echo "    check		  run fsck"
-	echo "    resize		  resize given device to new size"
-	echo "    size 		  in filesystem blocks"
-	echo " 			  add B to specify Bytes (i.e.: 1000000B)"
-	echo " 			  add K to specify KiloBytes (1024B)"
-	echo " 			  add M to specify MegaBytes (1024KB)"
-	echo " 			  add G to specify GigaBytes (1024MB)"
-	echo " 			  add T to specify TeraBytes (1024GB)"
-	echo " 			  (if unspecified full device is used)"
+	echo "${TOOL}: Utility to resize or check the filesystem on a device"
+	echo
+	echo "  ${TOOL} [options] check device"
+	echo "    - Check the filesystem on device using fsck"
+	echo
+	echo "  ${TOOL} [options] resize device [new_size[BKMGT]]"
+	echo "    - Change the size of the filesystem on device to new_size"
+	echo
+	echo "  Options:"
+	echo "    -h | --help         Show this help message"
+	echo "    -v | --verbose      Be verbose"
+	echo "    -e | --ext-offline  unmount filesystem before Ext2/3 resize"
+	echo "    -f | --force        Bypass sanity checks"
+	echo "    -n | --dry-run      Print commands without running them"
+	echo "    -y | --yes          Answer \"yes\" at any prompts"
+	echo
+	echo "  new_size - Absolute number of filesystem blocks to be in the filesystem,"
+	echo "             or an absolute size using a suffix (in powers of 1024)."
+	echo "             If new_size is not supplied, the whole device is used."
+
 	exit
 }
 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-11-11 12:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-08 11:18 LVM2/scripts fsadm.sh zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2010-11-11 12:17 zkabelac
2010-11-10 10:03 zkabelac
2008-01-08 16:45 zkabelac
2007-12-17 14:47 agk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).