Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1679210 > unrolled thread
| Started by | "David F." <df7729@gmail.com> |
|---|---|
| First post | 2017-07-01 01:20 +0200 |
| Last post | 2017-07-01 07:20 +0200 |
| Articles | 2 — 1 participant |
Back to article view | Back to linux.kernel
did vfs_read or something related to it get broken? "David F." <df7729@gmail.com> - 2017-07-01 01:20 +0200
Re: did vfs_read or something related to it get broken? "David F." <df7729@gmail.com> - 2017-07-01 07:20 +0200
| From | "David F." <df7729@gmail.com> |
|---|---|
| Date | 2017-07-01 01:20 +0200 |
| Subject | did vfs_read or something related to it get broken? |
| Message-ID | <tYdmF-3lY-5@gated-at.bofh.it> |
Hi,
I have a driver that reads data from a file that has worked from
kernel 3.x up to 4.9.13. I haven't tried all the other 4.9's or 4.10,
or 4.11.6 or earlier, but in 4.11.7 it's now broken and an error is
returned. It's based on
http://krishnamohanlinux.blogspot.com/2013/12/how-to-write-to-file-from-kernel-module.html
Is there a new requirement of some sort or did it get broken?
int driver_file_read(struct file *file, unsigned char *data, unsigned int size)
{
int ret;
mm_segment_t oldfs;
// get file pointer
loff_t pos = file->f_pos;
oldfs = get_fs();
set_fs(get_ds());
ret=vfs_read(file, data, size, &pos);
set_fs(oldfs);
// update file pointer
file->f_pos=pos;
return (ret);
}
struct file *driver_file_open(const char *path, int flags, int mode, int *err)
{
int ec=0;
struct file *filp = NULL;
filp=filp_open(path, flags, mode);
if (IS_ERR(filp)) {
ec=PTR_ERR(filp);
filp=NULL;
}
// update callers error code
if (err) {
*err=ec;
}
// return pointer to file
return (filp);
}
[toc] | [next] | [standalone]
| From | "David F." <df7729@gmail.com> |
|---|---|
| Date | 2017-07-01 07:20 +0200 |
| Message-ID | <tYiZ3-7a4-3@gated-at.bofh.it> |
| In reply to | #1679210 |
Answer: No nothing got broken except the driver itself.
On Fri, Jun 30, 2017 at 4:10 PM, David F. <df7729@gmail.com> wrote:
> Hi,
>
> I have a driver that reads data from a file that has worked from
> kernel 3.x up to 4.9.13. I haven't tried all the other 4.9's or 4.10,
> or 4.11.6 or earlier, but in 4.11.7 it's now broken and an error is
> returned. It's based on
> http://krishnamohanlinux.blogspot.com/2013/12/how-to-write-to-file-from-kernel-module.html
>
> Is there a new requirement of some sort or did it get broken?
>
> int driver_file_read(struct file *file, unsigned char *data, unsigned int size)
> {
> int ret;
> mm_segment_t oldfs;
>
> // get file pointer
> loff_t pos = file->f_pos;
>
> oldfs = get_fs();
> set_fs(get_ds());
>
> ret=vfs_read(file, data, size, &pos);
>
> set_fs(oldfs);
>
> // update file pointer
> file->f_pos=pos;
>
> return (ret);
> }
>
>
> struct file *driver_file_open(const char *path, int flags, int mode, int *err)
> {
> int ec=0;
> struct file *filp = NULL;
> filp=filp_open(path, flags, mode);
> if (IS_ERR(filp)) {
> ec=PTR_ERR(filp);
> filp=NULL;
> }
> // update callers error code
> if (err) {
> *err=ec;
> }
> // return pointer to file
> return (filp);
> }
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web