"""
Auto-generated Python stub file from posix.py
Module: posix
"""


import t, c
from stdint import *

DIR: t.CTypedef = t.CVoid | t.CPtr
mode_t: t.CTypedef = t.CUInt32T
pid_t: t.CTypedef = t.CInt32T
off_t: t.CTypedef = t.CInt64T
dev_t: t.CTypedef = t.CUInt64T
ino_t: t.CTypedef = t.CUInt64T
nlink_t: t.CTypedef = t.CUInt64T
uid_t: t.CTypedef = t.CUInt32T
gid_t: t.CTypedef = t.CUInt32T
blksize_t: t.CTypedef = t.CInt64T
blkcnt_t: t.CTypedef = t.CInt64T
time_t: t.CTypedef = t.CInt64T
O_RDONLY:   t.CDefine = 0
O_WRONLY:   t.CDefine = 1
O_RDWR:     t.CDefine = 2
O_CREAT:    t.CDefine = 0o100
O_EXCL:     t.CDefine = 0o200
O_TRUNC:    t.CDefine = 0o1000
O_APPEND:   t.CDefine = 0o2000
O_NONBLOCK: t.CDefine = 0o4000
O_CLOEXEC:  t.CDefine = 0o2000000
F_OK: t.CDefine = 0    # 文件存在
R_OK: t.CDefine = 4    # 可读
W_OK: t.CDefine = 2    # 可写
X_OK: t.CDefine = 1    # 可执行
S_IFMT:   t.CDefine = 0o170000   # 类型掩码
S_IFSOCK: t.CDefine = 0o140000   # 套接字
S_IFLNK:  t.CDefine = 0o120000   # 符号链接
S_IFREG:  t.CDefine = 0o100000   # 普通文件
S_IFBLK:  t.CDefine = 0o060000   # 块设备
S_IFDIR:  t.CDefine = 0o040000   # 目录
S_IFCHR:  t.CDefine = 0o020000   # 字符设备
S_IFIFO:  t.CDefine = 0o010000   # FIFO/管道
S_ISUID: t.CDefine = 0o4000    # set-user-ID
S_ISGID: t.CDefine = 0o2000    # set-group-ID
S_ISVTX: t.CDefine = 0o1000    # sticky 位
S_IRWXU: t.CDefine = 0o700     # 用户读写执行
S_IRUSR: t.CDefine = 0o400     # 用户读
S_IWUSR: t.CDefine = 0o200     # 用户写
S_IXUSR: t.CDefine = 0o100     # 用户执行
S_IRWXG: t.CDefine = 0o070     # 组读写执行
S_IRGRP: t.CDefine = 0o040     # 组读
S_IWGRP: t.CDefine = 0o020     # 组写
S_IXGRP: t.CDefine = 0o010     # 组执行
S_IRWXO: t.CDefine = 0o007     # 其他读写执行
S_IROTH: t.CDefine = 0o004     # 其他读
S_IWOTH: t.CDefine = 0o002     # 其他写
S_IXOTH: t.CDefine = 0o001     # 其他执行
SEEK_SET: t.CDefine = 0
SEEK_CUR: t.CDefine = 1
SEEK_END: t.CDefine = 2
PATH_MAX: t.CDefine = 4096
NAME_MAX: t.CDefine = 255
_SC_NPROCESSORS_ONLN: t.CDefine = 84
_SC_PAGESIZE:         t.CDefine = 30
_SC_CLK_TCK:          t.CDefine = 2
DT_UNKNOWN: t.CDefine = 0
DT_FIFO:    t.CDefine = 1
DT_CHR:     t.CDefine = 2
DT_DIR:     t.CDefine = 4
DT_BLK:     t.CDefine = 6
DT_REG:     t.CDefine = 8
DT_LNK:     t.CDefine = 10
DT_SOCK:    t.CDefine = 12
DT_WHT:     t.CDefine = 14
WNOHANG:    t.CDefine = 1
WUNTRACED:  t.CDefine = 2
WCONTINUED: t.CDefine = 8

