pipe: export size and blocks via system call fstat(2)
PATCH 1/1 pipe: export size and blocks via system call fstat(2)
export size and blocks via system call fstat(2)
pipe or fifo doesn't support fstat(2). This patch makes it possible to check the amount of data buffered in a pipe or fifo, and the pages used to store this data via fstat(2).
Signed-off-by Changli Gao <[email protected]>
----
fs/inode.c | 5 +++-- fs/pipe.c | 51 ++++++++++++++++++++++++++++++++++++++++----------- include/linux/fs.h | 1 + 3 files changed, 44 insertions(+), 13 deletions(-)
fs/inode.c +3 -2
@@ -1598,9 +1598,10 @@ void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev) }else if (S_ISBLK (mode)) { inode->i_fop = &def_blk_fops; inode->i_rdev = rdev; - }else if (S_ISFIFO (mode)) + }else if (S_ISFIFO (mode)) { + inode->i_op = &pipe_iops; inode->i_fop = &def_fifo_fops; -else if (S_ISSOCK (mode)) + }else if (S_ISSOCK (mode)) inode->i_fop = &bad_sock_fops;else printk(KERN_DEBUG "init_special_inode: bogus i_mode (%o) for"
fs/pipe.c +40 -11
77 lines not on this page · raw message
include/linux/fs.h +1 -0
@@ -1973,6 +1973,7 @@ extern const struct file_operations def_blk_fops;extern const struct file_operations def_chr_fops;extern const struct file_operations bad_sock_fops;extern const struct file_operations def_fifo_fops; +extern const struct inode_operations pipe_iops;#ifdef CONFIG_BLOCK extern int ioctl_by_bdev (struct block_device *,unsigned ,unsigned long );extern int blkdev_ioctl (struct block_device *,fmode_t ,unsigned ,unsigned long );