[PATCH] Fancy rc startup style RFC

2006-04-18 Thread Eric Anderson

Hi everyone!

I've made a patch to /etc/rc.subr that makes the startup/shutdown rc 
scripting look similar to other OS's (many different linux distros, 
HP-UX, etc), but without color.


The patch shouldn't break anything, and is only enabled if you have this 
in your /etc/rc.conf:


rc_fancy=YES

Several of the /etc/rc.d/* scripts send output to stdout, so that could 
be cleaned up a bit if needed, but for now I tried to keep the patch as 
minimal as possible.


This is still a first pass, so please give feedback.

The patch can be grabbed from here:

http://www.googlebit.com/freebsd/patches/rc_fancy.patch


Enjoy!
Eric



--

Eric AndersonSr. Systems AdministratorCentaur Technology
Anything that works is better than anything that doesn't.

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Gordon Bergling
Hi,

* Thus spake Eric Anderson ([EMAIL PROTECTED]):
 I've made a patch to /etc/rc.subr that makes the startup/shutdown rc 
 scripting look similar to other OS's (many different linux distros, 
 HP-UX, etc), but without color.
 
 The patch shouldn't break anything, and is only enabled if you have this 
 in your /etc/rc.conf:
 
 rc_fancy=YES
 
 Several of the /etc/rc.d/* scripts send output to stdout, so that could 
 be cleaned up a bit if needed, but for now I tried to keep the patch as 
 minimal as possible.
 
 This is still a first pass, so please give feedback.

A short try on my notebook shows some errors.
I don't want to let this email getting too big, so I put the dmesg -a
output online. http://generic.0xfce3.net/dmesg-fancy.txt

BTW, the patch applied cleanly.

best regards,

Gordon
 
-- 
Gordon Bergling GBergling at 0xfce3.net http://www.0xFCE3.net/
PGP Fingerprint:  7732 9BB1 5013 AE8B E42C  28E0 93B9 D32B C76F 02A0
RIPE-HDL: MDTP-RIPE   Minimal Electronic Music
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Eric Anderson

Gordon Bergling wrote:

Hi,

* Thus spake Eric Anderson ([EMAIL PROTECTED]):
I've made a patch to /etc/rc.subr that makes the startup/shutdown rc 
scripting look similar to other OS's (many different linux distros, 
HP-UX, etc), but without color.


The patch shouldn't break anything, and is only enabled if you have this 
in your /etc/rc.conf:


rc_fancy=YES

Several of the /etc/rc.d/* scripts send output to stdout, so that could 
be cleaned up a bit if needed, but for now I tried to keep the patch as 
minimal as possible.


This is still a first pass, so please give feedback.


A short try on my notebook shows some errors.
I don't want to let this email getting too big, so I put the dmesg -a
output online. http://generic.0xfce3.net/dmesg-fancy.txt

BTW, the patch applied cleanly.



Thanks for the feedback!  Looks like I made an erroneous assumption that 
the wc, expr, and printf tools found in /usr/bin and /bin would be 
available through boot, but that isn't the case on systems with those 
file systems separate from /.  I'm not sure how to resolve some of these 
issues, since I don't know of a way to do those functions in csh without 
them.  I'm open to suggestions here from anyone.


Eric




--

Eric AndersonSr. Systems AdministratorCentaur Technology
Anything that works is better than anything that doesn't.

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Eric Anderson [EMAIL PROTECTED] writes:
: Gordon Bergling wrote:
:  Hi,
:  
:  * Thus spake Eric Anderson ([EMAIL PROTECTED]):
:  I've made a patch to /etc/rc.subr that makes the startup/shutdown rc 
:  scripting look similar to other OS's (many different linux distros, 
:  HP-UX, etc), but without color.
: 
:  The patch shouldn't break anything, and is only enabled if you have this 
:  in your /etc/rc.conf:
: 
:  rc_fancy=YES
: 
:  Several of the /etc/rc.d/* scripts send output to stdout, so that could 
:  be cleaned up a bit if needed, but for now I tried to keep the patch as 
:  minimal as possible.
: 
:  This is still a first pass, so please give feedback.
:  
:  A short try on my notebook shows some errors.
:  I don't want to let this email getting too big, so I put the dmesg -a
:  output online. http://generic.0xfce3.net/dmesg-fancy.txt
:  
:  BTW, the patch applied cleanly.
: 
: 
: Thanks for the feedback!  Looks like I made an erroneous assumption that 
: the wc, expr, and printf tools found in /usr/bin and /bin would be 
: available through boot, but that isn't the case on systems with those 
: file systems separate from /.  I'm not sure how to resolve some of these 
: issues, since I don't know of a way to do those functions in csh without 
: them.  I'm open to suggestions here from anyone.

/bin and /sbin are available through the entire boot.  Only things in
/usr are suspect because /usr gets mounted early in the boot process,
but not as early as /.

Warner
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Coleman Kane
On 4/18/06, M. Warner Losh [EMAIL PROTECTED] wrote:

 In message: [EMAIL PROTECTED]
 Eric Anderson [EMAIL PROTECTED] writes:
 : Gordon Bergling wrote:
 :  Hi,
 : 
 :  * Thus spake Eric Anderson ([EMAIL PROTECTED]):
 :  I've made a patch to /etc/rc.subr that makes the startup/shutdown rc
 :  scripting look similar to other OS's (many different linux distros,
 :  HP-UX, etc), but without color.
 : 
 :  The patch shouldn't break anything, and is only enabled if you have
 this
 :  in your /etc/rc.conf:
 : 
 :  rc_fancy=YES
 : 
 :  Several of the /etc/rc.d/* scripts send output to stdout, so that
 could
 :  be cleaned up a bit if needed, but for now I tried to keep the patch
 as
 :  minimal as possible.
 : 
 :  This is still a first pass, so please give feedback.
 : 
 :  A short try on my notebook shows some errors.
 :  I don't want to let this email getting too big, so I put the dmesg
 -a
 :  output online. http://generic.0xfce3.net/dmesg-fancy.txt
 : 
 :  BTW, the patch applied cleanly.
 :
 :
 : Thanks for the feedback!  Looks like I made an erroneous assumption that
 : the wc, expr, and printf tools found in /usr/bin and /bin would be
 : available through boot, but that isn't the case on systems with those
 : file systems separate from /.  I'm not sure how to resolve some of these
 : issues, since I don't know of a way to do those functions in csh without
 : them.  I'm open to suggestions here from anyone.

 /bin and /sbin are available through the entire boot.  Only things in
 /usr are suspect because /usr gets mounted early in the boot process,
 but not as early as /.

 Warner


Nice work!

I too noticed the dependence upon wc, printf, expr. I went ahead and rewrote
these into equivalents in native sh. (attaching new diff).

This diff is against the latest 7-CURRENT rc.subr. I had to manually merge 3
hunks due to some differences.

--
coleman kane
--- rc.subr.orig	Tue Apr 18 13:58:14 2006
+++ rc.subr	Tue Apr 18 13:57:36 2006
@@ -313,12 +313,16 @@
 			break
 		fi
 		_list=$_nlist
-		echo -n ${_prefix:-Waiting for PIDS: }$_list
+		if ! checkyesno rc_fancy; then
+			echo -n ${_prefix:-Waiting for PIDS: }$_list
+		fi
 		_prefix=, 
 		sleep 2
 	done
 	if [ -n $_prefix ]; then
-		echo .
+		if ! checkyesno rc_fancy; then
+			echo .
+		fi
 	fi
 }
 
@@ -564,12 +568,14 @@
 	# if the precmd failed and force
 	# isn't set, exit
 	#
+			rcargsize=`echo $rc_arg`
+			rcargsize=${#rcargsize}
 			if [ -n $_precmd ]; then
 debug run_rc_command: evaluating ${_precmd}().
 eval $_precmd $rc_extra_args
 _return=$?
 [ $_return -ne 0 ]  [ -z $rc_force ] 
-return 1
+(echo_fancy FAILED `expr 10 + $rcargsize - 1`)  return 1
 			fi
 
 			if [ -n $_cmd ]; then
@@ -577,7 +583,7 @@
 eval $_cmd $rc_extra_args
 _return=$?
 [ $_return -ne 0 ]  [ -z $rc_force ] 
-return 1
+(echo_fancy FAILED `expr 10 + $rcargsize - 1`)  return 1
 			fi
 
 			if [ -n $_postcmd ]; then
@@ -585,6 +591,7 @@
  eval $_postcmd $rc_extra_args
 _return=$?
 			fi
+			echo_fancy   OK   0
 			return $_return
 		fi
 
@@ -600,13 +607,16 @@
 			;;
 
 		start)
+ 			echo -n Starting ${name}
 			if [ -z $rc_fast -a -n $rc_pid ]; then
+ echo_fancy  SKIP  9
 echo 12 ${name} already running? (pid=$rc_pid).
 return 1
 			fi
 
 			if [ ! -x ${_chroot}${command} ]; then
 info run_rc_command: cannot run ($command).
+ echo_fancy ERROR  9
 return 1
 			fi
 
@@ -617,6 +627,7 @@
 if ! checkyesno $_f; then
 	warn \$${_f} is not enabled.
 	if [ -z $rc_force ]; then
+		echo_fancy ERROR  9
 		return 1
 	fi
 fi
@@ -625,6 +636,7 @@
 if [ ! -d ${_f}/. ]; then
 	warn ${_f} is not a directory.
 	if [ -z $rc_force ]; then
+		echo_fancy ERROR  9
 		return 1
 	fi
 fi
@@ -633,6 +645,7 @@
 if [ ! -r ${_f} ]; then
 	warn ${_f} is not readable.
 	if [ -z $rc_force ]; then
+		echo_fancy ERROR  9
 		return 1
 	fi
 fi
@@ -646,12 +659,11 @@
 eval $_precmd
 _return=$?
 [ $_return -ne 0 ]  [ -z $rc_force ] 
-return 1
+(echo_fancy ERROR  9)  return 1
 			fi
 
 	# setup the command to run, and run it
 	#
-			echo Starting ${name}.
 			if [ -n $_chroot ]; then
 _doit=\
 ${_nice:+nice -n $_nice }\
@@ -673,7 +685,7 @@
 			debug run_rc_command: _doit: $_doit
 			eval $_doit
 			_return=$?
-			[ $_return -ne 0 ]  [ -z $rc_force ]  return 1
+			[ $_return -ne 0 ]  [ -z $rc_force ]  (echo_fancy FAILED 9)  return 1
 
 	# finally, run postcmd
 	#
@@ -681,15 +693,19 @@
 debug run_rc_command: evaluating ${_postcmd}().
 eval $_postcmd
 			fi
+ 			echo_fancy   OK   9
 			;;
 
 		stop)
+ 			echo -n Stopping ${name}
 			if [ -z $rc_pid ]; then
 [ -n $rc_fast ]  return 0
 if [ -n $pidfile ]; then
+ 	echo_fancy  SKIP  9
 	echo 12 \
 ${name} not running? (check $pidfile).
 else
+ 	echo_fancy  SKIP  9
 	echo 12 ${name} not running?
 fi
 

Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Coleman Kane
On 4/18/06, Coleman Kane [EMAIL PROTECTED] wrote:

 On 4/18/06, M. Warner Losh [EMAIL PROTECTED] wrote:

  In message: [EMAIL PROTECTED]
  Eric Anderson [EMAIL PROTECTED] writes:
  :
  : Thanks for the feedback!  Looks like I made an erroneous assumption
  that
  : the wc, expr, and printf tools found in /usr/bin and /bin would be
  : available through boot, but that isn't the case on systems with those
  : file systems separate from /.  I'm not sure how to resolve some of
  these
  : issues, since I don't know of a way to do those functions in csh
  without
  : them.  I'm open to suggestions here from anyone.
 
  /bin and /sbin are available through the entire boot.  Only things in
  /usr are suspect because /usr gets mounted early in the boot process,
  but not as early as /.
 
  Warner


 Nice work!

 I too noticed the dependence upon wc, printf, expr. I went ahead and
 rewrote these into equivalents in native sh. (attaching new diff).

 This diff is against the latest 7-CURRENT rc.subr. I had to manually merge
 3 hunks due to some differences.

 --
 coleman kane


I did some ugly-looking loops to build the space-padding expansion. Does
anybody know of a better, more elegant way to accomplish the same thing with
sh (and/or stuff in /bin,/sbin)?


--
coleman
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Coleman Kane
On 4/18/06, Coleman Kane [EMAIL PROTECTED] wrote:

 On 4/18/06, M. Warner Losh [EMAIL PROTECTED] wrote:

  In message: [EMAIL PROTECTED]
  Eric Anderson [EMAIL PROTECTED] writes:
  : Gordon Bergling wrote:
  :  Hi,
  : 
  :  * Thus spake Eric Anderson ([EMAIL PROTECTED]):
  :  I've made a patch to /etc/rc.subr that makes the startup/shutdown
  rc
  :  scripting look similar to other OS's (many different linux distros,
 
  :  HP-UX, etc), but without color.
  : 
  :  The patch shouldn't break anything, and is only enabled if you have
  this
  :  in your /etc/rc.conf:
  : 
  :  rc_fancy=YES
  : 
  :  Several of the /etc/rc.d/* scripts send output to stdout, so that
  could
  :  be cleaned up a bit if needed, but for now I tried to keep the
  patch as
  :  minimal as possible.
  : 
  :  This is still a first pass, so please give feedback.
  : 
  :  A short try on my notebook shows some errors.
  :  I don't want to let this email getting too big, so I put the dmesg
  -a
  :  output online. http://generic.0xfce3.net/dmesg-fancy.txt
  : 
  :  BTW, the patch applied cleanly.
  :
  :
  : Thanks for the feedback!  Looks like I made an erroneous assumption
  that
  : the wc, expr, and printf tools found in /usr/bin and /bin would be
  : available through boot, but that isn't the case on systems with those
  : file systems separate from /.  I'm not sure how to resolve some of
  these
  : issues, since I don't know of a way to do those functions in csh
  without
  : them.  I'm open to suggestions here from anyone.


Also, /bin/sh is used to execute rc NOT /bin/csh. So you are writing in
Bourne shell and not C-Shell.

--
 coleman kane




___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Eric Anderson

Coleman Kane wrote:

On 4/18/06, *M. Warner Losh* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote:

In message: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
Eric Anderson [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] writes:
: Gordon Bergling wrote:
:  Hi,
: 
:  * Thus spake Eric Anderson ([EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]):
:  I've made a patch to /etc/rc.subr that makes the
startup/shutdown rc
:  scripting look similar to other OS's (many different linux
distros,
:  HP-UX, etc), but without color.
: 
:  The patch shouldn't break anything, and is only enabled if you
have this
:  in your /etc/rc.conf:
: 
:  rc_fancy=YES
: 
:  Several of the /etc/rc.d/* scripts send output to stdout, so
that could
:  be cleaned up a bit if needed, but for now I tried to keep the
patch as
:  minimal as possible.
: 
:  This is still a first pass, so please give feedback.
: 
:  A short try on my notebook shows some errors.
:  I don't want to let this email getting too big, so I put the
dmesg -a
:  output online. http://generic.0xfce3.net/dmesg-fancy.txt
: 
:  BTW, the patch applied cleanly.
:
:
: Thanks for the feedback!  Looks like I made an erroneous
assumption that
: the wc, expr, and printf tools found in /usr/bin and /bin would be
: available through boot, but that isn't the case on systems with those
: file systems separate from /.  I'm not sure how to resolve some of
these
: issues, since I don't know of a way to do those functions in csh
without
: them.  I'm open to suggestions here from anyone.

/bin and /sbin are available through the entire boot.  Only things in
/usr are suspect because /usr gets mounted early in the boot process,
but not as early as /.

Warner


Nice work!

I too noticed the dependence upon wc, printf, expr. I went ahead and 
rewrote these into equivalents in native sh. (attaching new diff).


This diff is against the latest 7-CURRENT rc.subr. I had to manually 
merge 3 hunks due to some differences.


Thanks!!  I've put the updated version (for 6-STABLE) here:

http://www.googlebit.com/freebsd/patches/rc_fancy.patch-2


Gordon - can you give this version a try?

Thanks,
Eric




--

Eric AndersonSr. Systems AdministratorCentaur Technology
Anything that works is better than anything that doesn't.

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Gordon Bergling
* Thus spake Eric Anderson ([EMAIL PROTECTED]):
 Coleman Kane wrote:
 On 4/18/06, *M. Warner Losh* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
 wrote:
 
 In message: [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]
 Eric Anderson [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] writes:
 : Gordon Bergling wrote:
 :  Hi,
 : 
 :  * Thus spake Eric Anderson ([EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]):
 :  I've made a patch to /etc/rc.subr that makes the
 startup/shutdown rc
 :  scripting look similar to other OS's (many different linux
 distros,
 :  HP-UX, etc), but without color.
 : 
 :  The patch shouldn't break anything, and is only enabled if you
 have this
 :  in your /etc/rc.conf:
 : 
 :  rc_fancy=YES
 : 
 :  Several of the /etc/rc.d/* scripts send output to stdout, so
 that could
 :  be cleaned up a bit if needed, but for now I tried to keep the
 patch as
 :  minimal as possible.
 : 
 :  This is still a first pass, so please give feedback.
 : 
 :  A short try on my notebook shows some errors.
 :  I don't want to let this email getting too big, so I put the
 dmesg -a
 :  output online. http://generic.0xfce3.net/dmesg-fancy.txt
 : 
 :  BTW, the patch applied cleanly.
 :
 :
 : Thanks for the feedback!  Looks like I made an erroneous
 assumption that
 : the wc, expr, and printf tools found in /usr/bin and /bin would be
 : available through boot, but that isn't the case on systems with those
 : file systems separate from /.  I'm not sure how to resolve some of
 these
 : issues, since I don't know of a way to do those functions in csh
 without
 : them.  I'm open to suggestions here from anyone.
 
 /bin and /sbin are available through the entire boot.  Only things in
 /usr are suspect because /usr gets mounted early in the boot process,
 but not as early as /.
 
 Warner
 
 
 Nice work!
 
 I too noticed the dependence upon wc, printf, expr. I went ahead and 
 rewrote these into equivalents in native sh. (attaching new diff).
 
 This diff is against the latest 7-CURRENT rc.subr. I had to manually 
 merge 3 hunks due to some differences.
 
 Thanks!!  I've put the updated version (for 6-STABLE) here:
 
 http://www.googlebit.com/freebsd/patches/rc_fancy.patch-2
 
 
 Gordon - can you give this version a try?

Much better now. :)

The [OK] Messages printed correctly. Some [failed] messages are missing
a \t I think. But this should be the error of the respective scripts.

Nice work so far... ;)

best regards,

Gordon

-- 
Gordon Bergling GBergling at 0xfce3.net http://www.0xFCE3.net/
PGP Fingerprint:  7732 9BB1 5013 AE8B E42C  28E0 93B9 D32B C76F 02A0
RIPE-HDL: MDTP-RIPE   Minimal Electronic Music
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Peter Jeremy
On Tue, 2006-Apr-18 14:02:07 -0400, Coleman Kane wrote:
A few comments on the shellscript:

+  rcargsize=`echo $rc_arg`
+  rcargsize=${#rcargsize}

Try rcargsize=$((${#rc_arg} + 1))

-  return 1
+  (echo_fancy FAILED `expr 10 + $rcargsize 
- 1`)  return 1

Try echo_fancy FAILED $((10 + $rcargsize - 
1))  return 1

+echo_fancy () {
...
+  namesize=`echo -n $name`
+  namesize=${#namesize}
or  namesize=${#name}

+  padding=
+  paddingsize=$(($columns - 15 - $2 - $namesize))
+  until [ 0 = ${paddingsize} ]; do
+  padding= $padding
+  paddingsize=$(($paddingsize - 1))
+  done

This particular block of code appears unnecessary (since $padding is unused).

+  paddingsize=$((60 - $namesize - $rc_argsize))
+  until [ 0 = ${paddingsize} ]; do
+  padding= $padding
+  paddingsize=$(($paddingsize - 1))
+  done

For safety, the conditions should probably be [ 0 -ge ${paddingsize} ]
I don't see any alternative to the until loop.  If efficiency turns out
to be a real issue then you could try doing the expansion in multiple
goes.  Eg:

until [ 8 -gt ${paddingsize} ]; do
padding=$padding
paddingsize=$(($paddingsize - 8))
done
until [ 0 -ge ${paddingsize} ]; do
padding= $padding
paddingsize=$(($paddingsize - 1))
done

-- 
Peter Jeremy
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Eric Anderson

Peter Jeremy wrote:

On Tue, 2006-Apr-18 14:02:07 -0400, Coleman Kane wrote:
A few comments on the shellscript:


+   rcargsize=`echo $rc_arg`
+   rcargsize=${#rcargsize}


Try rcargsize=$((${#rc_arg} + 1))


-   return 1
+   (echo_fancy FAILED `expr 10 + $rcargsize - 1`) 
 return 1


Try echo_fancy FAILED $((10 + $rcargsize - 1)) 
 return 1


+echo_fancy () {

...

+   namesize=`echo -n $name`
+   namesize=${#namesize}

or  namesize=${#name}


+   padding=
+   paddingsize=$(($columns - 15 - $2 - $namesize))
+   until [ 0 = ${paddingsize} ]; do
+   padding= $padding
+   paddingsize=$(($paddingsize - 1))
+   done


This particular block of code appears unnecessary (since $padding is unused).


I must be missing something, because I'm pretty sure it's used.. What 
did I miss?





+   paddingsize=$((60 - $namesize - $rc_argsize))
+   until [ 0 = ${paddingsize} ]; do
+   padding= $padding
+   paddingsize=$(($paddingsize - 1))
+   done


For safety, the conditions should probably be [ 0 -ge ${paddingsize} ]
I don't see any alternative to the until loop.  If efficiency turns out
to be a real issue then you could try doing the expansion in multiple
goes.  Eg:

until [ 8 -gt ${paddingsize} ]; do
padding=$padding
paddingsize=$(($paddingsize - 8))
done
until [ 0 -ge ${paddingsize} ]; do
padding= $padding
paddingsize=$(($paddingsize - 1))
done


Thanks for the hints.  I was testing the same changes to the 
namesize/etc as you suggested, and it does work and is more readable and 
more efficient.


I've included your suggestions and put the latest changes here:

http://www.googlebit.com/freebsd/patches/rc_fancy.patch-3


Thanks for all the feedback!  Keep it coming! :)

Eric




--

Eric AndersonSr. Systems AdministratorCentaur Technology
Anything that works is better than anything that doesn't.

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Gordon Bergling
* Thus spake Eric Anderson ([EMAIL PROTECTED]):
 Peter Jeremy wrote:
 On Tue, 2006-Apr-18 14:02:07 -0400, Coleman Kane wrote:
 A few comments on the shellscript:
 
 +   rcargsize=`echo $rc_arg`
 +   rcargsize=${#rcargsize}
 
 Try  rcargsize=$((${#rc_arg} + 1))
 
 -   return 1
 +   (echo_fancy FAILED `expr 10 + 
 $rcargsize - 1`)  return 1
 
 Try  echo_fancy FAILED $((10 + $rcargsize - 
 1))  return 1
 
 +echo_fancy () {
 ...
 +   namesize=`echo -n $name`
 +   namesize=${#namesize}
 or   namesize=${#name}
 
 +   padding=
 +   paddingsize=$(($columns - 15 - $2 - $namesize))
 +   until [ 0 = ${paddingsize} ]; do
 +   padding= $padding
 +   paddingsize=$(($paddingsize - 1))
 +   done
 
 This particular block of code appears unnecessary (since $padding is 
 unused).
 
 I must be missing something, because I'm pretty sure it's used.. What 
 did I miss?
 
 
 
 +   paddingsize=$((60 - $namesize - $rc_argsize))
 +   until [ 0 = ${paddingsize} ]; do
 +   padding= $padding
 +   paddingsize=$(($paddingsize - 1))
 +   done
 
 For safety, the conditions should probably be [ 0 -ge ${paddingsize} ]
 I don't see any alternative to the until loop.  If efficiency turns out
 to be a real issue then you could try doing the expansion in multiple
 goes.  Eg:
 
  until [ 8 -gt ${paddingsize} ]; do
  padding=$padding
  paddingsize=$(($paddingsize - 8))
  done
  until [ 0 -ge ${paddingsize} ]; do
  padding= $padding
  paddingsize=$(($paddingsize - 1))
  done
 
 Thanks for the hints.  I was testing the same changes to the 
 namesize/etc as you suggested, and it does work and is more readable and 
 more efficient.
 
 I've included your suggestions and put the latest changes here:
 
 http://www.googlebit.com/freebsd/patches/rc_fancy.patch-3

Patch -3 is working good here. :)

best regards,

Gordon

PS: next try... fancy_color_rc=YES ;)

-- 
Gordon Bergling GBergling at 0xfce3.net http://www.0xFCE3.net/
PGP Fingerprint:  7732 9BB1 5013 AE8B E42C  28E0 93B9 D32B C76F 02A0
RIPE-HDL: MDTP-RIPE   Minimal Electronic Music
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Eric Anderson

Gordon Bergling wrote:

* Thus spake Eric Anderson ([EMAIL PROTECTED]):

Peter Jeremy wrote:

On Tue, 2006-Apr-18 14:02:07 -0400, Coleman Kane wrote:
A few comments on the shellscript:


+   rcargsize=`echo $rc_arg`
+   rcargsize=${#rcargsize}

Try rcargsize=$((${#rc_arg} + 1))


-   return 1
+(echo_fancy FAILED `expr 10 + 
$rcargsize - 1`)  return 1
Tryecho_fancy FAILED $((10 + $rcargsize - 
1))  return 1



+echo_fancy () {

...

+   namesize=`echo -n $name`
+   namesize=${#namesize}

or  namesize=${#name}


+   padding=
+   paddingsize=$(($columns - 15 - $2 - $namesize))
+   until [ 0 = ${paddingsize} ]; do
+   padding= $padding
+   paddingsize=$(($paddingsize - 1))
+   done
This particular block of code appears unnecessary (since $padding is 
unused).
I must be missing something, because I'm pretty sure it's used.. What 
did I miss?





+   paddingsize=$((60 - $namesize - $rc_argsize))
+   until [ 0 = ${paddingsize} ]; do
+   padding= $padding
+   paddingsize=$(($paddingsize - 1))
+   done

For safety, the conditions should probably be [ 0 -ge ${paddingsize} ]
I don't see any alternative to the until loop.  If efficiency turns out
to be a real issue then you could try doing the expansion in multiple
goes.  Eg:

until [ 8 -gt ${paddingsize} ]; do
padding=$padding
paddingsize=$(($paddingsize - 8))
done
until [ 0 -ge ${paddingsize} ]; do
padding= $padding
paddingsize=$(($paddingsize - 1))
done
Thanks for the hints.  I was testing the same changes to the 
namesize/etc as you suggested, and it does work and is more readable and 
more efficient.


I've included your suggestions and put the latest changes here:

http://www.googlebit.com/freebsd/patches/rc_fancy.patch-3


Patch -3 is working good here. :)

best regards,

Gordon

PS: next try... fancy_color_rc=YES ;)


If I could figure out how to make sh do colors, I'd do it. :)

Thanks for testing!

Eric





--

Eric AndersonSr. Systems AdministratorCentaur Technology
Anything that works is better than anything that doesn't.

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Anish Mistry
On Tuesday 18 April 2006 16:35, Eric Anderson wrote:
 Gordon Bergling wrote:
  * Thus spake Eric Anderson ([EMAIL PROTECTED]):
  Peter Jeremy wrote:
  On Tue, 2006-Apr-18 14:02:07 -0400, Coleman Kane wrote:
 
  A few comments on the shellscript:
  +rcargsize=`echo $rc_arg`
  +rcargsize=${#rcargsize}
 
  Try   rcargsize=$((${#rc_arg} + 1))
 
  -return 1
  +(echo_fancy FAILED `expr 10 +
  $rcargsize - 1`)  return 1
 
  Try   echo_fancy FAILED $((10 + 
  $rcargsize -
  1))  return 1
 
  +echo_fancy () {
 
  ...
 
  +namesize=`echo -n $name`
  +namesize=${#namesize}
 
  ornamesize=${#name}
 
  +padding=
  +paddingsize=$(($columns - 15 - $2 - $namesize))
  +until [ 0 = ${paddingsize} ]; do
  +padding= $padding
  +paddingsize=$(($paddingsize - 1))
  +done
 
  This particular block of code appears unnecessary (since
  $padding is unused).
 
  I must be missing something, because I'm pretty sure it's used..
  What did I miss?
 
  +paddingsize=$((60 - $namesize - $rc_argsize))
  +until [ 0 = ${paddingsize} ]; do
  +padding= $padding
  +paddingsize=$(($paddingsize - 1))
  +done
 
  For safety, the conditions should probably be [ 0 -ge
  ${paddingsize} ] I don't see any alternative to the until loop.
   If efficiency turns out to be a real issue then you could try
  doing the expansion in multiple goes.  Eg:
 
until [ 8 -gt ${paddingsize} ]; do
padding=$padding
paddingsize=$(($paddingsize - 8))
done
until [ 0 -ge ${paddingsize} ]; do
padding= $padding
paddingsize=$(($paddingsize - 1))
done
 
  Thanks for the hints.  I was testing the same changes to the
  namesize/etc as you suggested, and it does work and is more
  readable and more efficient.
 
  I've included your suggestions and put the latest changes here:
 
  http://www.googlebit.com/freebsd/patches/rc_fancy.patch-3
 
  Patch -3 is working good here. :)
 
  best regards,
 
  Gordon
 
  PS: next try... fancy_color_rc=YES ;)

 If I could figure out how to make sh do colors, I'd do it. :)
Is that all? :)
#!/bin/sh

# Nico Golde nico(at)ngolde.de Homepage: http://www.ngolde.de
# Last change: Mon Feb 16 16:24:41 CET 2004


for attr in 0 1 4 5 7 ; do

echo 
printf ESC[%s;Foreground;Background - \n $attr
for fore in 30 31 32 33 34 35 36 37; do
for back in 40 41 42 43 44 45 46 47; do
printf '\033[%s;%s;%sm %02s;%02s  ' $attr $fore $back 
$fore $back
done
printf '\n'
done
printf '\033[0m'
done


-- 
Anish Mistry


pgpf0bSZ3O8fs.pgp
Description: PGP signature


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Eric Anderson

Anish Mistry wrote:

On Tuesday 18 April 2006 16:35, Eric Anderson wrote:

Gordon Bergling wrote:

* Thus spake Eric Anderson ([EMAIL PROTECTED]):

Peter Jeremy wrote:

On Tue, 2006-Apr-18 14:02:07 -0400, Coleman Kane wrote:

A few comments on the shellscript:

+   rcargsize=`echo $rc_arg`
+   rcargsize=${#rcargsize}

Try rcargsize=$((${#rc_arg} + 1))


-   return 1
+   (echo_fancy FAILED `expr 10 +
$rcargsize - 1`)  return 1

Try echo_fancy FAILED $((10 + $rcargsize -
1))  return 1


+echo_fancy () {

...


+   namesize=`echo -n $name`
+   namesize=${#namesize}

or  namesize=${#name}


+   padding=
+   paddingsize=$(($columns - 15 - $2 - $namesize))
+   until [ 0 = ${paddingsize} ]; do
+   padding= $padding
+   paddingsize=$(($paddingsize - 1))
+   done

This particular block of code appears unnecessary (since
$padding is unused).

I must be missing something, because I'm pretty sure it's used..
What did I miss?


+   paddingsize=$((60 - $namesize - $rc_argsize))
+   until [ 0 = ${paddingsize} ]; do
+   padding= $padding
+   paddingsize=$(($paddingsize - 1))
+   done

For safety, the conditions should probably be [ 0 -ge
${paddingsize} ] I don't see any alternative to the until loop.
 If efficiency turns out to be a real issue then you could try
doing the expansion in multiple goes.  Eg:

until [ 8 -gt ${paddingsize} ]; do
padding=$padding
paddingsize=$(($paddingsize - 8))
done
until [ 0 -ge ${paddingsize} ]; do
padding= $padding
paddingsize=$(($paddingsize - 1))
done

Thanks for the hints.  I was testing the same changes to the
namesize/etc as you suggested, and it does work and is more
readable and more efficient.

I've included your suggestions and put the latest changes here:

http://www.googlebit.com/freebsd/patches/rc_fancy.patch-3

Patch -3 is working good here. :)

best regards,

Gordon

PS: next try... fancy_color_rc=YES ;)

If I could figure out how to make sh do colors, I'd do it. :)

Is that all? :)
#!/bin/sh

# Nico Golde nico(at)ngolde.de Homepage: http://www.ngolde.de
# Last change: Mon Feb 16 16:24:41 CET 2004


for attr in 0 1 4 5 7 ; do

echo 

printf ESC[%s;Foreground;Background - \n $attr
for fore in 30 31 32 33 34 35 36 37; do
for back in 40 41 42 43 44 45 46 47; do
printf '\033[%s;%s;%sm %02s;%02s  ' $attr $fore $back 
$fore $back

done
printf '\n'
done
printf '\033[0m'
done


But can you do it without the printf's?   That's the key.  We don't have 
printf until later in the boot process..


Eric




--

Eric AndersonSr. Systems AdministratorCentaur Technology
Anything that works is better than anything that doesn't.

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Stefan Bethke


Am 18.04.2006 um 22:56 schrieb Eric Anderson:


Anish Mistry wrote:

If I could figure out how to make sh do colors, I'd do it. :)

Is that all? :)
#!/bin/sh

# Nico Golde nico(at)ngolde.de Homepage: http://www.ngolde.de
# Last change: Mon Feb 16 16:24:41 CET 2004

for attr in 0 1 4 5 7 ; do
echo  


printf ESC[%s;Foreground;Background - \n $attr
for fore in 30 31 32 33 34 35 36 37; do
for back in 40 41 42 43 44 45 46 47; do
printf '\033[%s;%s;%sm %02s;%02s  ' $attr $fore $back  
$fore $back

done
printf '\n'
done
printf '\033[0m'
done


But can you do it without the printf's?   That's the key.  We don't  
have printf until later in the boot process..


echo -e is your friend, see sh(1).

$ echo -e '\e[0;32;46m'
gives green on cyan in my xterm.

Stefan

--
Stefan Bethke [EMAIL PROTECTED]   Fon +49 170 346 0140


___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Stanislaw Halik
On Tue, Apr 18, 2006, Anish Mistry wrote:
 printf '\033[%s;%s;%sm %02s;%02s  ' $attr $fore $back 

however, as stated previously in this thread: `printf is
/usr/bin/printf'.

embedding raw ^[s in the rc script would do, is this acceptable?

-- sh


pgpeAfaSh4tlK.pgp
Description: PGP signature


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Aren Olvalde Tyr
Hi

 I've included your suggestions and put the latest changes here:

 http://www.googlebit.com/freebsd/patches/rc_fancy.patch-3


 Thanks for all the feedback!  Keep it coming! :)


Works great on my FreeBSD 6-STABLE system too.

Excellent. Now, colour please! 

:^)

Aren.


pgpnNiwBjSZJJ.pgp
Description: PGP signature


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Doug Barton
While I personally am not necessarily opposed to this kind of patch, you
should be aware that this idea has been proposed in the past, and roundly
rejected. The consensus has been that we don't necessarily want FreeBSD to
look like other OSes that do this.

That said, when you have something that you're ready for a wider review on,
please submit it first to freebsd-rc@, then [EMAIL PROTECTED]

Doug

-- 

This .signature sanitized for your protection
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Darren Pilgrim

Eric Anderson wrote:

 If I could figure out how to make sh do colors, I'd do it. :)

Please do not use colors in rc.  Escape-sequenced colors make unacceptable 
assumptions about the user and syslogd strips escape sequences anyway, so it 
would be of no use to logged consoles.  Serial consoles introduce other 
problems with buggy escape handling in third-party terminal programs.  A 
good text layout and descriptive status messages do far more for clarity and 
readability than any use of color ever can.


___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Per CPU cpu-statistics under SMP

2006-04-18 Thread Marco van Tol
On Mon, Apr 17, 2006 at 01:48:25PM +, Marco van Tol wrote:
 On Mon, Apr 17, 2006 at 09:04:58AM -0400, John Baldwin wrote:

[...]

  I actually did it differently though to try and make it less confusing.
  I've added a kern.pcpu_time sysctl which is an array of 0..mp_maxid
  cp_time[] arrays (so (mp_maxid + 1) * CPUSTATES longs) which is just the
  per-CPU data.  Userland can sum them up if it wants a composite total.
  Userland would first do a sysctl with a NULL buffer to get the required
  size (since it can vary with the number of CPUs in the system), malloc()
  a buffer, and then use the malloc'd buffer to make the requests.  You
  should only have to do the malloc() at process start since FreeBSD doesn't
  currently allow for more CPUs to be added at runtime.  You can try out
  the patch at http://www.FreeBSD.org/~jhb/patches/cp_time.patch
 
 Great thanks!
 
 I will try to apply the patch, and try to modify gkrellm to support it.
 I'll drop them (gkrellm developers) a note that I'm doing this, as it would
 be a waist of effort if somebody else has been doing preliminary work that
 I'd be doing again. :)
 
 I'll keep you up-to-date.

I'm trying to apply the patch. Tried it to both todays current and todays
RELENG_6, but both have failing hunks in sys/kern/kern_clock.c.
The rest succeeds.

I can do two things:
- Try to manually patch it against todays current.
- re-checkout todays RELENG_6, and download the relevant files from the
  cvsweb interface from the date you posted the patch from that days
  CURRENT.  Then try to apply the patch.

For the latter it may break the kernelbuild, but I'm very tempted to try
that one ahead of the manual patching attempt. ;)

I'll keep you posted on how far I'm getting with this.  Guess I should have
gone straight to current the day you posted the patch.  Sorry.

Marco

-- 
Nothing takes the past away like the future
- Madonna in Nothing Really Matters
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Coleman Kane
On 4/18/06, Darren Pilgrim [EMAIL PROTECTED] wrote:

 Eric Anderson wrote:
 
  If I could figure out how to make sh do colors, I'd do it. :)

 Please do not use colors in rc.  Escape-sequenced colors make unacceptable
 assumptions about the user and syslogd strips escape sequences anyway, so
 it
 would be of no use to logged consoles.  Serial consoles introduce other
 problems with buggy escape handling in third-party terminal programs.  A
 good text layout and descriptive status messages do far more for clarity
 and
 readability than any use of color ever can.


I understand your concerns regarding the pollution of rc messages with
excess baggage such as ANSI-color sequences and attributes. The patches have
been set up in such a way as to provide the fancy capability only on
demand, and the fancy w/ color only as another toggle. I think that having
a more defined status interface would be very beneficial (and using colors
and other attributes supported by advanced terminal types seems to be what
people would like).

For instance, right now we just have the name of the service printed if it
is started, otherwise an ugly (in my eyes) dump of its stderr is displayed
on-screen. If we instead defined an API that defined a Service Name
Service Description Service Status and Error Code then we could have a
more manageable service structure (IMHO). I think this work toward making
the service status messages prettier CAN ONLY BE GOOD. Even if pretty
colors are deemed too fancy by the freebsd gods in the end.

As for your buggy escape handling of third-party terminals: 1) Don't
enable the feature and it won't be a problem, or 2) Don't use crappy
third-party terminal software that will die when it recieves ^[[0;31;40m
rather than setting the attributes to NormalText-Red-on-Black. In fact, I
haven't heard of one for some time.

--
Coleman Kane
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Coleman Kane
On 4/18/06, Doug Barton [EMAIL PROTECTED] wrote:

 While I personally am not necessarily opposed to this kind of patch, you
 should be aware that this idea has been proposed in the past, and roundly
 rejected. The consensus has been that we don't necessarily want FreeBSD to
 look like other OSes that do this.


I remember a time back when the idea of an /etc/rc.d/ was taboo to bring
up hopefully times are better now!

That said, when you have something that you're ready for a wider review on,
 please submit it first to freebsd-rc@, then [EMAIL PROTECTED]

 Doug

 --

 This .signature sanitized for your protection
 ___
 freebsd-hackers@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
 To unsubscribe, send any mail to [EMAIL PROTECTED]


You want colors?!?

You can have them! (attached)

---
Coleman Kane
--- rc.subr.orig	Tue Apr 18 18:06:20 2006
+++ rc.subr	Tue Apr 18 18:09:24 2006
@@ -313,12 +313,16 @@
 			break
 		fi
 		_list=$_nlist
-		echo -n ${_prefix:-Waiting for PIDS: }$_list
+		if ! checkyesno rc_fancy; then
+			echo -n ${_prefix:-Waiting for PIDS: }$_list
+		fi
 		_prefix=, 
 		sleep 2
 	done
 	if [ -n $_prefix ]; then
-		echo .
+		if ! checkyesno rc_fancy; then
+			echo .
+		fi
 	fi
 }
 
@@ -564,12 +568,14 @@
 	# if the precmd failed and force
 	# isn't set, exit
 	#
+			rcargsize=`echo $rc_arg`
+			rcargsize=${#rcargsize}
 			if [ -n $_precmd ]; then
 debug run_rc_command: evaluating ${_precmd}().
 eval $_precmd $rc_extra_args
 _return=$?
 [ $_return -ne 0 ]  [ -z $rc_force ] 
-return 1
+(echo_fancy FAILED `expr 10 + $rcargsize - 1`)  return 1
 			fi
 
 			if [ -n $_cmd ]; then
@@ -577,7 +583,7 @@
 eval $_cmd $rc_extra_args
 _return=$?
 [ $_return -ne 0 ]  [ -z $rc_force ] 
-return 1
+(echo_fancy FAILED `expr 10 + $rcargsize - 1`)  return 1
 			fi
 
 			if [ -n $_postcmd ]; then
@@ -585,6 +591,7 @@
  eval $_postcmd $rc_extra_args
 _return=$?
 			fi
+			echo_fancy   OK   0
 			return $_return
 		fi
 
@@ -600,13 +607,16 @@
 			;;
 
 		start)
+ 			echo -n Starting ${name}
 			if [ -z $rc_fast -a -n $rc_pid ]; then
+ echo_fancy  SKIP  9
 echo 12 ${name} already running? (pid=$rc_pid).
 return 1
 			fi
 
 			if [ ! -x ${_chroot}${command} ]; then
 info run_rc_command: cannot run ($command).
+ echo_fancy ERROR  9
 return 1
 			fi
 
@@ -617,6 +627,7 @@
 if ! checkyesno $_f; then
 	warn \$${_f} is not enabled.
 	if [ -z $rc_force ]; then
+		echo_fancy ERROR  9
 		return 1
 	fi
 fi
@@ -625,6 +636,7 @@
 if [ ! -d ${_f}/. ]; then
 	warn ${_f} is not a directory.
 	if [ -z $rc_force ]; then
+		echo_fancy ERROR  9
 		return 1
 	fi
 fi
@@ -633,6 +645,7 @@
 if [ ! -r ${_f} ]; then
 	warn ${_f} is not readable.
 	if [ -z $rc_force ]; then
+		echo_fancy ERROR  9
 		return 1
 	fi
 fi
@@ -646,12 +659,11 @@
 eval $_precmd
 _return=$?
 [ $_return -ne 0 ]  [ -z $rc_force ] 
-return 1
+(echo_fancy ERROR  9)  return 1
 			fi
 
 	# setup the command to run, and run it
 	#
-			echo Starting ${name}.
 			if [ -n $_chroot ]; then
 _doit=\
 ${_nice:+nice -n $_nice }\
@@ -673,7 +685,7 @@
 			debug run_rc_command: _doit: $_doit
 			eval $_doit
 			_return=$?
-			[ $_return -ne 0 ]  [ -z $rc_force ]  return 1
+			[ $_return -ne 0 ]  [ -z $rc_force ]  (echo_fancy FAILED 9)  return 1
 
 	# finally, run postcmd
 	#
@@ -681,15 +693,19 @@
 debug run_rc_command: evaluating ${_postcmd}().
 eval $_postcmd
 			fi
+ 			echo_fancy   OK   9
 			;;
 
 		stop)
+ 			echo -n Stopping ${name}
 			if [ -z $rc_pid ]; then
 [ -n $rc_fast ]  return 0
 if [ -n $pidfile ]; then
+ 	echo_fancy  SKIP  9
 	echo 12 \
 ${name} not running? (check $pidfile).
 else
+ 	echo_fancy  SKIP  9
 	echo 12 ${name} not running?
 fi
 return 1
@@ -702,12 +718,11 @@
 eval $_precmd
 _return=$?
 [ $_return -ne 0 ]  [ -z $rc_force ] 
-return 1
+	(echo_fancy ERROR  9)  return 1
 			fi
 
 	# send the signal to stop
 	#
-			echo Stopping ${name}.
 			_doit=kill -${sig_stop:-TERM} $rc_pid
 			if [ -n $_user ]; then
 _doit=su -m $_user -c 'sh -c \$_doit\'
@@ -718,7 +733,7 @@
 	#
 			eval $_doit
 			_return=$?
-			[ $_return -ne 0 ]  [ -z $rc_force ]  return 1
+			[ $_return -ne 0 ]  [ -z $rc_force ]  (echo_fancy FAILED 9)  return 1
 
 	# wait for the command to exit,
 	# and run postcmd.
@@ -727,24 +742,27 @@
 eval $_postcmd
 _return=$?
 			fi
+ 			echo_fancy   OK   9
 			;;
 
 		reload)
+ 			echo -n Reloading ${name} config files
 			if [ -z $rc_pid ]; then
 if [ -n $pidfile ]; then
+ 	echo_fancy SKIPPED 23
 	echo 12 \
 ${name} not running? (check $pidfile).
 else
+ 	echo_fancy SKIPPED 23
 	echo 12 ${name} not running?
 

Re: Per CPU cpu-statistics under SMP

2006-04-18 Thread John Baldwin
On Tuesday 18 April 2006 18:15, Marco van Tol wrote:
 On Mon, Apr 17, 2006 at 01:48:25PM +, Marco van Tol wrote:
  On Mon, Apr 17, 2006 at 09:04:58AM -0400, John Baldwin wrote:
 
 [...]
 
   I actually did it differently though to try and make it less confusing.
   I've added a kern.pcpu_time sysctl which is an array of 0..mp_maxid
   cp_time[] arrays (so (mp_maxid + 1) * CPUSTATES longs) which is just the
   per-CPU data.  Userland can sum them up if it wants a composite total.
   Userland would first do a sysctl with a NULL buffer to get the required
   size (since it can vary with the number of CPUs in the system), malloc()
   a buffer, and then use the malloc'd buffer to make the requests.  You
   should only have to do the malloc() at process start since FreeBSD doesn't
   currently allow for more CPUs to be added at runtime.  You can try out
   the patch at http://www.FreeBSD.org/~jhb/patches/cp_time.patch
  
  Great thanks!
  
  I will try to apply the patch, and try to modify gkrellm to support it.
  I'll drop them (gkrellm developers) a note that I'm doing this, as it would
  be a waist of effort if somebody else has been doing preliminary work that
  I'd be doing again. :)
  
  I'll keep you up-to-date.
 
 I'm trying to apply the patch. Tried it to both todays current and todays
 RELENG_6, but both have failing hunks in sys/kern/kern_clock.c.
 The rest succeeds.
 
 I can do two things:
 - Try to manually patch it against todays current.
 - re-checkout todays RELENG_6, and download the relevant files from the
   cvsweb interface from the date you posted the patch from that days
   CURRENT.  Then try to apply the patch.
 
 For the latter it may break the kernelbuild, but I'm very tempted to try
 that one ahead of the manual patching attempt. ;)
 
 I'll keep you posted on how far I'm getting with this.  Guess I should have
 gone straight to current the day you posted the patch.  Sorry.

Ah, hmm.  On 6.x we don't have per-thread stat ticks yet, which is
probably why it is failing.  It also isn't safe to move sched_lock
down either on 6.x.  You can still apply the rest of the patch by
hand, just leave the 'mtx_lock_spin(sched_lock)' where it is and
change all the 'cp_time[FOO]++' to 'PCPU_LAZY_INC(cp_time[FOO])'.

-- 
John Baldwin [EMAIL PROTECTED]http://www.FreeBSD.org/~jhb/
Power Users Use the Power to Serve  =  http://www.FreeBSD.org
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] Fancy rc startup style RFC

2006-04-18 Thread Robert Watson

On Tue, 18 Apr 2006, Coleman Kane wrote:

I understand your concerns regarding the pollution of rc messages with 
excess baggage such as ANSI-color sequences and attributes. The patches have 
been set up in such a way as to provide the fancy capability only on 
demand, and the fancy w/ color only as another toggle. I think that having 
a more defined status interface would be very beneficial (and using colors 
and other attributes supported by advanced terminal types seems to be what 
people would like).


For instance, right now we just have the name of the service printed if it 
is started, otherwise an ugly (in my eyes) dump of its stderr is displayed 
on-screen. If we instead defined an API that defined a Service Name 
Service Description Service Status and Error Code then we could have a 
more manageable service structure (IMHO). I think this work toward making 
the service status messages prettier CAN ONLY BE GOOD. Even if pretty 
colors are deemed too fancy by the freebsd gods in the end.


As for your buggy escape handling of third-party terminals: 1) Don't 
enable the feature and it won't be a problem, or 2) Don't use crappy 
third-party terminal software that will die when it recieves ^[[0;31;40m 
rather than setting the attributes to NormalText-Red-on-Black. In fact, I 
haven't heard of one for some time.


If adding color, please...

(1) Confirm that the results just work with /var/log/console.log turned on. 
(2) Confirm that the results just work with dmesg -a.


It has always struck me that what we have right now is the easiest to 
implement model for logging service startup, but the least useful from the 
perspective of consumers: we have script output that varies by application, 
component, etc.  It would be nice to have either, and possibly both, of 
consistently user friendly output, or entirely machine-parseable content that 
could be used to generate user friendly output.


I've wondered for a while if it wouldn't be useful to consider having a flag 
in syslogd to indicate that syslog should store log entries in the target 
logfile in binary format, so that log messages could be reviewed, sorted, 
searched, etc, by facility, criticality, source process, etc...


Robert N M Watson
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Broadcom 440x on FreeBSD 6.0/6.1

2006-04-18 Thread Pyun YongHyeon
On Sun, Apr 16, 2006 at 09:57:34PM +0200, Andreas Bachmann wrote:
   The bfe driver is broken for RAM sizes above 1G, and you have 2G.
   
   For kicks, you could try booting with hw.physmem=1G (in loader.conf
   or manually).  If that doesn't work, you have discovered a new bug.
   
   The ndis driver works on my H^HDell notebook (see ndisgen(8)).
  I found your post to freebsd-mobile with the same text :-)
  After limiting my physical memory, my NIC works now...
  I will look at the ndisgen.
  

It seems that BCM440x has DMA address limit at 1GB.
How about this?

Index: if_bfe.c
===
RCS file: /pool/ncvs/src/sys/dev/bfe/if_bfe.c,v
retrieving revision 1.32
diff -u -r1.32 if_bfe.c
--- if_bfe.c4 Apr 2006 22:30:12 -   1.32
+++ if_bfe.c19 Apr 2006 04:01:47 -
@@ -200,7 +200,7 @@
/* parent tag */
error = bus_dma_tag_create(NULL,  /* parent */
PAGE_SIZE, 0, /* alignment, boundary */
-   BUS_SPACE_MAXADDR,/* lowaddr */
+   0x3fff,   /* lowaddr */
BUS_SPACE_MAXADDR_32BIT,  /* highaddr */
NULL, NULL,   /* filter, filterarg */
MAXBSIZE, /* maxsize */
-- 
Regards,
Pyun YongHyeon
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]