Exemple #1
0
int getdents(
  int   dd_fd,
  char *dd_buf,
  int   dd_len
)
{
  rtems_libio_t *iop;
  rtems_filesystem_node_types_t type;

  /*
   *  Get the file control block structure associated with the file descriptor
   */
  iop = rtems_libio_iop( dd_fd );

  /*
   *  Make sure we are working on a directory
   */
  type = rtems_filesystem_node_type( &iop->pathinfo );
  if ( type != RTEMS_FILESYSTEM_DIRECTORY )
    rtems_set_errno_and_return_minus_one( ENOTDIR );

  /*
   *  Return the number of bytes that were actually transfered as a result
   *  of the read attempt.
   */
  return (*iop->pathinfo.handlers->read_h)( iop, dd_buf, dd_len  );
}
Exemple #2
0
int rtems_filesystem_chdir( rtems_filesystem_location_info_t *loc )
{
  int rv = 0;
  rtems_filesystem_global_location_t *global_loc =
    rtems_filesystem_location_transform_to_global( loc );
  rtems_filesystem_node_types_t type =
    rtems_filesystem_node_type( &global_loc->location );

  if ( type == RTEMS_FILESYSTEM_DIRECTORY ) {
    rtems_filesystem_global_location_assign(
      &rtems_filesystem_current,
      global_loc
    );
  } else {
    rtems_filesystem_location_error( &global_loc->location, ENOTDIR );
    rtems_filesystem_global_location_release( global_loc );
    rv = -1;
  }

  return rv;
}