]>
git.ipfire.org Git - thirdparty/kmod.git/blob - testsuite/uname.c
2 * Copyright (C) 2012-2013 ProFUSION embedded systems
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <sys/utsname.h>
27 #include "testsuite.h"
29 TS_EXPORT
int uname(struct utsname
*u
)
31 static void *nextlib
= NULL
;
32 static int (*nextlib_uname
)(struct utsname
*u
);
37 if (nextlib
== NULL
) {
41 nextlib
= dlopen("libc.so.6", RTLD_LAZY
);
43 nextlib_uname
= dlsym(nextlib
, "uname");
46 err
= nextlib_uname(u
);
52 * probably called from within glibc before main(); unsafe
57 release
= getenv(S_TC_UNAME_R
);
58 if (release
== NULL
) {
59 fprintf(stderr
, "TRAP uname(): missing export %s?\n",
64 sz
= strlen(release
) + 1;
65 if (sz
> sizeof(u
->release
)) {
66 fprintf(stderr
, "uname(): sizeof release (%s) "
67 "is greater than available space: %zu",
68 release
, sizeof(u
->release
));
73 memcpy(u
->release
, release
, sz
);