Date: Thu, 18 Jan 2007 02:43:38 GMT From: Jung-uk Kim <jkim@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 113090 for review Message-ID: <200701180243.l0I2hcLn035071@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=113090 Change 113090 by jkim@jkim_hammer on 2007/01/18 02:43:32 - Add Linux kernel version strings to /proc/sys/kernel. - Properly implement OS build date string instead of using fake one. Affected files ... .. //depot/projects/linuxolator/src/sys/compat/linprocfs/linprocfs.c#8 edit Differences ... ==== //depot/projects/linuxolator/src/sys/compat/linprocfs/linprocfs.c#8 (text+ko) ==== @@ -416,6 +416,37 @@ } /* + * Get OS build date + */ +static void +linprocfs_osbuild(struct thread *td, struct sbuf *sb) +{ + char osbuild[256]; + int kern_ver[2]; + size_t size; + char *cp1, *cp2; + + cp1 = NULL; + kern_ver[0] = CTL_KERN; + kern_ver[1] = KERN_VERSION; + osbuild[0] = '\0'; + size = sizeof(osbuild); + if (kernel_sysctl(td, kern_ver, 2, &osbuild, &size, 0, 0, 0, 0) == 0) { + cp1 = strstr(osbuild, "\n"); + cp2 = strstr(osbuild, ":"); + if (cp1 && cp2) { + *cp1 = *cp2 = '\0'; + cp1 = strstr(osbuild, "#"); + } else + cp1 = NULL; + } + if (cp1) + sbuf_printf(sb, "%s%s", cp1, cp2 + 1); + else + sbuf_printf(sb, "#4 Sun Dec 18 04:30:00 CET 1977"); +} + +/* * Filler function for proc/version */ static int @@ -426,10 +457,11 @@ linux_get_osname(td, osname); linux_get_osrelease(td, osrelease); + sbuf_printf(sb, "%s version %s (des@freebsd.org) (gcc version " + __VERSION__ ") ", osname, osrelease); + linprocfs_osbuild(td, sb); + sbuf_cat(sb, "\n"); - sbuf_printf(sb, - "%s version %s (des@freebsd.org) (gcc version " __VERSION__ ")" - " #4 Sun Dec 18 04:30:00 CET 1977\n", osname, osrelease); return (0); } @@ -925,6 +957,46 @@ } /* + * Filler function for proc/sys/kernel/osrelease + */ +static int +linprocfs_doosrelease(PFS_FILL_ARGS) +{ + char osrelease[LINUX_MAX_UTSNAME]; + + linux_get_osrelease(td, osrelease); + sbuf_printf(sb, "%s\n", osrelease); + + return (0); +} + +/* + * Filler function for proc/sys/kernel/ostype + */ +static int +linprocfs_doostype(PFS_FILL_ARGS) +{ + char osname[LINUX_MAX_UTSNAME]; + + linux_get_osname(td, osname); + sbuf_printf(sb, "%s\n", osname); + + return (0); +} + +/* + * Filler function for proc/sys/kernel/version + */ +static int +linprocfs_doosbuild(PFS_FILL_ARGS) +{ + linprocfs_osbuild(td, sb); + sbuf_cat(sb, "\n"); + + return (0); +} + +/* * Filler function for proc/sys/kernel/msgmni */ static int @@ -1136,6 +1208,12 @@ dir = pfs_create_dir(root, "sys", NULL, NULL, 0); /* /proc/sys/kernel/... */ dir = pfs_create_dir(dir, "kernel", NULL, NULL, 0); + pfs_create_file(dir, "osrelease", &linprocfs_doosrelease, + NULL, NULL, PFS_RD); + pfs_create_file(dir, "ostype", &linprocfs_doostype, + NULL, NULL, PFS_RD); + pfs_create_file(dir, "version", &linprocfs_doosbuild, + NULL, NULL, PFS_RD); pfs_create_file(dir, "msgmni", &linprocfs_domsgmni, NULL, NULL, PFS_RD); pfs_create_file(dir, "pid_max", &linprocfs_dopid_max,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701180243.l0I2hcLn035071>