mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2024-12-28 04:23:38 +01:00
stat: definitions required to support stat(2)
This commit is contained in:
parent
e479393a9c
commit
937b7bfb63
3 changed files with 100 additions and 47 deletions
|
@ -9,8 +9,13 @@ extern "C" {
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#define DT_UNKNOWN 0 /* Unknown type */
|
#define DT_UNKNOWN 0 /* Unknown type */
|
||||||
#define DT_REG 1 /* Regular file */
|
#define DT_BLK 1 /* Block device */
|
||||||
#define DT_DIR 2 /* Directory */
|
#define DT_CHR 2 /* Character device */
|
||||||
|
#define DT_DIR 3 /* Directory */
|
||||||
|
#define DT_FIFO 4 /* FIFO */
|
||||||
|
#define DT_LNK 5 /* Symbolic link */
|
||||||
|
#define DT_REG 6 /* Regular file */
|
||||||
|
#define DT_SOCK 7 /* Socket */
|
||||||
|
|
||||||
/* In gint d_ino is unused; but it's required by POSIX.1. */
|
/* In gint d_ino is unused; but it's required by POSIX.1. */
|
||||||
struct dirent {
|
struct dirent {
|
||||||
|
|
|
@ -5,41 +5,75 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* File types. */
|
#include <sys/types.h>
|
||||||
#define __S_IFMT 0170000 /* These bits determine file type. */
|
#include <time.h>
|
||||||
#define __S_IFDIR 0040000 /* Directory. */
|
|
||||||
#define __S_IFCHR 0020000 /* Character device. */
|
|
||||||
#define __S_IFBLK 0060000 /* Block device. */
|
|
||||||
#define __S_IFREG 0100000 /* Regular file. */
|
|
||||||
#define __S_IFIFO 0010000 /* FIFO. */
|
|
||||||
#define __S_IFLNK 0120000 /* Symbolic link. */
|
|
||||||
#define __S_IFSOCK 0140000 /* Socket. */
|
|
||||||
|
|
||||||
/* Protection bits. */
|
/* File types; taken from inode(7), any values would probably work. */
|
||||||
#define __S_ISUID 0004000 /* Set user ID on execution. */
|
#define S_IFMT 0170000
|
||||||
#define __S_ISGID 0002000 /* Set group ID on execution. */
|
#define S_IFIFO 0010000 /* FIFO */
|
||||||
#define __S_ISVTX 0001000 /* Save swapped text after use (sticky). */
|
#define S_IFCHR 0020000 /* Character device */
|
||||||
#define __S_IREAD 0000400 /* Read by owner. */
|
#define S_IFDIR 0040000 /* Directory */
|
||||||
#define __S_IWRITE 0000200 /* Write by owner. */
|
#define S_IFBLK 0060000 /* Block device */
|
||||||
#define __S_IEXEC 0000100 /* Execute by owner. */
|
#define S_IFREG 0100000 /* Regular file */
|
||||||
|
#define S_IFLNK 0120000 /* Symbolic link */
|
||||||
|
#define S_IFSOCK 0140000 /* Socket */
|
||||||
|
|
||||||
#define S_IRUSR __S_IREAD /* Read by owner. */
|
/* Shortcuts to check file types from a mode_t value */
|
||||||
#define S_IWUSR __S_IWRITE /* Write by owner. */
|
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||||
#define S_IXUSR __S_IEXEC /* Execute by owner. */
|
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||||
/* Read, write, and execute by owner. */
|
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||||
#define S_IRWXU (__S_IREAD|__S_IWRITE|__S_IEXEC)
|
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||||
|
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||||
|
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||||
|
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||||
|
|
||||||
#define S_IRGRP (S_IRUSR >> 3) /* Read by group. */
|
/* Protection bits of a mode_t */
|
||||||
#define S_IWGRP (S_IWUSR >> 3) /* Write by group. */
|
#define S_ISUID 0004000 /* Set user ID on execution */
|
||||||
#define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */
|
#define S_ISGID 0002000 /* Set group ID on execution */
|
||||||
/* Read, write, and execute by group. */
|
#define S_ISVTX 0001000 /* Sticky bit */
|
||||||
#define S_IRWXG (S_IRWXU >> 3)
|
/* Usual permissions */
|
||||||
|
#define S_IRWXU 00700
|
||||||
|
#define S_IRUSR 00400
|
||||||
|
#define S_IWUSR 00200
|
||||||
|
#define S_IXUSR 00100
|
||||||
|
#define S_IRWXG 00070
|
||||||
|
#define S_IRGRP 00040
|
||||||
|
#define S_IWGRP 00020
|
||||||
|
#define S_IXGRP 00010
|
||||||
|
#define S_IRWXO 00007
|
||||||
|
#define S_IROTH 00004
|
||||||
|
#define S_IWOTH 00002
|
||||||
|
#define S_IXOTH 00001
|
||||||
|
|
||||||
#define S_IROTH (S_IRGRP >> 3) /* Read by others. */
|
struct stat {
|
||||||
#define S_IWOTH (S_IWGRP >> 3) /* Write by others. */
|
off_t st_size;
|
||||||
#define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */
|
mode_t st_mode;
|
||||||
/* Read, write, and execute by others. */
|
|
||||||
#define S_IRWXO (S_IRWXG >> 3)
|
/* In gint, the struct stat only has the file size and file type. The
|
||||||
|
protection bits of (st_mode) are always 00777. The following fields all
|
||||||
|
have undefined values. */
|
||||||
|
|
||||||
|
dev_t st_dev;
|
||||||
|
ino_t st_ino;
|
||||||
|
nlink_t st_link;
|
||||||
|
uid_t st_uid;
|
||||||
|
gid_t st_gid;
|
||||||
|
dev_t st_rdev;
|
||||||
|
blksize_t st_blksize;
|
||||||
|
blkcnt_t st_blocks;
|
||||||
|
|
||||||
|
// struct timespec st_atim;
|
||||||
|
// struct timespec st_mtim;
|
||||||
|
// struct timespec st_ctim;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define st_atime st_atim.tv_sec
|
||||||
|
#define st_mtime st_mtim.tv_sec
|
||||||
|
#define st_ctime st_ctim.tv_sec
|
||||||
|
|
||||||
|
/* Obtain information about an entry in the filesystem. */
|
||||||
|
extern int stat(char const * restrict __pathname,
|
||||||
|
struct stat * restrict __statbuf);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,25 +8,39 @@ extern "C" {
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
// Define properly off_t type.
|
/* Number of blocks in a file */
|
||||||
# ifndef __off_t_defined
|
typedef uint16_t blkcnt_t;
|
||||||
typedef int32_t off_t;
|
|
||||||
# define __off_t_defined
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// Define properly ssize_t type.
|
/* Size of a file block */
|
||||||
#ifndef __ssize_t_defined
|
typedef uint16_t blksize_t;
|
||||||
typedef int32_t ssize_t;
|
|
||||||
# define __ssize_t_defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Define alias
|
/* Device identifier, with a major and minor byte */
|
||||||
typedef int32_t pid_t;
|
|
||||||
typedef int16_t mode_t;
|
|
||||||
typedef uint16_t dev_t;
|
typedef uint16_t dev_t;
|
||||||
typedef uint16_t umode_t;
|
|
||||||
|
/* Type of group identifiers on the system */
|
||||||
|
typedef uint16_t gid_t;
|
||||||
|
|
||||||
|
/* Inode number */
|
||||||
typedef uint32_t ino_t;
|
typedef uint32_t ino_t;
|
||||||
|
|
||||||
|
/* Holds a file's type and permissions bits */
|
||||||
|
typedef int16_t mode_t;
|
||||||
|
|
||||||
|
/* Number of hard links to a file */
|
||||||
|
typedef uint16_t nlink_t;
|
||||||
|
|
||||||
|
/* Offset within a file or stream; also, file size */
|
||||||
|
typedef int32_t off_t;
|
||||||
|
|
||||||
|
/* Process identifier */
|
||||||
|
typedef int16_t pid_t;
|
||||||
|
|
||||||
|
/* Signed size_t which can hold the value -1 */
|
||||||
|
typedef int32_t ssize_t;
|
||||||
|
|
||||||
|
/* Type of user identifiers on the system */
|
||||||
|
typedef uint16_t uid_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue