diff options
author | Erik Andersen | 2000-02-21 21:26:32 +0000 |
---|---|---|
committer | Erik Andersen | 2000-02-21 21:26:32 +0000 |
commit | d07ee46919e3a8e42b3a8735e1152cc050165934 (patch) | |
tree | 8884f7679bef0e0baba2f216372577d314113dcd /utility.c | |
parent | fa4718efcf055d8720ea99be1af237a921232f5a (diff) | |
download | busybox-d07ee46919e3a8e42b3a8735e1152cc050165934.zip busybox-d07ee46919e3a8e42b3a8735e1152cc050165934.tar.gz |
Removed proc dependancies for init and free (which maintaining exactly
the same functionality). /proc takes up 90k of kernel space, so it is
nice to avoid using it at all costs. The only places where it is depended
on is for cetain optional mount/umount features, and for ps and lsmod.
-Erik
Diffstat (limited to 'utility.c')
-rw-r--r-- | utility.c | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -48,6 +48,7 @@ #include <unistd.h> #include <ctype.h> #include <sys/param.h> /* for PATH_MAX */ +#include <sys/utsname.h> /* for uname(2) */ #if defined BB_FEATURE_MOUNT_LOOP #include <fcntl.h> @@ -103,26 +104,20 @@ extern void fatalError(char *s, ...) } #if defined (BB_INIT) || defined (BB_PS) - -#if ! defined BB_FEATURE_USE_PROCFS -#error Sorry, I depend on the /proc filesystem right now. -#endif /* Returns kernel version encoded as major*65536 + minor*256 + patch, * so, for example, to check if the kernel is greater than 2.2.11: * if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> } */ int get_kernel_revision() { - FILE *file; + struct utsname name; int major = 0, minor = 0, patch = 0; - file = fopen("/proc/sys/kernel/osrelease", "r"); - if (file == NULL) { - /* bummer, /proc must not be mounted... */ + if (uname(&name) == -1) { + perror("cannot get system information"); return (0); } - fscanf(file, "%d.%d.%d", &major, &minor, &patch); - fclose(file); + sscanf(name.version, "%d.%d.%d", &major, &minor, &patch); return major * 65536 + minor * 256 + patch; } #endif /* BB_INIT || BB_PS */ |