From nobody@FreeBSD.org  Sat Apr 29 08:25:35 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id BEEBC16A401
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 29 Apr 2006 08:25:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 8B07E43D46
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 29 Apr 2006 08:25:35 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k3T8PZqM031163
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 29 Apr 2006 08:25:35 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k3T8PZwc031162;
	Sat, 29 Apr 2006 08:25:35 GMT
	(envelope-from nobody)
Message-Id: <200604290825.k3T8PZwc031162@www.freebsd.org>
Date: Sat, 29 Apr 2006 08:25:35 GMT
From: Rostislav Krasny <rosti.bsd@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] etc/rc.d/mixer script may reset mixer values to their defaults
X-Send-Pr-Version: www-2.3

>Number:         96501
>Category:       misc
>Synopsis:       [PATCH] etc/rc.d/mixer script may reset mixer values to their defaults
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 29 08:30:16 GMT 2006
>Closed-Date:    Sat Apr 29 22:50:34 GMT 2006
>Last-Modified:  Sat Apr 29 22:50:34 GMT 2006
>Originator:     Rostislav Krasny
>Release:        6.1-RC
>Organization:
>Environment:
FreeBSD saturn.lan 6.1-RC FreeBSD 6.1-RC #0: Fri Apr 28 18:55:32 IDT 2006     root@saturn.lan:/usr/obj/usr/src/sys/MYKERNEL  i386
>Description:
The etc/rc.d/mixer script saves and restores mixer values on shutdown and boot
respectively. If system booted in a single user mode and then rebooted the mixer
values might be resetted to their defaults.
>How-To-Repeat:
Make sure your mixer values are different to their defaults.
Boot into a single user mode, like you do before 'make installworld':

fsck -p
mount -u /
mount -a -t ufs
swapon -a
adjkerntz -i

.. and then just reboot:

shutdown -r now

Boot normaly and check your mixer values by running /usr/sbin/mixer
>Fix:
The etc/rc.d/mixer script patch:

--- mixer.orig	Sun Dec 18 18:06:28 2005
+++ mixer	Sat Apr 29 00:58:13 2006
@@ -53,10 +53,15 @@
 mixer_save()
 {
 	local dev
+	local uptime
 
 	dev="/dev/${1}"
+	uptime=$((`date +"%s"` - \
+		`sysctl kern.boottime | awk '{ printf("%d", $5) }'`))
 	if [ -r ${dev} ]; then
-		/usr/sbin/mixer -f ${dev} -s > /var/db/${1}-state 2>/dev/null
+		find /var/db/ -name ${1}-state -mtime -${uptime}s -maxdepth 1 \
+			-exec sh -c "/usr/sbin/mixer -f ${dev} -s > {} \
+				2>/dev/null" \;
 	fi
 }
 
@@ -71,6 +76,7 @@
 	file="/var/db/${1}-state"
 	if [ -r ${dev} -a -r ${file} ]; then
 		/usr/sbin/mixer -f ${dev} `cat ${file}` > /dev/null
+		touch -m ${file}
 	fi
 }
 

>Release-Note:
>Audit-Trail:

From: Ariff Abdullah <ariff@FreeBSD.org>
To: rosti.bsd@gmail.com, freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: misc/96501: [PATCH] etc/rc.d/mixer script may reset mixer
 values to their defaults
Date: Sat, 29 Apr 2006 16:53:53 +0800

 Complicated approach to solve simple problem. Do *not* use
 "shutdown -r now" while in single user mode. That is plain wrong.
 Use "reboot" instead.
 
 Same goes to people who use "reboot" while in multi-user mode, and
 keep wondering why their mixer settings does not survive across
 reboot.
 
 
 --
 Ariff Abdullah
 FreeBSD
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sat Apr 29 22:50:06 UTC 2006 
State-Changed-Why:  
Ariff responded with way to avoid this problem. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96501 
>Unformatted:
