Re: did vfs_read or something related to it get broken?

2017-06-30 Thread David F.
Answer: No nothing got broken except the driver itself.

On Fri, Jun 30, 2017 at 4:10 PM, David F.  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, );
>
>   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);
> }


Re: did vfs_read or something related to it get broken?

2017-06-30 Thread David F.
Answer: No nothing got broken except the driver itself.

On Fri, Jun 30, 2017 at 4:10 PM, David F.  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, );
>
>   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);
> }


did vfs_read or something related to it get broken?

2017-06-30 Thread David F.
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, );

  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);
}


did vfs_read or something related to it get broken?

2017-06-30 Thread David F.
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, );

  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);
}