On Sat, Jan 29, 2005 at 06:16:55PM -0500, Albert Cahalan wrote:
> > 
> > It won't work without my patch.  If this file is unneeded, why not just
> > removing it?
> 
> It's convenient to ship everything together in one tarball.
> One might use minimal.c for a rescue disk or embedded system.

Well, then we might need it for a GNU/kFreeBSD rescue disk.  Please, could
you fix the PAGE_SIZE issue in that file?  (patch is attached)

> > The version in /proc/version is intended
> > to match with the implementation in the same version of Linux procfs.  It's
> > unrelated to other kernel features.  So for what linprocfs is concerned, 
> > we're
> > Linux 2.4, for what RT signals are concerned, we're Linux 2.0, etc.
> > 
> > Even the linprocfs implementation is far from complete.  I don't think we're
> > safe claiming anything other than 2.0 in /proc/version.
> 
> Well, give it a try.

I'll patch kfreebsd to identify itself as "Linux 2.0" in /proc/version.  I'm
attaching the patch for procps to use /proc/version instead of uname.

-- 
 .''`.   Proudly running Debian GNU/kFreeBSD unstable/unreleased (on UFS2+S)
: :' :
`. `'    http://www.debian.org/ports/kfreebsd-gnu
  `-
diff -ur procps-3.2.4.old/minimal.c procps-3.2.4/minimal.c
--- procps-3.2.4.old/minimal.c  2004-05-05 02:26:14.000000000 +0200
+++ procps-3.2.4/minimal.c      2005-01-28 00:39:14.000000000 +0100
@@ -57,7 +57,6 @@
 ///////////////////////////////////////////////////////
 #ifdef __linux__
 #include <asm/param.h>  /* HZ */
-#include <asm/page.h>   /* PAGE_SIZE */
 #define NO_TTY_VALUE DEV_ENCODE(0,0)
 #ifndef HZ
 #warning HZ not defined, assuming it is 100
@@ -68,8 +67,15 @@
 ///////////////////////////////////////////////////////////
 
 #ifndef PAGE_SIZE
-#warning PAGE_SIZE not defined, assuming it is 4096
-#define PAGE_SIZE 4096
+#if defined(__linux__)
+#include <asm/page.h>  /* looks safe for glibc */
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include <machine/param.h>
+#elif defined(_SC_PAGE_SIZE)
+#define PAGE_SIZE sysconf (_SC_PAGE_SIZE)
+#else
+#error
+#endif
 #endif
 
 
diff -ur procps-3.2.4.old/proc/version.c procps-3.2.4/proc/version.c
--- procps-3.2.4.old/proc/version.c     2003-01-29 02:11:43.000000000 +0100
+++ procps-3.2.4/proc/version.c 2005-01-30 02:12:08.000000000 +0100
@@ -27,7 +27,6 @@
 /* Linux kernel version information for procps utilities
  * Copyright (c) 1996 Charles Blake <[EMAIL PROTECTED]>
  */
-#include <sys/utsname.h>
 
 #define LINUX_VERSION(x,y,z)   (0x10000*(x) + 0x100*(y) + z)
 
@@ -35,15 +34,16 @@
 
 static void init_Linux_version(void) __attribute__((constructor));
 static void init_Linux_version(void) {
-    static struct utsname uts;
+    FILE *fp;
     int x = 0, y = 0, z = 0;   /* cleared in case sscanf() < 3 */
     
-    if (uname(&uts) == -1)     /* failure implies impending death */
+    fp = fopen ("/proc/version", "r");
+    if (fp == NULL)    /* failure implies impending death */
        exit(1);
-    if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3)
+    if (fscanf(fp, "Linux version %d.%d.%d", &x, &y, &z) < 3)
        fprintf(stderr,         /* *very* unlikely to happen by accident */
                "Non-standard uts for running kernel:\n"
-               "release %s=%d.%d.%d gives version code %d\n",
-               uts.release, x, y, z, LINUX_VERSION(x,y,z));
+               "release %d.%d.%d gives version code %d\n",
+               x, y, z, LINUX_VERSION(x,y,z));
     linux_version_code = LINUX_VERSION(x, y, z);
 }

Reply via email to