From hsn@netmag.cz  Sat Jan 17 08:30:35 2004
Return-Path: <hsn@netmag.cz>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id B9D6316A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 17 Jan 2004 08:30:35 -0800 (PST)
Received: from mail.tiscali.cz (stateless2.tiscali.cz [213.235.135.71])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 04B6F43D49
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 17 Jan 2004 08:30:34 -0800 (PST)
	(envelope-from hsn@netmag.cz)
Received: from asura.bsd (212.11.96.229) by mail.tiscali.cz (6.7.018)
        id 3FB9680901159853 for FreeBSD-gnats-submit@freebsd.org; Sat, 17 Jan 2004 17:30:32 +0100
Received: from hsn by asura.bsd with local (Exim 4.24 #4 (Debian))
	id 1AhbyH-0001td-Ng
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 16 Jan 2004 22:57:41 +0100
Message-Id: <E1AhbyH-0001td-Ng@asura.bsd>
Date: Fri, 16 Jan 2004 22:57:41 +0100
From: Radim Kolar <hsn@netmag.cz>
Reply-To: Radim Kolar <hsn@netmag.cz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] fix for uptimed
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         61479
>Category:       ports
>Synopsis:       [patch] fix for uptimed
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 17 08:40:16 PST 2004
>Closed-Date:    Tue Jan 20 11:32:20 PST 2004
>Last-Modified:  Tue Jan 20 11:32:20 PST 2004
>Originator:     Radim Kolar
>Release:        FreeBSD 5.2-RELEASE i386
>Organization:
Sanatana Dharma
>Environment:
System: FreeBSD asura.bsd 5.2-RELEASE FreeBSD 5.2-RELEASE #0: Thu Jan 15 18:35:03 CET 2004 root@asura.bsd:/usr/obj/usr/src/sys/GENERIC i386
>Description:
When system crashes while uptimed is updating his record file, all entries
in the file are lost. This simple patch writes records into temporary
file and rename it to original. Tested and works.
>How-To-Repeat:
Press reset button while uptimed is running, if you are lucky, softupdates
sets file length to zero. It happens to me 2 times on linux with 
reiserfs journaling and 3 times 
on freebsd with softupdates.
>Fix:
diff -rNu /usr/ports/sysutils/uptimed/Makefile /tmp/uptimed/Makefile
--- /usr/ports/sysutils/uptimed/Makefile	Fri Feb 21 14:28:55 2003
+++ /tmp/uptimed/Makefile	Fri Jan 16 22:40:59 2004
@@ -6,6 +6,7 @@
 
 PORTNAME=	uptimed
 PORTVERSION=	0.3.0
+PORTREVISION=	1
 CATEGORIES=	sysutils
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	uptimed
diff -rNu /usr/ports/sysutils/uptimed/files/patch-aa /tmp/uptimed/files/patch-aa
--- /usr/ports/sysutils/uptimed/files/patch-aa	Thu Jan  1 01:00:00 1970
+++ /tmp/uptimed/files/patch-aa	Fri Jan 16 22:43:09 2004
@@ -0,0 +1,19 @@
+--- libuptimed/urec.c.orig	Tue Nov  5 12:41:04 2002
++++ libuptimed/urec.c	Fri Jan 16 22:42:30 2004
+@@ -246,7 +246,7 @@
+ 	Urec *u;
+ 	int i=0;
+ 	
+-	f=fopen(FILE_RECORDS, "w");
++	f=fopen(FILE_RECORDS".new", "w");
+ 	if (!f)
+ 	{
+ 		printf("uptimed: cannot write to %s\n", FILE_RECORDS);
+@@ -265,6 +265,7 @@
+ 		}
+ 	}
+ 	fclose(f);
++	rename(FILE_RECORDS".new",FILE_RECORDS);
+ }
+ 
+ #ifdef PLATFORM_LINUX
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: clement 
State-Changed-When: Mon Jan 19 03:03:47 PST 2004 
State-Changed-Why:  
The patch has been added to uptimed 0.3.1 
http://www.unixcode.org/uptimed/download.html 
Waiting for an uptimed update. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=61479 
State-Changed-From-To: feedback->closed 
State-Changed-By: arved 
State-Changed-When: Tue Jan 20 11:31:54 PST 2004 
State-Changed-Why:  
The port was updated to 0.3.1, which incorporated your fix, thanks. 


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