diff options
Diffstat (limited to 'nuttx/include')
-rw-r--r-- | nuttx/include/fcntl.h | 32 | ||||
-rw-r--r-- | nuttx/include/nuttx/fs.h | 1 | ||||
-rw-r--r-- | nuttx/include/stdio.h | 25 | ||||
-rw-r--r-- | nuttx/include/sys/stat.h | 71 | ||||
-rw-r--r-- | nuttx/include/sys/types.h | 35 |
5 files changed, 90 insertions, 74 deletions
diff --git a/nuttx/include/fcntl.h b/nuttx/include/fcntl.h index 1949be42a..10780da2c 100644 --- a/nuttx/include/fcntl.h +++ b/nuttx/include/fcntl.h @@ -104,38 +104,6 @@ #define DN_RENAME 4 /* A file was renamed */ #define DN_ATTRIB 5 /* Attributes of a file were changed */ -#define S_IFMT 0170000 -#define S_IFSOCK 0140000 -#define S_IFLNK 0120000 -#define S_IFREG 0100000 -#define S_IFBLK 0060000 -#define S_IFCHR 0020000 -#define S_IFDIR 0040000 -#define S_IFIFO 0010000 -#define S_ISUID 0004000 -#define S_ISGID 0002000 -#define S_ISVTX 0001000 -#define S_IRWXU 0000700 -#define S_IRUSR 0000400 -#define S_IWUSR 0000200 -#define S_IXUSR 0000100 -#define S_IRWXG 0000070 -#define S_IRGRP 0000040 -#define S_IWGRP 0000020 -#define S_IXGRP 0000010 -#define S_IRWXO 0000007 -#define S_IROTH 0000004 -#define S_IWOTH 0000002 -#define S_IXOTH 0000001 - -#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) - /******************************************************************************** * Public Type Definitions ********************************************************************************/ diff --git a/nuttx/include/nuttx/fs.h b/nuttx/include/nuttx/fs.h index c703bcf36..efb3251f2 100644 --- a/nuttx/include/nuttx/fs.h +++ b/nuttx/include/nuttx/fs.h @@ -163,6 +163,7 @@ struct mountpt_operations int (*mkdir)(struct inode *mountpt, const char *relpath, mode_t mode); int (*rmdir)(struct inode *mountpt, const char *relpath); int (*rename)(struct inode *mountpt, const char *oldrelpath, const char *newrelpath); + int (*stat)(struct inode *mountpt, const char *relpath, struct stat *buf); /* NOTE: More operations will be needed here to support: disk usage stats * file stat(), file attributes, file truncation, etc. diff --git a/nuttx/include/stdio.h b/nuttx/include/stdio.h index bdad75eb6..592ded26a 100644 --- a/nuttx/include/stdio.h +++ b/nuttx/include/stdio.h @@ -80,29 +80,6 @@ * Public Type Definitions ************************************************************/ -struct stat -{ - dev_t st_dev; /* ID of device containing a */ - /* directory entry for this file */ - ino_t st_ino; /* Inode number */ - unsigned short st_mode; /* File type, attributes, and */ - /* access control summary */ - unsigned short st_nlink; /* Number of links */ - uid_t st_uid; /* User ID of file owner */ - gid_t st_gid; /* Group ID of file group */ - dev_t st_rdev; /* Device ID; this entry defined */ - /* only for char or blk spec files */ - off_t st_size; /* File size (bytes) */ - time_t st_atime; /* Time of last access */ - time_t st_mtime; /* Last modification time */ - time_t st_ctime; /* Last file status change time */ - /* Measured in secs since */ - /* 00:00:00 GMT, Jan 1, 1970 */ - long st_blksize; /* Non-standard, Wind-River field */ - unsigned long st_blocks; /* Non-standard, Wind-River field */ - long st_gen; /* file generation value: Non-standard, Wind-River field */ -}; - struct statfs { long f_bavail; /* free blocks available to non-superuser */ @@ -166,9 +143,7 @@ EXTERN int vsprintf(char *buf, const char *s, va_list ap); EXTERN int chdir(const char *path); EXTERN FILE *fdopen(int fd, const char *type); -EXTERN int fstat(int fd, FAR struct stat *buf); EXTERN char *getcwd(FAR char *buf, size_t size); -EXTERN int stat(const char *path, FAR struct stat *buf); EXTERN int statfs(const char *path, FAR struct statfs *buf); #undef EXTERN diff --git a/nuttx/include/sys/stat.h b/nuttx/include/sys/stat.h index 0d686e10f..20fbc3a59 100644 --- a/nuttx/include/sys/stat.h +++ b/nuttx/include/sys/stat.h @@ -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) diff --git a/nuttx/include/sys/types.h b/nuttx/include/sys/types.h index 916681c39..97b2d7eed 100644 --- a/nuttx/include/sys/types.h +++ b/nuttx/include/sys/types.h @@ -99,24 +99,29 @@ typedef double double_t; /* Misc. scalar types */ -typedef unsigned int mode_t; +typedef unsigned int mode_t; /* Needs at least 16-bits but must be */ + /* sizeof(int) because it is passed */ + /* via varargs. */ #ifdef CONFIG_SMALL_MEMORY -typedef uint16 size_t; -typedef sint16 ssize_t; -typedef sint16 off_t; +typedef uint16 size_t; +typedef sint16 ssize_t; +typedef sint16 off_t; +typedef uint16 blksize_t; +typedef uint16 blkcnt_t; #else -typedef uint32 size_t; -typedef sint32 ssize_t; -typedef sint32 off_t; +typedef uint32 size_t; +typedef sint32 ssize_t; +typedef sint32 off_t; +typedef uint16 blksize_t; +typedef uint32 blkcnt_t; #endif -//typedef sint32 time_t; -typedef sint16 uid_t; -typedef sint16 gid_t; -typedef uint16 dev_t; -typedef uint16 ino_t; -typedef unsigned int sig_atomic_t; -typedef int pid_t; -typedef int STATUS; +typedef sint16 uid_t; +typedef sint16 gid_t; +typedef uint16 dev_t; +typedef uint16 ino_t; +typedef unsigned int sig_atomic_t; +typedef int pid_t; +typedef int STATUS; /* Process entry point */ |