From: Sean Hefty Date: Tue, 7 Aug 2012 16:37:24 +0000 (-0700) Subject: rspreload: Add fstat support X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=e5e956b7a4f61e3dbd8f1137877031040cc525ac;p=~shefty%2Flibrdmacm.git rspreload: Add fstat support vsftpd calls fstat on a socket. Fake it out. Signed-off-by: Sean Hefty --- diff --git a/src/preload.c b/src/preload.c index c6cf1761..f0c41741 100644 --- a/src/preload.c +++ b/src/preload.c @@ -86,7 +86,11 @@ struct socket_calls { void *optval, socklen_t *optlen); int (*fcntl)(int socket, int cmd, ... /* arg */); int (*dup2)(int oldfd, int newfd); +<<<<<<< current ssize_t (*sendfile)(int out_fd, int in_fd, off_t *offset, size_t count); +======= + int (*fxstat64)(int ver, int fd, struct stat64 *buf); +>>>>>>> patched }; static struct socket_calls real; @@ -279,7 +283,11 @@ static void init_preload(void) real.getsockopt = dlsym(RTLD_NEXT, "getsockopt"); real.fcntl = dlsym(RTLD_NEXT, "fcntl"); real.dup2 = dlsym(RTLD_NEXT, "dup2"); +<<<<<<< current real.sendfile = dlsym(RTLD_NEXT, "sendfile"); +======= + real.fxstat64 = dlsym(RTLD_NEXT, "__fxstat64"); +>>>>>>> patched rs.socket = dlsym(RTLD_DEFAULT, "rsocket"); rs.bind = dlsym(RTLD_DEFAULT, "rbind"); @@ -1033,3 +1041,17 @@ ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count) munmap(file_addr, count); return ret; } + +int __fxstat64(int ver, int socket, struct stat64 *buf) +{ + int fd, ret; + + if (fd_get(socket, &fd) == fd_rsocket) { + ret = real.fxstat64(ver, socket, buf); + if (!ret) + buf->st_mode = (buf->st_mode & ~S_IFMT) | __S_IFSOCK; + } else { + ret = real.fxstat64(ver, fd, buf); + } + return ret; +}