summaryrefslogtreecommitdiff
path: root/pflocal/io.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-07-25 19:04:42 +0000
committerMiles Bader <miles@gnu.org>1995-07-25 19:04:42 +0000
commit5d4a2156ea7cacbea84b9875b6f934fa28c6284f (patch)
tree63b01619e379995a45a01061d038ebfd93ee5a46 /pflocal/io.c
parent02f33a5c89233931393b69093d43621e283702b1 (diff)
Formerly io.c.~12~
Diffstat (limited to 'pflocal/io.c')
-rw-r--r--pflocal/io.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/pflocal/io.c b/pflocal/io.c
index 7cfa64e1..fcbce170 100644
--- a/pflocal/io.c
+++ b/pflocal/io.c
@@ -294,6 +294,8 @@ error_t
S_io_stat (struct sock_user *user, struct stat *st)
{
struct sock *sock;
+ struct pipe *rpipe, *wpipe;
+
void copy_time (time_value_t *from, time_t *to_sec, unsigned long *to_usec)
{
*to_sec = from->seconds;
@@ -310,18 +312,33 @@ S_io_stat (struct sock_user *user, struct stat *st)
st->st_fstype = FSTYPE_SOCKET;
st->st_fsid = getpid ();
st->st_ino = sock->id;
-
- st->st_blksize = vm_page_size * 8;
+ /* As we try to be clever with large transfers, ask for them. */
+ st->st_blksize = vm_page_size * 16;
debug (sock, "lock");
mutex_lock (&sock->lock); /* Make sure the pipes don't go away... */
- if (sock->read_pipe)
- copy_time (&sock->read_pipe->read_time, &st->st_atime, &st->st_atime_usec);
- if (sock->write_pipe)
- copy_time (&sock->read_pipe->write_time, &st->st_mtime, &st->st_mtime_usec);
+ rpipe = sock->read_pipe;
+ wpipe = sock->write_pipe;
+
+ mutex_lock (&rpipe->lock);
+ copy_time (&rpipe->read_time, &st->st_atime, &st->st_atime_usec);
+ /* This seems useful. */
+ st->st_size = pipe_readable (rpipe, 1);
+ mutex_unlock (&rpipe->lock);
+
+ if (wpipe)
+ {
+ mutex_lock (&wpipe->lock);
+ copy_time (&wpipe->write_time, &st->st_mtime, &st->st_mtime_usec);
+ mutex_unlock (&wpipe->lock);
+ }
+
copy_time (&sock->change_time, &st->st_ctime, &st->st_ctime_usec);
+ /* When RPIPE == WPIPE, it *is* a fifo; also the fifo server uses sockets. */
+ st->st_mode = (wpipe == rpipe ? S_IFIFO : S_IFSOCK);
+
debug (sock, "unlock");
mutex_unlock (&sock->lock);