|
ginnOS
The reference: libc, the libraries and the kernel
|
file metadata: stat() and fstat(). More...
Go to the source code of this file.
Data Structures | |
| struct | stat |
Macros | |
| #define | S_IFMT 0170000 |
| #define | S_IFIFO 0010000 |
| #define | S_IFSOCK 0140000 |
| #define | S_IFCHR 0020000 |
| #define | S_IFDIR 0040000 |
| #define | S_IFBLK 0060000 |
| #define | S_IFREG 0100000 |
| #define | S_IFLNK 0120000 |
| #define | S_ISFIFO(m) |
| #define | S_ISCHR(m) |
| #define | S_ISDIR(m) |
| #define | S_ISBLK(m) |
| #define | S_ISREG(m) |
| #define | S_ISLNK(m) |
| #define | S_ISSOCK(m) |
| #define | S_IRWXU 0700 |
| #define | S_IRUSR 0400 |
| #define | S_IWUSR 0200 |
| #define | S_IXUSR 0100 |
| #define | S_IRWXG 0070 |
| #define | S_IRGRP 0040 |
| #define | S_IWGRP 0020 |
| #define | S_IXGRP 0010 |
| #define | S_IRWXO 0007 |
| #define | S_IROTH 0004 |
| #define | S_IWOTH 0002 |
| #define | S_IXOTH 0001 |
| #define | st_atime st_atim.tv_sec |
| #define | st_mtime st_mtim.tv_sec |
| #define | st_ctime st_ctim.tv_sec |
| #define | S_ISUID 04000 |
| #define | S_ISGID 02000 |
| #define | S_ISVTX 01000 |
| #define | UTIME_NOW ((1l << 30) - 1) |
| #define | UTIME_OMIT ((1l << 30) - 2) |
Functions | |
| int | stat (const char *path, struct stat *st) |
| get a file's metadata by path. | |
| int | lstat (const char *path, struct stat *st) |
| the metadata of a symbolic link itself (stat gives what it points at). | |
| int | fstat (int fd, struct stat *st) |
| get an open file's metadata (pipes and the console too). | |
| int | mkdir (const char *path, mode_t mode) |
| create a directory with a mode (taken through the umask). | |
| int | mkdirat (int dirfd, const char *path, mode_t mode) |
| int | fstatat (int dirfd, const char *path, struct stat *st, int flags) |
| int | fchmodat (int dirfd, const char *path, mode_t mode, int flags) |
| int | chmod (const char *path, mode_t mode) |
| change the permission bits of a file (owner or root only). | |
| int | fchmod (int fd, mode_t mode) |
| mode_t | umask (mode_t mask) |
| set the mask taken off the mode of new files. | |
| int | utimensat (int dirfd, const char *path, const struct timespec times[2], int flags) |
| set a file's access and modification times (times[0], times[1]); with times NULL, both to the time now. | |
| int | futimens (int fd, const struct timespec times[2]) |
| int | mkfifo (const char *path, mode_t mode) |
| make a named pipe (a FIFO): processes that open it share one pipe. | |
| int | mkfifoat (int dirfd, const char *path, mode_t mode) |
| int | mknod (const char *path, mode_t mode, dev_t dev) |
| make a named pipe (S_IFIFO), an empty file (S_IFREG) or, as root, a device node (S_IFCHR, S_IFBLK with makedev's number). | |
| int | mknodat (int dirfd, const char *path, mode_t mode, dev_t dev) |
file metadata: stat() and fstat().
struct stat and the S_ bits are ABI and must match the kernel side in src/kernel/vfs/stat.h exactly.
| #define S_IFMT 0170000 |
| #define S_IFIFO 0010000 |
| #define S_IFSOCK 0140000 |
| #define S_IFCHR 0020000 |
| #define S_IFDIR 0040000 |
| #define S_IFBLK 0060000 |
| #define S_IFREG 0100000 |
| #define S_IFLNK 0120000 |
| #define S_ISFIFO | ( | m | ) |
| #define S_ISSOCK | ( | m | ) |
| #define S_IRWXU 0700 |
| #define S_IRUSR 0400 |
| #define S_IWUSR 0200 |
| #define S_IXUSR 0100 |
| #define S_IRWXG 0070 |
| #define S_IRGRP 0040 |
| #define S_IWGRP 0020 |
| #define S_IXGRP 0010 |
| #define S_IRWXO 0007 |
| #define S_IROTH 0004 |
| #define S_IWOTH 0002 |
| #define S_IXOTH 0001 |
| #define st_atime st_atim.tv_sec |
| #define st_mtime st_mtim.tv_sec |
| #define st_ctime st_ctim.tv_sec |
| #define S_ISUID 04000 |
| #define S_ISGID 02000 |
| #define S_ISVTX 01000 |
| #define UTIME_NOW ((1l << 30) - 1) |
| #define UTIME_OMIT ((1l << 30) - 2) |
| int stat | ( | const char * | path, |
| struct stat * | st ) |
get a file's metadata by path.
| int lstat | ( | const char * | path, |
| struct stat * | st ) |
the metadata of a symbolic link itself (stat gives what it points at).
| int fstat | ( | int | fd, |
| struct stat * | st ) |
get an open file's metadata (pipes and the console too).
| int mkdir | ( | const char * | path, |
| mode_t | mode ) |
create a directory with a mode (taken through the umask).
| int mkdirat | ( | int | dirfd, |
| const char * | path, | ||
| mode_t | mode ) |
| int fstatat | ( | int | dirfd, |
| const char * | path, | ||
| struct stat * | st, | ||
| int | flags ) |
| int fchmodat | ( | int | dirfd, |
| const char * | path, | ||
| mode_t | mode, | ||
| int | flags ) |
| int chmod | ( | const char * | path, |
| mode_t | mode ) |
change the permission bits of a file (owner or root only).
| int fchmod | ( | int | fd, |
| mode_t | mode ) |
| int utimensat | ( | int | dirfd, |
| const char * | path, | ||
| const struct timespec | times[2], | ||
| int | flags ) |
set a file's access and modification times (times[0], times[1]); with times NULL, both to the time now.
| flags | AT_SYMLINK_NOFOLLOW: the link itself. |
| int futimens | ( | int | fd, |
| const struct timespec | times[2] ) |
| int mkfifo | ( | const char * | path, |
| mode_t | mode ) |
make a named pipe (a FIFO): processes that open it share one pipe.
| int mkfifoat | ( | int | dirfd, |
| const char * | path, | ||
| mode_t | mode ) |
make a named pipe (S_IFIFO), an empty file (S_IFREG) or, as root, a device node (S_IFCHR, S_IFBLK with makedev's number).
a device node outside /dev opens with ENXIO: ginnOS's devices are in /dev.