Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Jan 2004 22:57:41 +0100
From:      Radim Kolar <hsn@netmag.cz>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/61479: [patch] fix for uptimed
Message-ID:  <E1AhbyH-0001td-Ng@asura.bsd>
Resent-Message-ID: <200401171640.i0HGeHsP094816@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         61479
>Category:       ports
>Synopsis:       [patch] fix for uptimed
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 17 08:40:16 PST 2004
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1AhbyH-0001td-Ng>