[DRBD-cvs] scripts by lars; datadisk does not check for TERMINAL; no...

drbd-user@lists.linbit.com drbd-user@lists.linbit.com
Tue, 6 Apr 2004 20:52:10 +0200 (CEST)


DRBD CVS committal

Author  : lars
Project : drbd
Module  : scripts

Dir     : drbd/scripts


Modified Files:
	drbd 


Log Message:
datadisk does not check for TERMINAL; no more use of blockdev
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/scripts/drbd,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -3 -r1.55 -r1.56
--- drbd	4 Mar 2004 07:38:18 -0000	1.55
+++ drbd	6 Apr 2004 18:52:04 -0000	1.56
@@ -62,7 +62,7 @@
 #
 # shouldn't there be more descriptive comments? ;)
 #
-CVSID='$Id: drbd,v 1.55 2004/03/04 07:38:18 lars Exp $'
+CVSID='$Id: drbd,v 1.56 2004/04/06 18:52:04 lars Exp $'
 CONTACT='Lars Ellenberg <l.g.e@web.de>, drbd-user@lists.linbit.com'
 
 ##################################################}}}1
@@ -168,20 +168,6 @@
 fi
 USLEEP="sleep 1"
 
-# QQQ thought this could be useful
-# TERMINAL=/dev/tty
-# maybe we can use $CONSOLE, which should be exported by init anyways?
-#
-for TERMINAL in /proc/$$/fd/0 /dev/tty /dev/console ""
-do
-   [ -z "$TERMINAL" ] && break
-   ( [ -t 1 ] < $TERMINAL &> $TERMINAL ) 2>/dev/null && break
-done
-if [ -z "$TERMINAL" ] ; then
-	$LOGERR "FATAL: no terminal"
-	exit -1
-fi
-
 
 # frame work for commandline options part I {{{2
 # I use getopt, if it is in PATH. if getopt is not found, it will
@@ -1071,7 +1057,6 @@
 # underlying block device
 {
 	local size_in_kB conf_disk_size unit
-	local size_in_sectors sector_size_in_byte
 	trace "for $res on $host"
 	local disk
 	fetch CONF "$res:on $host:disk"; disk=$RET_VAL
@@ -1080,21 +1065,13 @@
 	else
 		store -new Disk "$disk" "$res($host)"
 		# check the device size
-		if ! size_in_sectors=$(blockdev --getsize $disk) ; then
+		if ! size_in_kB=$(fdisk -s $disk) ; then
 			echo "$link: warning: could not get size of $disk"
 return
-		else if [ $size_in_sectors == 0 ] ; then
+		elif [ $size_in_kB == 0 ] ; then
 			echo "$link: warning $disk has zero size?"
 return
-		fi; fi
-		if ! sector_size_in_byte=$(blockdev --getss $disk) ; then
-			echo "$link: warning: could not get sector size of $disk, assuming 512"
-			sector_size_in_byte=512
 		fi
-		multiply "$size_in_sectors" by "$sector_size_in_byte"
-		# now byte -> kB
-		divide "$RET_VAL" by 1024
-		size_in_kB=$RET_VAL
 
 		fetch CONF "$res:disk"
 		set -- $RET_VAL
@@ -2139,6 +2116,20 @@
 case $link in
 
 drbd)
+	# QQQ thought this could be useful
+	# TERMINAL=/dev/tty
+	# maybe we can use $CONSOLE, which should be exported by init anyways?
+	#
+	for TERMINAL in /proc/$$/fd/0 /dev/tty /dev/console ""
+	do
+	   [ -z "$TERMINAL" ] && break
+	   ( [ -t 1 ] < $TERMINAL &> $TERMINAL ) 2>/dev/null && break
+	done
+	if [ -z "$TERMINAL" ] ; then
+		$LOGERR "FATAL: no terminal"
+		exit -1
+	fi
+
 	case $COMMAND in
 	checkconfig|$OPT_CHECK_ONLY) # {{{1
 		# on VERBOSITY level >= 2 this is done above already.