From 3dbaad0a1f27b96462541e1189efe37ffa913e9a Mon Sep 17 00:00:00 2001 From: Albert Ou Date: Tue, 13 Dec 2016 15:05:19 -0800 Subject: Refactor libc stubs into libwrap The --wrap feature of GNU ld supports a cleaner framework for linking in alternative implementations of libc functions without cpp hacks. Place wrappers in separate object files to reduce static code size. --- bsp/libwrap/sys/fstat.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 bsp/libwrap/sys/fstat.c (limited to 'bsp/libwrap/sys/fstat.c') diff --git a/bsp/libwrap/sys/fstat.c b/bsp/libwrap/sys/fstat.c new file mode 100644 index 0000000..6ea3e6a --- /dev/null +++ b/bsp/libwrap/sys/fstat.c @@ -0,0 +1,16 @@ +/* See LICENSE of license details. */ + +#include +#include +#include +#include "stub.h" + +int __wrap_fstat(int fd, struct stat* st) +{ + if (isatty(fd)) { + st->st_mode = S_IFCHR; + return 0; + } + + return _stub(EBADF); +} -- cgit v1.2.1-18-gbd029