fs/char_dev.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/char_dev.c b/fs/char_dev.c index 00dfe17871ac..e5ffebdf80d5 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c @@ -367,6 +367,16 @@ void cdev_put(struct cdev *p) } } +static int might_be_stream(struct inode *inode, struct file *file) +{ + const struct file_operations *fops = file->f_op; + + if (fops->llseek && fops->llseek != no_llseek) + return 0; + + return stream_open(inode, file); +} + /* * Called every time a character special file is opened */ @@ -416,7 +426,7 @@ static int chrdev_open(struct inode *inode, struct file *filp) goto out_cdev_put; } - return 0; + return might_be_stream(inode, filp); out_cdev_put: cdev_put(p);