class Stat:
    st_dev: dev_t
    st_ino: ino_t
    st_nlink: nlink_t
    st_mode: mode_t
    st_uid: uid_t
    st_gid: gid_t
    __pad0: INT
    st_rdev: dev_t
    st_size: off_t
    st_blksize: blksize_t
    st_blocks: blkcnt_t
    st_atim_sec: time_t
    st_atim_nsec: LONGLONG
    st_mtim_sec: time_t
    st_mtim_nsec: LONGLONG
    st_ctim_sec: time_t
    st_ctim_nsec: LONGLONG
    __unused0: LONGLONG
    __unused1: LONGLONG
    __unused2: LONGLONG
class Dirent:
    d_ino: ino_t
    d_off: off_t
    d_reclen: USHORT
    d_type: BYTE
    d_name: CHARPTR

def open(path: t.CConst | str, oflag: INT, *args) -> INT | t.State: pass

def close(fd: INT) -> INT | t.State: pass

def read(fd: INT, buf: bytes, count: t.CSizeT) -> ssize_t | t.State: pass

def write(fd: INT, buf: t.CConst | bytes, count: t.CSizeT) -> ssize_t | t.State: pass

def lseek(fd: INT, offset: off_t, whence: INT) -> off_t | t.State: pass

def unlink(path: t.CConst | str) -> INT | t.State: pass

def access(path: t.CConst | str, amode: INT) -> INT | t.State: pass

def realpath(path: t.CConst | str, resolved: CHARPTR) -> CHARPTR | t.State: pass

def rename(oldpath: t.CConst | str, newpath: t.CConst | str) -> INT | t.State: pass

def chmod(path: t.CConst | str, mode: mode_t) -> INT | t.State: pass

def stat(path: t.CConst | str, buf: Stat | t.CPtr) -> INT | t.State: pass

def fstat(fd: INT, buf: Stat | t.CPtr) -> INT | t.State: pass

def opendir(name: t.CConst | str) -> DIR | t.CPtr | t.State: pass

def readdir(dirp: DIR | t.CPtr) -> Dirent | t.CPtr | t.State: pass

def closedir(dirp: DIR | t.CPtr) -> INT | t.State: pass

def mkdir(path: t.CConst | str, mode: mode_t) -> INT | t.State: pass

def rmdir(path: t.CConst | str) -> INT | t.State: pass

def getcwd(buf: CHARPTR, size: t.CSizeT) -> CHARPTR | t.State: pass

def chdir(path: t.CConst | str) -> INT | t.State: pass

def fork() -> pid_t | t.State: pass

def execvp(file: t.CConst | str, argv: CHARPTR | t.CPtr) -> INT | t.State: pass

def execv(path: t.CConst | str, argv: CHARPTR | t.CPtr) -> INT | t.State: pass

def waitpid(pid: pid_t, status: INT | t.CPtr, options: INT) -> pid_t | t.State: pass

def pipe(fds: INT | t.CPtr) -> INT | t.State: pass

def dup2(oldfd: INT, newfd: INT) -> INT | t.State: pass

def _exit(status: INT) -> t.CVoid | t.State: pass

def getpid() -> pid_t | t.State: pass

def getenv(name: t.CConst | str) -> CHARPTR | t.State: pass

def setenv(name: t.CConst | str, value: t.CConst | str, overwrite: INT) -> INT | t.State: pass

def sysconf(name: INT) -> LONG | t.State: pass

def isatty(fd: INT) -> INT | t.State: pass

def S_ISREG(mode: mode_t) -> bool: pass

def S_ISDIR(mode: mode_t) -> bool: pass

def S_ISLNK(mode: mode_t) -> bool: pass

def S_ISCHR(mode: mode_t) -> bool: pass

def S_ISBLK(mode: mode_t) -> bool: pass

def S_ISFIFO(mode: mode_t) -> bool: pass

def S_ISSOCK(mode: mode_t) -> bool: pass

def WIFEXITED(status: INT) -> bool: pass

def WEXITSTATUS(status: INT) -> INT: pass

def WIFSIGNALED(status: INT) -> bool: pass

def WTERMSIG(status: INT) -> INT: pass
