diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index ecfb4adca6d3..c29ecc6445f6 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -174,6 +174,14 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred, *(int *)data = so->so_snd.sb_cc; break; + case FIONSPACE: + if ((so->so_snd.sb_hiwat < so->so_snd.sb_cc) || + (so->so_snd.sb_mbmax < so->so_snd.sb_mbcnt)) + *(int *)data = 0; + else + *(int *)data = sbspace(&so->so_snd); + break; + case FIOSETOWN: error = fsetown(*(int *)data, &so->so_sigio); break; diff --git a/sys/sys/filio.h b/sys/sys/filio.h index 68e7852a4ceb..1710ba45e6c5 100644 --- a/sys/sys/filio.h +++ b/sys/sys/filio.h @@ -56,6 +56,7 @@ struct fiodgname_arg { }; #define FIODGNAME _IOW('f', 120, struct fiodgname_arg) /* get dev. name */ #define FIONWRITE _IOR('f', 119, int) /* get # bytes (yet) to write */ +#define FIONSPACE _IOR('f', 118, int) /* get space in send queue */ /* Handle lseek SEEK_DATA and SEEK_HOLE for holey file knowledge. */ #define FIOSEEKDATA _IOWR('f', 97, off_t) /* SEEK_DATA */ #define FIOSEEKHOLE _IOWR('f', 98, off_t) /* SEEK_HOLE */