FreeNOS
Data Structures | Macros | Functions
stat.h File Reference
#include <FileSystem.h>
#include <Macros.h>
#include <errno.h>
#include <time.h>
#include "types.h"

Go to the source code of this file.

Data Structures

struct  stat
 The <sys/stat.h> header shall define the stat structure. More...
 

Macros

#define FILETYPE_BITS   3
 Number of bits needed to store a FileType. More...
 
#define FILETYPE_MASK   7
 Masker value for all FileTypes. More...
 
#define FILEMODE_BITS   9
 Number of bits required for all FileModes. More...
 
#define FILEMODE_MASK   0777
 Masker value for all FileMode values. More...
 
File stat type bits.

The <sys/stat.h> header shall define the following symbolic constants for the file types encoded in type mode_t.

The values shall be suitable for use in #if preprocessing directives.

#define S_IFMT   (FILETYPE_MASK << FILEMODE_BITS)
 Type of file. More...
 
#define S_IFBLK   (FileSystem::BlockDeviceFile << FILEMODE_BITS)
 Block special. More...
 
#define S_IFCHR   (FileSystem::CharacterDeviceFile << FILEMODE_BITS)
 Character special. More...
 
#define S_IFIFO   (FileSystem::FIFOFile << FILEMODE_BITS)
 FIFO special. More...
 
#define S_IFREG   (FileSystem::RegularFile << FILEMODE_BITS)
 Regular. More...
 
#define S_IFDIR   (FileSystem::DirectoryFile << FILEMODE_BITS)
 Directory. More...
 
#define S_IFLNK   (FileSystem::SymlinkFile << FILEMODE_BITS)
 Symbolic link. More...
 
#define S_IFSOCK   (FileSystem::SocketFile << FILEMODE_BITS)
 Socket. More...
 
#define S_IRWXU   FileSystem::OwnerRWX
 File mode bits. More...
 
#define S_IRUSR   FileSystem::OwnerR
 Read permission, owner. More...
 
#define S_IWUSR   FileSystem::OwnerW
 Write permission, owner. More...
 
#define S_IXUSR   FileSystem::OwnerX
 Execute/search permission, owner. More...
 
#define S_IRWXG   FileSystem::GroupRWX
 Read, write, execute/search by group. More...
 
#define S_IRGRP   FileSystem::GroupR
 Read permission, group. More...
 
#define S_IWGRP   FileSystem::GroupW
 Write permission, group. More...
 
#define S_IXGRP   FileSystem::GroupX
 Execute/search permission, group. More...
 
#define S_IRWXO   FileSystem::OtherRWX
 Read, write, execute/search by others. More...
 
#define S_IROTH   FileSystem::OtherR
 Read permission, others. More...
 
#define S_IWOTH   FileSystem::OtherW
 Write permission, others. More...
 
#define S_IXOTH   FileSystem::OtherX
 Execute/search permission, others. More...
 
File type macros.

The following macros shall be provided to test whether a file is of the specified type.

The value m supplied to the macros is the value of st_mode from a stat structure. The macro shall evaluate to a non-zero value if the test is true; 0 if the test is false.

#define S_ISTYPE(mode, mask)   (((mode) & S_IFMT) == (mask))
 Test for mode bits. More...
 
#define S_ISBLK(m)   S_ISTYPE(m, S_IFBLK)
 Test for a block special file. More...
 
#define S_ISCHR(m)   S_ISTYPE(m, S_IFCHR)
 Test for a character special file. More...
 
#define S_ISDIR(m)   S_ISTYPE(m, S_IFDIR)
 Test for a directory. More...
 
#define S_ISFIFO(m)   S_ISTYPE(m, S_IFIFO)
 Test for a pipe or FIFO special file. More...
 
#define S_ISREG(m)   S_ISTYPE(m, S_IFREG)
 Test for a regular file. More...
 
#define S_ISLNK(m)   S_ISTYPE(m, S_IFLNK)
 Test for a symbolic link. More...
 
#define S_ISSOCK(m)   S_ISTYPE(m, S_IFSOCK)
 Test for a socket. More...
 

Functions

C int stat (const char *path, struct stat *buf)
 Get file status. More...
 
C int mknod (const char *path, mode_t mode, dev_t dev)
 Make directory, special file, or regular file. More...
 
C int mkdir (const char *path, mode_t mode)
 Create a new directory. More...
 
C int creat (const char *path, mode_t mode)
 Create a new file or rewrite an existing one. More...