fs/vfs/fs_write.c
ssize_t file_write(struct file *filep, const void *buf, size_t nbytes)
{
  int ret;
  int err;

  if (buf == NULL)
    {
      err = EFAULT;
      goto errout;
    }

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

  if ((((unsigned int)(filep->f_oflags)) & O_ACCMODE) == O_RDONLY)
    {
      err = EACCES;
      goto errout;
    }

  /* Is a driver registered? Does it support the write method? */

  if (!filep->ops || !filep->ops->write)
    {
      err = EBADF;
      goto errout;
    }

  /* Yes, then let the driver perform the write */

  ret = filep->ops->write(filep, (const char *)buf, nbytes);
  if (ret < 0)
    {
      err = -ret;
      goto errout;
    }

  return ret;

errout:
  set_errno(err);
  return VFS_ERROR;
}
/****************************************************************************
 * Name: file_write
 *
 * Description:
 *   Equivalent to the standard write() function except that is accepts a
 *   struct file instance instead of a file descriptor.  It is functionally
 *   equivalent to write() except that in addition to the differences in
 *   input paramters:
 *
 *  - It does not modify the errno variable,
 *  - It is not a cancellation point, and
 *  - It does not handle socket descriptors.
 *
 * Input Parameters:
 *   filep  - Instance of struct file to use with the write
 *   buf    - Data to write
 *   nbytes - Length of data to write
 *
 * Returned Value:
 *  On success, the number of bytes written are returned (zero indicates
 *  nothing was written).  On any failure, a negated errno value is returned
 *  (see comments withwrite() for a description of the appropriate errno
 *  values).
 *
 ****************************************************************************/
file_write
Description:
Equivalent to the standard write() function except that is accepts a
struct file instance instead of a file descriptor.  It is functionally
equivalent to write() except that in addition to the differences in
input paramters.

- It does not modify the errno variable,
- It is not a cancellation point, and
- It does not handle socket descriptors.

Input Parameters:
filep  - Instance of struct file to use with the write
buf    - Data to write
nbytes - Length of data to write

Returned Value:
On success, the number of bytes written are returned (zero indicates
nothing was written).  On any failure, a negated errno value is returned
for a description of the appropriate errno
values).
file_write Description : Equivalent to the standard write () function except that is accepts a struct file instance instead of a file descriptor . It is functionally equivalent to write () except that in addition to the differences in input paramters . - It does not modify the errno variable - It is not a cancellation point and - It does not handle socket descriptors . Input Parameters : filep - Instance of struct file to use with the write buf - Data to write nbytes - Length of data to write Returned Value : On success the number of bytes written are returned ( zero indicates nothing was written ) . On any failure a negated errno value is returned for a description of the appropriate errno values ) .
ssize_t file_write(struct file *filep, const void *buf, size_t nbytes)
{
  int ret;
  int err;
  if (buf == NULL)
    {
      err = EFAULT;
      goto errout;
    }
  if ((((unsigned int)(filep->f_oflags)) & O_ACCMODE) == O_RDONLY)
    {
      err = EACCES;
      goto errout;
    }
  if (!filep->ops || !filep->ops->write)
    {
      err = EBADF;
      goto errout;
    }
  ret = filep->ops->write(filep, (const char *)buf, nbytes);
  if (ret < 0)
    {
      err = -ret;
      goto errout;
    }
  return ret;
errout:
  set_errno(err);
  return VFS_ERROR;
}
ssize_t file_write ( struct file * filep , const void * buf , size_t nbytes ) { int ret ; int err ; if ( buf == NULL ) { err = EFAULT ; goto errout ; } if ( ( ( ( unsigned int ) ( filep -> f_oflags ) ) & O_ACCMODE ) == O_RDONLY ) { err = EACCES ; goto errout ; } if ( ! filep -> ops || ! filep -> ops -> write ) { err = EBADF ; goto errout ; } ret = filep -> ops -> write ( filep , ( const char * ) buf , nbytes ) ; if ( ret < 0 ) { err = - ret ; goto errout ; } return ret ; errout : set_errno ( err ) ; return VFS_ERROR ; }
Name: file_write
 Description:
   Equivalent to the standard write() function except that is accepts a
   struct file instance instead of a file descriptor.
Name : file_write Description : Equivalent to the standard write () function except that is accepts a struct file instance instead of a file descriptor .
/* Was this file opened for write access? */ /* Is a driver registered? Does it support the write method? */ /* Yes, then let the driver perform the write */