[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#648948: uptimed: FTBFS on hurd-i386: add support for GNU



Package: uptimed
Version: 0.3.16-3.2
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd

Hi,

The attached patch fixes the FTBFS problems of uptimed on GNU/Hurd,
adding support for the GNU platform. Additionally it replaces the NOFILE
parameter for architectures supporting getdtablesize() with a fallback
to sysconf() or 3 for other architectures.

The NOFILE parameter is obsolete even on GNU/Linux.
>From /usr/include/i386-linux-gnu/sys/param.h:

/* The following are not really correct but it is a value we used for a
   long time and which seems to be usable.  People should not use NOFILE
   and NCARGS anyway.  */
#define NOFILE          256
#define NCARGS          131072

The patched uptimed has been build and run tested on GNU/Linux and
GNU/Hurd for some time with no problems so far.

Thanks!

diff -ur uptimed-0.3.16/configure.ac uptimed-0.3.16.modified/configure.ac
--- uptimed-0.3.16/configure.ac	2009-01-02 00:46:00.000000000 +0100
+++ uptimed-0.3.16.modified/configure.ac	2011-11-01 22:45:58.000000000 +0100
@@ -31,6 +31,9 @@
   *-darwin*)
     AC_DEFINE(PLATFORM_BSD, 1, [Define if you are compiling for *BSD])
     ;;
+  *-gnu*)
+    AC_DEFINE(PLATFORM_GNU, 1, [Define if you are compiling for *GNU])
+    ;;
   *)
     AC_DEFINE(PLATFORM_UNKNOWN, 1, [Define if you are compiling for an unknown system])
     ;;
@@ -38,6 +41,7 @@
 
 AC_REPLACE_FUNCS(getopt)
 AC_CHECK_HEADERS(getopt.h)
+AC_CHECK_FUNCS([getdtablesize])
 
 AC_OUTPUT([Makefile libuptimed/Makefile src/Makefile man/Makefile etc/Makefile uptimed.spec])
 
diff -ur uptimed-0.3.16/src/uptimed.c uptimed-0.3.16.modified/src/uptimed.c
--- uptimed-0.3.16/src/uptimed.c	2009-01-02 00:46:00.000000000 +0100
+++ uptimed-0.3.16.modified/src/uptimed.c	2011-11-01 23:00:14.000000000 +0100
@@ -175,7 +175,7 @@
 
 void bg(void)
 {
-	int i;
+	int i, fdmax;
 	/* Simple fork to run proces in the background. */
 	switch(fork())
 	{
@@ -192,7 +192,15 @@
 	}
 
 	/* Close probably all file descriptors */
-	for (i = 0; i<NOFILE; i++)
+#ifdef HAVE_GETDTABLESIZE
+	fdmax = getdtablesize();
+#else
+	fdmax = sysconf(_SC_OPEN_MAX);
+#endif
+	if (fdmax <= 0)
+		fdmax = 3;
+
+	for (i = 0; i < fdmax; i++)
 		close(i);
 
 	/* Be nice to umount */
--- uptimed-0.3.16/libuptimed/urec.c	2011-11-15 19:39:26.000000000 +0100
+++ uptimed-0.3.16.modified/libuptimed/urec.c	2011-11-15 18:18:30.000000000 +0100
@@ -103,6 +103,9 @@
 #ifdef PLATFORM_HPUX
 		return "HP/UX";
 #endif
+#ifdef PLATFORM_GNU
+		return "GNU";
+#endif
 #ifdef PLATFORM_UNKNOWN
 		return "unknown";
 #endif
@@ -177,7 +180,7 @@
 }
 #endif
 
-#ifdef PLATFORM_UNKNOWN
+#if defined(PLATFORM_UNKNOWN) || defined(PLATFORM_GNU)
 time_t read_uptime(void) {
 /*
  * This is a quick and inaccurate hack calculating the uptime from the
@@ -294,7 +297,7 @@
 	rename(FILE_RECORDS".tmp", FILE_RECORDS);
 }
 
-#if defined(PLATFORM_LINUX) || defined(PLATFORM_BSD)
+#if defined(PLATFORM_LINUX) || defined(PLATFORM_BSD) || defined(PLATFORM_GNU)
 int createbootid(void) {
 	/* these platforms doesn't need to create a bootid file.
 	 * readbootid() fetches it directly from the system every time.
@@ -387,7 +390,7 @@
 	}
 
 	return bootid;
-#elif PLATFORM_LINUX
+#elif defined(PLATFORM_LINUX) || defined(PLATFORM_GNU)
 	FILE *f;
 	char str[256];
 	time_t bootid = 0;

Reply to: