]>
git.ipfire.org Git - pakfire.git/blob - src/libpakfire_preload/uname.c
6 #include <stdlib.h> /* for EXIT_FAILURE */
7 #include <unistd.h> /* for _exit() */
11 #include <sys/syslog.h>
12 #include <sys/utsname.h>
15 #define RTLD_NEXT ((void *) -1l)
18 typedef int (*uname_t
)(struct utsname
* buf
);
20 static void *get_libc_func(const char *funcname
) {
23 void *func
= dlsym(RTLD_NEXT
, funcname
);
24 if ((error
= dlerror()) != NULL
) {
25 fprintf(stderr
, "I can't locate libc function `%s' error: %s", funcname
, error
);
32 int uname(struct utsname
*buf
) {
35 /* Call real uname to get the information we need. */
36 uname_t real_uname
= (uname_t
)get_libc_func("uname");
37 int ret
= real_uname((struct utsname
*) buf
);
39 /* Replace release if requested. */
40 if ((env
= getenv("UTS_RELEASE")) != NULL
) {
41 strncpy(buf
->release
, env
, _UTSNAME_RELEASE_LENGTH
);
44 /* Replace machine type if requested. */
45 if ((env
= getenv("UTS_MACHINE")) != NULL
) {
46 strncpy(buf
->machine
, env
, _UTSNAME_MACHINE_LENGTH
);