Skip to content

Commit b0aab5a

Browse files
committed
Allow pipes to be stat'ed
1 parent 5cdda14 commit b0aab5a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/lib/libpipefs.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ addToLibrary({
2020
// refcnt 2 because pipe has a read end and a write end. We need to be
2121
// able to read from the read end after write end is closed.
2222
refcnt : 2,
23+
timestamp: new Date(),
2324
};
2425

2526
pipe.buckets.push({
@@ -60,6 +61,25 @@ addToLibrary({
6061
};
6162
},
6263
stream_ops: {
64+
getattr(stream) {
65+
var node = stream.node;
66+
var timestamp = node.pipe.timestamp;
67+
return {
68+
dev: 14,
69+
ino: node.id,
70+
mode: 0o10600,
71+
nlink: 1,
72+
uid: 0,
73+
gid: 0,
74+
rdev: 0,
75+
size: 0,
76+
atime: timestamp,
77+
mtime: timestamp,
78+
ctime: timestamp,
79+
blksize: 4096,
80+
blocks: 0,
81+
};
82+
},
6383
poll(stream) {
6484
var pipe = stream.node.pipe;
6585

test/unistd/pipe.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <unistd.h>
99
#include <sys/types.h>
10+
#include <sys/stat.h>
1011
#include <fcntl.h>
1112
#include <poll.h>
1213
#include <errno.h>
@@ -65,6 +66,10 @@ int test_most() {
6566

6667
assert(pipe(fd) == 0);
6768

69+
// Test that pipe is statable
70+
struct stat st;
71+
assert(fstat(fd[0], &st) == 0);
72+
6873
// Test that pipe is not seekable
6974

7075
memset(buf, 0, sizeof buf);

0 commit comments

Comments
 (0)