RT-Thread RTOS
An open source embedded real-time operating system
|
Functions | |
int | open (const char *file, int flags,...) |
int | openat (int dirfd, const char *path, int flag,...) |
int | creat (const char *path, mode_t mode) |
int | close (int fd) |
ssize_t | read (int fd, void *buf, size_t len) |
ssize_t | write (int fd, const void *buf, size_t len) |
off_t | lseek (int fd, off_t offset, int whence) |
int | rename (const char *old_file, const char *new_file) |
int | unlink (const char *pathname) |
int | stat (const char *file, struct stat *buf) |
int | fstat (int fildes, struct stat *buf) |
int | fsync (int fildes) |
int | fcntl (int fildes, int cmd,...) |
int | ioctl (int fildes, int cmd,...) |
int | ftruncate (int fd, off_t length) |
int | statfs (const char *path, struct statfs *buf) |
int | fstatfs (int fildes, struct statfs *buf) |
int | mkdir (const char *path, mode_t mode) |
int | rmdir (const char *pathname) |
DIR * | opendir (const char *name) |
struct dirent * | readdir (DIR *d) |
long | telldir (DIR *d) |
void | seekdir (DIR *d, long offset) |
void | rewinddir (DIR *d) |
int | closedir (DIR *d) |
int | access (const char *path, int amode) |
void | setcwd (char *buf) |
char * | getcwd (char *buf, size_t size) |
ssize_t | pread (int fd, void *buf, size_t len, off_t offset) |
ssize_t | pwrite (int fd, const void *buf, size_t len, off_t offset) |
int open | ( | const char * | file, |
int | flags, | ||
... | |||
) |
this function is a POSIX compliant version, which will open a file and return a file descriptor according specified flags.
file | the path name of file. |
flags | the file open flags. Common values include:
|
int openat | ( | int | dirfd, |
const char * | path, | ||
int | flag, | ||
... | |||
) |
Opens a file relative to a directory file descriptor.
dirfd | The file descriptor of the directory to base the relative path on. |
path | The path to the file to be opened, relative to the directory specified by dirfd . Can be an absolute path (in which case dirfd is ignored). |
flag | File access and status flags (e.g., O_RDONLY , O_WRONLY , O_CREAT ). |
-1
and sets errno
to indicate the error.dirfd
is a valid directory descriptor. When pathname
is absolute, the dirfd
argument is ignored. int creat | ( | const char * | path, |
mode_t | mode | ||
) |
this function is a POSIX compliant version, which will create a new file or rewrite an existing one
path | the path name of file. |
mode | the file permission bits to be used in creating the file (not used, can be 0) |
int close | ( | int | fd | ) |
this function is a POSIX compliant version, which will close the open file descriptor.
fd | the file descriptor. |
ssize_t read | ( | int | fd, |
void * | buf, | ||
size_t | len | ||
) |
this function is a POSIX compliant version, which will read specified data buffer length for an open file descriptor.
fd | the file descriptor. |
buf | the buffer to save the read data. |
len | the maximal length of data buffer |
ssize_t write | ( | int | fd, |
const void * | buf, | ||
size_t | len | ||
) |
this function is a POSIX compliant version, which will write specified data buffer length for an open file descriptor.
fd | the file descriptor |
buf | the data buffer to be written. |
len | the data buffer length. |
off_t lseek | ( | int | fd, |
off_t | offset, | ||
int | whence | ||
) |
this function is a POSIX compliant version, which will Reposition the file offset for an open file descriptor.
The lseek
function sets the file offset for the file descriptor fd
to a new value, determined by the offset
and whence
parameters. It can be used to seek to specific positions in a file for reading or writing.
fd | the file descriptor. |
offset | The offset, in bytes, to set the file position. The meaning of offset depends on the value of whence . |
whence | the directive of seek. It can be one of:
|
int rename | ( | const char * | old_file, |
const char * | new_file | ||
) |
this function is a POSIX compliant version, which will rename old file name to new file name.
old_file | the old file name. |
new_file | the new file name. |
note: the old and new file name must be belong to a same file system.
int unlink | ( | const char * | pathname | ) |
this function is a POSIX compliant version, which will unlink (remove) a specified path file from file system.
pathname | the specified path name to be unlinked. |
int stat | ( | const char * | file, |
struct stat * | buf | ||
) |
this function is a POSIX compliant version, which will get file information.
file | the file name |
buf | the data buffer to save stat description. |
int fstat | ( | int | fildes, |
struct stat * | buf | ||
) |
this function is a POSIX compliant version, which will get file status.
fildes | the file description |
buf | the data buffer to save stat description. |
int fsync | ( | int | fildes | ) |
this function is a POSIX compliant version, which shall request that all data for the open file descriptor named by fildes is to be transferred to the storage device associated with the file described by fildes.
fildes | the file description |
int fcntl | ( | int | fildes, |
int | cmd, | ||
... | |||
) |
this function is a POSIX compliant version, which shall perform a variety of control functions on devices.
fildes | the file description |
cmd | the specified command, Common values include:
|
... | represents the additional information that is needed by this specific device to perform the requested function. For example:
|
int ioctl | ( | int | fildes, |
int | cmd, | ||
... | |||
) |
this function is a POSIX compliant version, which shall perform a variety of control functions on devices.
fildes | the file description |
cmd | the specified command |
... | represents the additional information that is needed by this specific device to perform the requested function. |
int ftruncate | ( | int | fd, |
off_t | length | ||
) |
this function is a POSIX compliant version, which cause the regular file referenced by fd to be truncated to a size of precisely length bytes.
fd | the file descriptor. |
length | the length to be truncated. |
int statfs | ( | const char * | path, |
struct statfs * | buf | ||
) |
this function is a POSIX compliant version, which will return the information about a mounted file system.
path | the path which mounted file system. |
buf | the buffer to save the returned information. |
int fstatfs | ( | int | fildes, |
struct statfs * | buf | ||
) |
this function is a POSIX compliant version, which will return the information about a mounted file system.
fildes | the file description. |
buf | the buffer to save the returned information. |
int mkdir | ( | const char * | path, |
mode_t | mode | ||
) |
this function is a POSIX compliant version, which will make a directory
path | the directory path to be made. |
mode | The permission mode for the new directory (unused here, can be set to 0). |
int rmdir | ( | const char * | pathname | ) |
this function is a POSIX compliant version, which will remove a directory.
pathname | the path name to be removed. |
DIR* opendir | ( | const char * | name | ) |
this function is a POSIX compliant version, which will open a directory.
name | the path name to be open. |
struct dirent* readdir | ( | DIR * | d | ) |
this function is a POSIX compliant version, which will return a pointer to a dirent structure representing the next directory entry in the directory stream.
d | the directory stream pointer. |
long telldir | ( | DIR * | d | ) |
this function is a POSIX compliant version, which will return current location in directory stream.
d | the directory stream pointer. |
void seekdir | ( | DIR * | d, |
long | offset | ||
) |
this function is a POSIX compliant version, which will set position of next directory structure in the directory stream.
d | the directory stream. |
offset | the offset in directory stream. |
void rewinddir | ( | DIR * | d | ) |
this function is a POSIX compliant version, which will reset directory stream.
d | the directory stream. |
int closedir | ( | DIR * | d | ) |
this function is a POSIX compliant version, which will close a directory stream.
d | the directory stream. |
int access | ( | const char * | path, |
int | amode | ||
) |
this function is a POSIX compliant version, which shall check the file named by the pathname pointed to by the path argument for accessibility according to the bit pattern contained in amode.
path | the specified file/dir path. |
amode | the value is either the bitwise-inclusive OR of the access permissions to be checked (R_OK, W_OK, X_OK) or the existence test (F_OK). |
void setcwd | ( | char * | buf | ) |
this function is a POSIX compliant version, which will set current working directory.
buf | the current directory. |
char* getcwd | ( | char * | buf, |
size_t | size | ||
) |
this function is a POSIX compliant version, which will return current working directory.
buf | the returned current directory. |
size | the buffer size. |
ssize_t pread | ( | int | fd, |
void * | buf, | ||
size_t | len, | ||
off_t | offset | ||
) |
this function is a POSIX compliant version, which will read specified data buffer length for an open file descriptor.
fd | the file descriptor. |
buf | the buffer to save the read data. |
len | the maximal length of data buffer |
offset | the file pos |
ssize_t pwrite | ( | int | fd, |
const void * | buf, | ||
size_t | len, | ||
off_t | offset | ||
) |
this function is a POSIX compliant version, which will write specified data buffer length for an open file descriptor.
fd | the file descriptor |
buf | the data buffer to be written. |
len | the data buffer length. |
offset | the file pos |