Skip to content

Commit

Permalink
Allow pipes to be stat'ed
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Jan 6, 2025
1 parent bdfca83 commit f81c931
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/library_pipefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ addToLibrary({
// refcnt 2 because pipe has a read end and a write end. We need to be
// able to read from the read end after write end is closed.
refcnt : 2,
timestamp: new Date(),
};

pipe.buckets.push({
Expand Down Expand Up @@ -60,6 +61,25 @@ addToLibrary({
};
},
stream_ops: {
getattr(stream) {
var node = stream.node;
var timestamp = node.pipe.timestamp;
return {
dev: 14,
ino: node.id,
mode: 0o10600,
nlink: 1,
uid: 0,
gid: 0,
rdev: 0,
size: 0,
atime: timestamp,
mtime: timestamp,
ctime: timestamp,
blksize: 4096,
blocks: 0,
};
},
poll(stream) {
var pipe = stream.node.pipe;

Expand Down
5 changes: 5 additions & 0 deletions test/unistd/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <poll.h>
#include <errno.h>
Expand Down Expand Up @@ -65,6 +66,10 @@ int test_most() {

assert(pipe(fd) == 0);

// Test that pipe is statable
struct stat st;
assert(fstat(fd[0], &st) == 0);

// Test that pipe is not seekable

memset(buf, 0, sizeof buf);
Expand Down

0 comments on commit f81c931

Please sign in to comment.