]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
Refresh of fstat
authorSean Hefty <sean.hefty@intel.com>
Tue, 7 Aug 2012 17:30:05 +0000 (10:30 -0700)
committerSean Hefty <sean.hefty@intel.com>
Tue, 7 Aug 2012 17:30:05 +0000 (10:30 -0700)
src/preload.c

index 085e8b4c63beccce53efaa51584077f170f1a6a1..b9c32e670aa10b78a8dc565b1e084219326b7a8a 100644 (file)
@@ -84,6 +84,7 @@ struct socket_calls {
                          void *optval, socklen_t *optlen);
        int (*fcntl)(int socket, int cmd, ... /* arg */);
        int (*dup2)(int oldfd, int newfd);
+       int (*fstat)(int fd, struct stat *buf);
 };
 
 static struct socket_calls real;
@@ -259,6 +260,7 @@ static void init_preload(void)
        real.getsockopt = dlsym(RTLD_NEXT, "getsockopt");
        real.fcntl = dlsym(RTLD_NEXT, "fcntl");
        real.dup2 = dlsym(RTLD_NEXT, "dup2");
+       real.fstat = dlsym(RTLD_NEXT, "fstat");
 
        rs.socket = dlsym(RTLD_DEFAULT, "rsocket");
        rs.bind = dlsym(RTLD_DEFAULT, "rbind");
@@ -960,3 +962,17 @@ int dup2(int oldfd, int newfd)
        atomic_inc(&oldfdi->refcnt);
        return newfd;
 }
+
+int fstat(int socket, struct stat *buf)
+{
+       int fd, ret;
+
+       if (fd_get(socket, &fd) == fd_rsocket) {
+               ret = real.fstat(socket, buf);
+               if (!ret)
+                       buf->st_mode |= __S_IFSOCK;
+       } else {
+               ret = real.fstat(fd, buf);
+       }
+       return ret;
+}