diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-09-14 20:13:01 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-09-14 20:13:01 +0000 |
commit | 39cfe8dd14b6fea6f1e129d3069944586a2651fc (patch) | |
tree | f4493f3df4f7945c8cd1afd34bbf039be1805e6f /sysdeps/unix | |
parent | 1d3f0563c9d779364b5f6e14c53f57f3529a8514 (diff) | |
download | glibc-39cfe8dd14b6fea6f1e129d3069944586a2651fc.tar glibc-39cfe8dd14b6fea6f1e129d3069944586a2651fc.tar.gz glibc-39cfe8dd14b6fea6f1e129d3069944586a2651fc.tar.bz2 glibc-39cfe8dd14b6fea6f1e129d3069944586a2651fc.zip |
(DL_SYSDEP_OSCHECK): Change to not use sysctl(). Too many architectures have problems with it.
Diffstat (limited to 'sysdeps/unix')
-rw-r--r-- | sysdeps/unix/sysv/linux/dl-osinfo.h | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h index cc0694a130..1834da8a9f 100644 --- a/sysdeps/unix/sysv/linux/dl-osinfo.h +++ b/sysdeps/unix/sysv/linux/dl-osinfo.h @@ -51,39 +51,30 @@ dl_fatal (const char *str) kernels. */ \ if (__LINUX_KERNEL_VERSION > 0) \ { \ - static const int sysctl_args[] = { CTL_KERN, KERN_OSRELEASE }; \ - char buf[64]; \ - size_t reslen = sizeof (buf); \ + char bufmem[64]; \ + char *buf = bufmem; \ unsigned int version; \ int parts; \ char *cp; \ + struct utsname uts; \ \ - /* Try reading the number using `sysctl' first. */ \ - if (__sysctl ((int *) sysctl_args, \ - sizeof (sysctl_args) / sizeof (sysctl_args[0]), \ - buf, &reslen, NULL, 0) < 0) \ - { \ - /* This didn't work. Next try the uname syscall */ \ - struct utsname uts; \ - if (__uname (&uts)) \ - { \ - /* This was not successful. Now try reading the /proc \ - filesystem. */ \ - int fd = __open ("/proc/sys/kernel/osrelease", O_RDONLY); \ - if (fd == -1 \ - || (reslen = __read (fd, buf, sizeof (buf))) <= 0) \ - /* This also didn't work. We give up since we cannot \ - make sure the library can actually work. */ \ - FATAL ("FATAL: cannot determine library version\n"); \ - __close (fd); \ - } \ - else \ - { \ - strncpy (buf, uts.release, sizeof (buf)); \ - reslen = strlen (uts.release); \ - } \ + /* Try the uname syscall */ \ + if (__uname (&uts)) \ + { \ + /* This was not successful. Now try reading the /proc \ + filesystem. */ \ + ssize_t reslen; \ + int fd = __open ("/proc/sys/kernel/osrelease", O_RDONLY); \ + if (fd == -1 \ + || (reslen = __read (fd, bufmem, sizeof (bufmem))) <= 0) \ + /* This also didn't work. We give up since we cannot \ + make sure the library can actually work. */ \ + FATAL ("FATAL: cannot determine library version\n"); \ + __close (fd); \ + buf[MIN (reslen, sizeof (bufmem) - 1)] = '\0'; \ } \ - buf[MIN (reslen, sizeof (buf) - 1)] = '\0'; \ + else \ + buf = uts.release; \ \ /* Now convert it into a number. The string consists of at most \ three parts. */ \ |