From: Andrei Tatar Date: Wed, 19 Mar 2025 12:37:23 +0000 (+0100) Subject: lib/posix-pipe: Add pipe stat support X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=6dadb454e5b509113f5b39bd0849684cb2396382;p=unikraft%2Funikraft.git lib/posix-pipe: Add pipe stat support This change implements a real getstat operation for pipes, returning basic information about an open pipe. Signed-off-by: Andrei Tatar Approved-by: Sergiu Moga Reviewed-by: Sergiu Moga GitHub-Closes: #1603 --- diff --git a/lib/posix-pipe/pipe.c b/lib/posix-pipe/pipe.c index 3ee53cf2a..106171d5f 100644 --- a/lib/posix-pipe/pipe.c +++ b/lib/posix-pipe/pipe.c @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -318,10 +319,21 @@ out_full: return -EAGAIN; } +static int pipe_getstat(const struct uk_file *f, unsigned mask __unused, + struct uk_statx *arg) +{ + /* All data is immediately available, ignore mask */ + arg->stx_mask = UK_STATX_TYPE | UK_STATX_MODE | UK_STATX_INO; + arg->stx_blksize = 1; + arg->stx_mode = S_IFIFO | 0600; + arg->stx_ino = (uintptr_t)f; + return 0; +} + static const struct uk_file_ops rpipe_ops = { .read = pipe_read, .write = uk_file_nop_write, - .getstat = uk_file_nop_getstat, + .getstat = pipe_getstat, .setstat = uk_file_nop_setstat, .ctl = uk_file_nop_ctl }; @@ -329,7 +341,7 @@ static const struct uk_file_ops rpipe_ops = { static const struct uk_file_ops wpipe_ops = { .read = uk_file_nop_read, .write = pipe_write, - .getstat = uk_file_nop_getstat, + .getstat = pipe_getstat, .setstat = uk_file_nop_setstat, .ctl = uk_file_nop_ctl };