From: Andreas Hartmann <andihartmann@01019freenet.de>
To: linux-kernel@vger.kernel.org
Subject: f_op->read seems to be always NULL since Linux 4.1
Date: Sat, 27 Jun 2015 19:32:39 +0200 [thread overview]
Message-ID: <mmmmkc$5dp$1@327.eternal-september.org> (raw)
Hello!
Given is a module like the following snippet running fine w/ Linux 4.0
and ext4 fs - but doesn't work w/ Linux 4.1 because f->f_op->read is not
defined any more (= NULL). Is this the intended behavior now?
vfs_read(f, buf, 128, &f->f_pos) works fine.
module.c
--------------------------------------------------------------------
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
int init_module(void)
{
struct file *f;
char buf[128];
mm_segment_t fs;
int i;
int len=128;
for(i=0;i<len;i++)
buf[i] = 0;
printk(KERN_INFO "My module is loaded\n");
f = filp_open("/etc/fedora-release", O_RDONLY, 0);
if(f == NULL)
printk(KERN_ALERT "filp_open error!!.\n");
else{
fs = get_fs();
set_fs(get_ds());
if (f->f_op->read) {
f->f_op->read(f, buf, len, &f->f_pos);
printk(KERN_INFO "buf:%s\n",buf);
}
else {
printk(KERN_INFO "No read method\n");
}
set_fs(fs);
}
filp_close(f,NULL);
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "My module is unloaded\n");
}
-----------------------------------------------------------
Makefile:
-----------------------------------------------------------
obj-m += module.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
------------------------------------------------------------
Regards,
Andreas
next reply other threads:[~2015-06-27 18:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-27 17:32 Andreas Hartmann [this message]
2015-06-27 18:10 ` f_op->read seems to be always NULL since Linux 4.1 Richard Weinberger
2015-06-28 6:36 ` Andreas Hartmann
2015-06-28 7:38 ` Richard Weinberger
2015-06-28 8:30 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='mmmmkc$5dp$1@327.eternal-september.org' \
--to=andihartmann@01019freenet.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox