bfsStatFirst()
PROTOTYPE
#include <bfs.h>
int bfsStatFirst(BfsStat *buf);
DESCRIPTION
bfsStatFirst() outputs information on the volume’s first file and resets a counter so that successive bfsStatNext() calls walk a list of volume files. buf points to a BfsStat structure, defined in “bfs.h” and reproduced below, that the file information is written to.
typedef struct
{
char *fname; /* null-terminated file name */
ui32 size; /* file size in bytes */
ui32 rd_cnt; /* number times read since last boot */
ui32 wr_seq; /* f-node sequence # when file written */
ui8 num_ext; /* current number of extents used */
ui8 max_ext; /* maximum number of extents used */
ui8 flags; /* may contain RECYCLE_REQ (NAND only) */
} BfsStat;
If successful, bfsStatFirst() returns 0. Otherwise, it sets errno and returns -1.
ERROR CODES
| EFAULT | buf equals NULL. |
| EMFILE | A file is open or a fatal error has occurred. |
| ENOENT | No files exist. |
EXAMPLE
static void sh_ls(char *cmd_line)
{
BfsStat stat;
/*-------------------------------------------------------------------*/
/* Read file statistics for the first file. */
/*-------------------------------------------------------------------*/
if (bfsStatFirst(&stat) < 0)
{
if (errno == EMFILE)
puts(" File is open");
return;
}