mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-22 10:50:07 +00:00
(DL_SYSDEP_OSCHECK): Change to not use sysctl(). Too many architectures have problems with it.
This commit is contained in:
parent
1d3f0563c9
commit
39cfe8dd14
@ -51,39 +51,30 @@ dl_fatal (const char *str)
|
|||||||
kernels. */ \
|
kernels. */ \
|
||||||
if (__LINUX_KERNEL_VERSION > 0) \
|
if (__LINUX_KERNEL_VERSION > 0) \
|
||||||
{ \
|
{ \
|
||||||
static const int sysctl_args[] = { CTL_KERN, KERN_OSRELEASE }; \
|
char bufmem[64]; \
|
||||||
char buf[64]; \
|
char *buf = bufmem; \
|
||||||
size_t reslen = sizeof (buf); \
|
|
||||||
unsigned int version; \
|
unsigned int version; \
|
||||||
int parts; \
|
int parts; \
|
||||||
char *cp; \
|
char *cp; \
|
||||||
\
|
|
||||||
/* 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; \
|
struct utsname uts; \
|
||||||
|
\
|
||||||
|
/* Try the uname syscall */ \
|
||||||
if (__uname (&uts)) \
|
if (__uname (&uts)) \
|
||||||
{ \
|
{ \
|
||||||
/* This was not successful. Now try reading the /proc \
|
/* This was not successful. Now try reading the /proc \
|
||||||
filesystem. */ \
|
filesystem. */ \
|
||||||
|
ssize_t reslen; \
|
||||||
int fd = __open ("/proc/sys/kernel/osrelease", O_RDONLY); \
|
int fd = __open ("/proc/sys/kernel/osrelease", O_RDONLY); \
|
||||||
if (fd == -1 \
|
if (fd == -1 \
|
||||||
|| (reslen = __read (fd, buf, sizeof (buf))) <= 0) \
|
|| (reslen = __read (fd, bufmem, sizeof (bufmem))) <= 0) \
|
||||||
/* This also didn't work. We give up since we cannot \
|
/* This also didn't work. We give up since we cannot \
|
||||||
make sure the library can actually work. */ \
|
make sure the library can actually work. */ \
|
||||||
FATAL ("FATAL: cannot determine library version\n"); \
|
FATAL ("FATAL: cannot determine library version\n"); \
|
||||||
__close (fd); \
|
__close (fd); \
|
||||||
|
buf[MIN (reslen, sizeof (bufmem) - 1)] = '\0'; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
buf = uts.release; \
|
||||||
strncpy (buf, uts.release, sizeof (buf)); \
|
|
||||||
reslen = strlen (uts.release); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
buf[MIN (reslen, sizeof (buf) - 1)] = '\0'; \
|
|
||||||
\
|
\
|
||||||
/* Now convert it into a number. The string consists of at most \
|
/* Now convert it into a number. The string consists of at most \
|
||||||
three parts. */ \
|
three parts. */ \
|
||||||
|
Loading…
Reference in New Issue
Block a user