Hack to sysctl kern.osreldate, for ports cluster
Craig Rodrigues
rodrigc at crodrigues.org
Fri Jan 7 23:13:27 PST 2005
Hi,
On http://pointyhat.freebsd.org/errorlogs/ it states
that sysctl should not be used to determine the
version of FreeBSD, and that uname(1) or the OSVERSION
variable should be used instead.
While a valid thing to do, this is another detail
for port maintainers to keep track of.
What do you think of this hack to sysctl,
which cats /usr/include/sys/param.h to get the
value of kern.osreldate, instead of going to
the true kernel sysctl variable?
--- sbin/sysctl/sysctl.c.orig Sat Jan 8 01:34:41 2005
+++ sbin/sysctl/sysctl.c Sat Jan 8 01:57:13 2005
@@ -568,8 +568,14 @@
printf("%d", *(int *)p);
else
printf("%d.%dC", (*(int *)p - 2732) / 10, (*(int *)p - 2732) % 10);
- } else
- printf(hflag ? "%'d" : "%d", *(int *)p);
+ } else {
+#ifdef PORTS_HACK
+ if (strcmp("kern.osreldate", name ) == 0) {
+ system("awk '/^#define __FreeBSD_version/ { print $3 }' /usr/include/sys/param.h");
+ } else
+#endif /* PORTS_HACK */
+ printf(hflag ? "%'d" : "%d", *(int *)p);
+ }
val = " ";
len -= sizeof(int);
p += sizeof(int);
--
Craig Rodrigues
rodrigc at crodrigues.org
More information about the freebsd-ports
mailing list