Hack to sysctl kern.osreldate, for ports cluster
Conrad J. Sabatier
conrads at cox.net
Sat Jan 8 01:47:21 PST 2005
On Sat, 8 Jan 2005 02:13:24 -0500, Craig Rodrigues
<rodrigc at crodrigues.org> wrote:
> 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?
Well, while it's certainly a "doable" thing, don't you think it's just a
little bit dangerous? What about when the source tree is not in sync
with the currently running kernel?
> --- 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
> _______________________________________________
> freebsd-ports at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-ports
> To unsubscribe, send any mail to
> "freebsd-ports-unsubscribe at freebsd.org"
>
--
Conrad J. Sabatier <conrads at cox.net> -- "In Unix veritas"
More information about the freebsd-ports
mailing list