Add stat()

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@257 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2007-05-27 18:08:18 +00:00
parent 0c8bb6aac5
commit a0153a1ed2
17 changed files with 612 additions and 113 deletions
+69 -2
View File
@@ -1,5 +1,5 @@
/************************************************************
* stat.h
* sys/stat.h
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
@@ -41,11 +41,76 @@
************************************************************/
#include <sys/types.h>
#include <time.h>
/************************************************************
* Definitions
************************************************************/
/* mode_t bit settings (most of these do not apply to Nuttx).
* This assumes that the full size of a mode_t is 16-bits.
* (However, mode_t must be size 'int' because it is promoted
* to size int when passed in varargs).
*/
#define S_IXOTH 0000001 /* Permissions for others: RWX */
#define S_IWOTH 0000002
#define S_IROTH 0000004
#define S_IRWXO 0000007
#define S_IXGRP 0000010 /* Group permissions: RWX */
#define S_IWGRP 0000020
#define S_IRGRP 0000040
#define S_IRWXG 0000070
#define S_IXUSR 0000100 /* Owner permissions: RWX */
#define S_IWUSR 0000200
#define S_IRUSR 0000400
#define S_IRWXU 0000700
#define S_ISVTX 0001000 /* "sticky" bit */
#define S_ISGID 0002000 /* Set group ID bit */
#define S_ISUID 0004000 /* Set UID bit */
#define S_IFIFO 0010000 /* File type bites */
#define S_IFCHR 0020000
#define S_IFDIR 0040000
#define S_IFBLK 0060000
#define S_IFREG 0100000
#define S_IFLNK 0120000
#define S_IFSOCK 0140000
#define S_IFMT 0170000
/* File type macros that operate on an instance of mode_t */
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
/************************************************************
* Type Definitions
************************************************************/
/* This is the simplified struct stat as returned by fstat().
* This structure provides information about a specific file
* or directory in the file system.
*/
struct stat
{
mode_t st_mode; /* File type, atributes, and access mode bits */
off_t st_size; /* Size of file/directory, in bytes */
blksize_t st_blksize; /* Blocksize used for filesystem I/O */
blkcnt_t st_blocks; /* Number of blocks allocated*/
time_t st_atime; /* Time of last access */
time_t st_mtime; /* Time of last modification */
time_t st_ctime; /* Time of last status change */
};
/************************************************************
* Global Function Prototypes
************************************************************/
@@ -58,7 +123,9 @@ extern "C" {
#define EXTERN extern
#endif
EXTERN int mkdir(const char *pathname, mode_t mode);
EXTERN int mkdir(FAR const char *pathname, mode_t mode);
EXTERN int stat(const char *path, FAR struct stat *buf);
EXTERN int fstat(int fd, FAR struct stat *buf);
#undef EXTERN
#if defined(__cplusplus)