summaryrefslogtreecommitdiff
path: root/sys/kern/sys_socket.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2000-08-04 00:49:17 +0000
committerPeter Wemm <peter@FreeBSD.org>2000-08-04 00:49:17 +0000
commit8f30c24b53f67c1c0a3badb92ddc57a7d1039c9a (patch)
treecdf7491d522d36647e60887621c9d636057e5492 /sys/kern/sys_socket.c
parente6bcad16fb1afdefe4f4929e3391da6a5906f855 (diff)
Notes
Diffstat (limited to 'sys/kern/sys_socket.c')
-rw-r--r--sys/kern/sys_socket.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c
index f0f27179a124..f58720b7e4a5 100644
--- a/sys/kern/sys_socket.c
+++ b/sys/kern/sys_socket.c
@@ -45,6 +45,7 @@
#include <sys/stat.h>
#include <sys/uio.h>
#include <sys/filedesc.h>
+#include <sys/ucred.h>
#include <net/if.h>
#include <net/route.h>
@@ -164,6 +165,18 @@ soo_stat(fp, ub, p)
bzero((caddr_t)ub, sizeof (*ub));
ub->st_mode = S_IFSOCK;
+ /*
+ * If SS_CANTRCVMORE is set, but there's still data left in the
+ * receive buffer, the socket is still readable.
+ */
+ if ((so->so_state & SS_CANTRCVMORE) == 0 ||
+ so->so_rcv.sb_cc != 0)
+ ub->st_mode |= S_IRUSR | S_IRGRP | S_IROTH;
+ if ((so->so_state & SS_CANTSENDMORE) == 0)
+ ub->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
+ ub->st_size = so->so_rcv.sb_cc;
+ ub->st_uid = so->so_cred->cr_uid;
+ ub->st_gid = so->so_cred->cr_gid;
return ((*so->so_proto->pr_usrreqs->pru_sense)(so, ub));
}