<sys/type.h>
此头文件还包含适当时应使用的多个基本派生类型。尤其是以下类型更为重要:
clock_t 表示系统时间(以时钟周期为单位)。
dev_t 用于设备号。
off_t 用于文件大小和偏移量。
ptrdiff_t 是一种带符号整型,用于对两个指针执行减法运算后所得的结果。
size_t 反映内存中对象的大小(以字节为单位)。
ssize_t 供返回字节计数或错误提示的函数使用。
time_t 以秒为单位计时。
所有这些类型在 ILP32 编译环境中保持为 32 位值,并会在 LP64 编译环境中增长为 64 位值。
位置在哪儿呢?
find /usr/include -name “types.h”
里面有一项 /usr/include/x86_64-linux-gnu/sys/types.h
<sys/stat.h>
是unix/linux系统定义文件状态所在的伪标准头文件
dev_t st_dev Device ID of device containing file.
ino_t st_ino File serial number.
mode_t st_mode Mode of file (see below).
nlink_t st_nlink Number of hard links to the file.
uid_t st_uid User ID of file.
gid_t st_gid Group ID of file.
dev_t st_rdev Device ID (if file is character or block special).
off_t st_size For regular files, the file size in bytes.
For symbolic links, the length in bytes of the pathname contained in the symbolic link.
For a shared memory object, the length in bytes.
For a typed memory object, the length in bytes.
For other file types, the use of this field is unspecified.
time_t st_atime Time of last access.
time_t st_mtime Time of last data modification.
time_t st_ctime Time of last status change.
int chmod(const char *, mode_t);
int fchmod(int, mode_t);
int fstat(int, struct stat *);
int lstat(const char *restrict, struct stat *restrict);
int mkdir(const char *, mode_t);
int mkfifo(const char *, mode_t);
int mknod(const char *, mode_t, dev_t);
int stat(const char *restrict, struct stat *restrict);
mode_t umask(mode_t);
使用stat函数最多的可能是ls-l命令,用其可以获得有关一个文件的所有信息。
一般头文件在/usr/include下面,这里是标准C程序头文件,如果你的头文件前加了
<sys/unistd.h>
#include <unistd.h>
符号常量
是POSIX标准定义的unix类系统定义符号常量的头文件,包含了许多UNIX系统服务的函数原型,例如read函数、write函数和getpid函数
unistd.h在unix中类似于window中的windows.h!
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
unistd.h含有的常量与函数:
ssize_t read(int, void *, size_t);
int unlink(const char *);
ssize_t write(int, const void *, size_t);
int usleep(useconds_t);
unsigned sleep(unsigned);
int access(const char *, int);
unsigned alarm(unsigned);
int chdir(const char *);
int chown(const char *, uid_t, gid_t);
int close(int);
size_t confstr(int, char *, size_t);
void _exit(int);
pid_t fork(void);
NULL // Null pointer
SEEK_CUR // Set file offset to current plus offset.
SEEK_END // Set file offset to EOF plus offset.
SEEK_SET // Set file offset to offset.
<sys/fnctl.h>
linux 文件操作/文件描述符的头文件
相关函数 open,fcntl,shutdown,unlink,fclose、close(关闭文件)
<sys/cdef.h>