]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
rspreload: Add fstat support
authorSean Hefty <sean.hefty@intel.com>
Tue, 7 Aug 2012 16:37:24 +0000 (09:37 -0700)
committerSean Hefty <sean.hefty@intel.com>
Tue, 14 Aug 2012 22:53:34 +0000 (15:53 -0700)
vsftpd calls fstat on a socket.  Fake it out.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/preload.c

index c6cf1761d6efb8233b3ac14f043aa337bda36c0d..ec62e693b351efa3395c11e16a842d4bfc44d6b1 100644 (file)
@@ -87,6 +87,8 @@ struct socket_calls {
        int (*fcntl)(int socket, int cmd, ... /* arg */);
        int (*dup2)(int oldfd, int newfd);
        ssize_t (*sendfile)(int out_fd, int in_fd, off_t *offset, size_t count);
+       int (*fxstat64)(int ver, int fd, struct stat64 *buf);
+       int (*fxstat)(int ver, int fd, struct stat *buf);
 };
 
 static struct socket_calls real;
@@ -280,6 +282,8 @@ static void init_preload(void)
        real.fcntl = dlsym(RTLD_NEXT, "fcntl");
        real.dup2 = dlsym(RTLD_NEXT, "dup2");
        real.sendfile = dlsym(RTLD_NEXT, "sendfile");
+       real.fxstat64 = dlsym(RTLD_NEXT, "__fxstat64");
+       real.fxstat = dlsym(RTLD_NEXT, "__fxstat");
 
        rs.socket = dlsym(RTLD_DEFAULT, "rsocket");
        rs.bind = dlsym(RTLD_DEFAULT, "rbind");
@@ -1033,3 +1037,23 @@ 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;
+       return real.fxstat64(ver, socket, buf);
+}
+
+int __fxstat(int ver, int socket, struct stat *buf)
+{
+       return real.fxstat(ver, socket, buf);
+}