Skip to content

[FS] Allow pipes to be stat'ed #23306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/lib/libpipefs.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
Loading