Services and Modeling for Embedded Software Development
Embecosm divider strip
Prev  Next

5.3.16.  Status of a File (by Name), stat

For a namespace clean function, implement _stat, otherwise implement stat. The detailed implementation will depend on the file handling functionality available.

A minimal implementation should assume that all files are character special devices and populate the status data structure accordingly.

#include <sys/stat.h>

int
_stat (char        *file,
       struct stat *st)
{
  st->st_mode = S_IFCHR;
  return 0;

}       /* _stat () */
	  

The OpenRISC 1000  implementation takes a stricter view of this. Since no named files are supported, this function always fails.

#include <errno.h>
#include <sys/stat.h>

#undef errno
extern int  errno;

int
_stat (char        *file,
       struct stat *st)
{
  errno = EACCES;
  return  -1;

}       /* _stat () */
	  
Embecosm divider strip