From eb3d2c61b44836b51b956726eb887af0a40b738d Mon Sep 17 00:00:00 2001
From: Mike Silbersack <silby@FreeBSD.org>
Date: Tue, 20 Jul 2004 07:06:43 +0000
Subject: [PATCH] Fix a minor error in pipe_stat - st_size was always reported
 as 0 when direct writes kicked in.  Whether this affected any applications is
 unknown.

---
 sys/kern/sys_pipe.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index aa0445ee6c6f..fa578e804ec8 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1353,7 +1353,10 @@ pipe_stat(fp, ub, active_cred, td)
 	bzero(ub, sizeof(*ub));
 	ub->st_mode = S_IFIFO;
 	ub->st_blksize = pipe->pipe_buffer.size;
-	ub->st_size = pipe->pipe_buffer.cnt;
+	if (pipe->pipe_state & PIPE_DIRECTW)
+		ub->st_size = pipe->pipe_map.cnt;
+	else
+		ub->st_size = pipe->pipe_buffer.cnt;
 	ub->st_blocks = (ub->st_size + ub->st_blksize - 1) / ub->st_blksize;
 	ub->st_atimespec = pipe->pipe_atime;
 	ub->st_mtimespec = pipe->pipe_mtime;