fs/vfs/fs_read.c
ssize_t file_read(struct file *filep, void *buf, size_t nbytes)
{
  int ret = -EBADF;

  if (buf == NULL)
    {
      ret = -EFAULT;
    }

  /* Was this file opened for read access? */

  else if (((unsigned int)(filep->f_oflags) & O_ACCMODE) == O_WRONLY)
    {
      /* No.. File is not read-able */

      ret = -EACCES;
    }

  /* Is a driver or mountpoint registered? If so, does it support the read
   * method?
   */

  else if (filep->ops && filep->ops->read)
    {
      /* Yes.. then let it perform the read.  NOTE that for the case of the
       * mountpoint, we depend on the read methods being identical in
       * signature and position in the operations vtable.
       */

      ret = (int)filep->ops->read(filep, (char *)buf, (size_t)nbytes);
    }

  /* If an error occurred, set errno and return -1 (ERROR) */

  if (ret < 0)
    {
      set_errno(-ret);
      return VFS_ERROR;
    }

  /* Otherwise, return the number of bytes read */

  return ret;
}
/****************************************************************************
 * Name: file_read
 *
 * Description:
 *   file_read() is an interanl OS interface.  It is functionally similar to
 *   the standard read() interface except:
 *
 *    - It does not modify the errno variable,
 *    - It is not a cancellation point,
 *    - It does not handle socket descriptors, and
 *    - It accepts a file structure instance instead of file descriptor.
 *
 * Input Parameters:
 *   filep  - File structure instance
 *   buf    - User-provided to save the data
 *   nbytes - The maximum size of the user-provided buffer
 *
 * Returned Value:
 *   The positive non-zero number of bytes read on success, 0 on if an
 *   end-of-file condition, or a negated errno value on any failure.
 *
 ****************************************************************************/
file_read
Description:
file_read() is an interanl OS interface.  It is functionally similar to
the standard read() interface except.

- It does not modify the errno variable,
- It is not a cancellation point,
- It does not handle socket descriptors, and
- It accepts a file structure instance instead of file descriptor.



Returned Value:
The positive non-zero number of bytes read on success, 0 on if an
end-of-file condition, or a negated errno value on any failure.
file_read Description : file_read () is an interanl OS interface . It is functionally similar to the standard read () interface except . - It does not modify the errno variable - It is not a cancellation point - It does not handle socket descriptors and - It accepts a file structure instance instead of file descriptor . Returned Value : The positive non - zero number of bytes read on success 0 on if an end - of - file condition or a negated errno value on any failure .
ssize_t file_read(struct file *filep, void *buf, size_t nbytes)
{
  int ret = -EBADF;
  if (buf == NULL)
    {
      ret = -EFAULT;
    }
  else if (((unsigned int)(filep->f_oflags) & O_ACCMODE) == O_WRONLY)
    {
      ret = -EACCES;
    }
  else if (filep->ops && filep->ops->read)
    {
      ret = (int)filep->ops->read(filep, (char *)buf, (size_t)nbytes);
    }
  if (ret < 0)
    {
      set_errno(-ret);
      return VFS_ERROR;
    }
  return ret;
}
ssize_t file_read ( struct file * filep , void * buf , size_t nbytes ) { int ret = - EBADF ; if ( buf == NULL ) { ret = - EFAULT ; } else if ( ( ( unsigned int ) ( filep -> f_oflags ) & O_ACCMODE ) == O_WRONLY ) { ret = - EACCES ; } else if ( filep -> ops && filep -> ops -> read ) { ret = ( int ) filep -> ops -> read ( filep , ( char * ) buf , ( size_t ) nbytes ) ; } if ( ret < 0 ) { set_errno ( - ret ) ; return VFS_ERROR ; } return ret ; }
Name: file_read
 Description:
   file_read() is an interanl OS interface.
Name : file_read Description : file_read () is an interanl OS interface .
/* Was this file opened for read access? */ /* No.. File is not read-able */ /* Is a driver or mountpoint registered? If so, does it support the read
   * method?
   */ /* Yes.. then let it perform the read.  NOTE that for the case of the
       * mountpoint, we depend on the read methods being identical in
       * signature and position in the operations vtable.
       */ /* If an error occurred, set errno and return -1 (ERROR) */ /* Otherwise, return the number of bytes read */