fs/inode/fs_files.c
/****************************************************************************
 * Name: nx_close
 *
 * Description:
 *   nx_close() is similar to the standard 'close' interface except that is
 *   not a cancellation point and it does not modify the errno variable.
 *
 *   nx_close() is an internal NuttX interface and should not be called from
 *   applications.
 *
 *   Close an inode (if open)
 *
 * Returned Value:
 *   Zero (OK) is returned on success; A negated errno value is returned on
 *   on any failure.
 *
 * Assumptions:
 *   Caller holds the list semaphore because the file descriptor will be
 *   freed.
 *
 ****************************************************************************/
nx_close
Description:
nx_close() is similar to the standard 'close' interface except that is
not a cancellation point and it does not modify the errno variable.

nx_close() is an internal NuttX interface and should not be called from
applications.

Close an inode (if open)

Returned Value:
Zero (OK) is returned on success; A negated errno value is returned on
on any failure.

Caller holds the list semaphore because the file descriptor will be
freed.
nx_close Description : nx_close () is similar to the standard ' close ' interface except that is not a cancellation point and it does not modify the errno variable . nx_close () is an internal NuttX interface and should not be called from applications . Close an inode ( if open ) Returned Value : Zero ( OK ) is returned on success ; A negated errno value is returned on on any failure . Caller holds the list semaphore because the file descriptor will be freed .
int nx_close(int fd)
{
  FAR struct filelist *list;
  int                  ret;
  list = nxsched_get_files();
  DEBUGASSERT(list != NULL);
  if (fd < 0 || fd >= CONFIG_NFILE_DESCRIPTORS ||
      !list->fl_files[fd].f_inode)
    {
      return -EBADF;
    }
  ret = _files_semtake(list);
  if (ret >= 0)
    {
      ret = file_close(&list->fl_files[fd]);
      _files_semgive(list);
    }
  return ret;
}
int nx_close ( int fd ) { FAR struct filelist * list ; int ret ; list = nxsched_get_files ( ) ; DEBUGASSERT ( list != NULL ) ; if ( fd < 0 || fd >= CONFIG_NFILE_DESCRIPTORS || ! list -> fl_files [ fd ] . f_inode ) { return - EBADF ; } ret = _files_semtake ( list ) ; if ( ret >= 0 ) { ret = file_close ( & list -> fl_files [ fd ] ) ; _files_semgive ( list ) ; } return ret ; }
Name: nx_close
 Description:
   nx_close() is similar to the standard 'close' interface except that is
   not a cancellation point and it does not modify the errno variable.
Name : nx_close Description : nx_close () is similar to the standard ' close ' interface except that is not a cancellation point and it does not modify the errno variable .
/* Get the thread-specific file list.  It should never be NULL in this
   * context.
   */ /* If the file was properly opened, there should be an inode assigned */ /* Perform the protected close operation */