## **Overview**
Provides functions for file system, include file operations, directory operations and so on.
**Since:**
1.0
**Version:**
1.0
## **Summary**
## Files
## Data Structures
Defines the content of the directory. | |
Defines the file tree walker (FTW). | |
Defines the search information. | |
Defines the file information structure. | |
Describes file system information. | |
Defines the file access time and modification time. |
## Macros
fallocate64 fallocate | Pre-allocates space to a file. See fallocate. |
Unreadable directory. Its subdirectories will not be traversed. | |
The data of the stat structure cannot be obtained. The possible cause is that the permission is incorrect. | |
FTW_DP 6 | |
Symbolic link that names a non-existent file. | |
Symbolic links that are not traversed. If not set, symbolic links are traversed by default. | |
Stay within the same file system. | |
chdir is called to go to the directory before reading the directory. | |
All subdirectories will be traversed before the directory itself. | |
Append a slash (/) to each path, which corresponds to a directory. | |
Do not sort the returned path names. | |
In the pglob parameter of the glob() function, reserve a string that has a length of pglob->gl_offs and ends with \0 at the beginning of the string list in pglob->pathv. That is, the newly matched string is appended to a position where the distance from the beginning of pglob->pathv is the length of pglob->gl_offs. | |
If no pattern matches, return the original pattern. | |
Append the results of this call to the results returned by a previous call to glob(). | |
Do not use a backslash () as an escape character. | |
Allow a leading period to be matched by metacharacters. | |
Carry out tilde expansion. If a tilde (~) is the only character in the pattern, or an initial tilde is followed immediately by a slash (/), then the home directory of the caller is substituted for the tilde. | |
Similar to GLOB_TILDE. The difference is that if the username is invalid, or the home directory cannot be determined, glob() returns GLOB_NOMATCH to indicate an error. | |
The function is not supported. |
## Typedefs
Opens the handle of the folder directory. |
## Functions
DIR * | |
struct dirent * | |
readdir_r (DIR *__restrict dirp, struct dirent *__restrict entry, struct dirent **__restrict result) | Reads a specified directory (thread-safe version). |
Resets a directory stream read position. | |
alphasort (const struct dirent **a, const struct dirent **b) | Sorts the directory entries in alphabetical order. |
scandir (const char *dir, struct dirent ***namelist, int(*sel)(const struct dirent *), int(*compar)(const struct dirent **, const struct dirent **)) | Scans directory to find the target entries. |
seekdir (DIR *dirp, long offset) | Sets the position of the next readdir call in the directory stream. |
Obtains the current position in the specified directory stream. | |
creat (const char *path, mode_t mode) | Creates a file or rewrites an existing file. |
open (const char *path, int oflags,...) | |
fallocate (int fd, int mode, off_t offset, off_t len) | Pre-allocates space to a file. |
fcntl (int fd, int cmd,...) | Manipulates a specified file descriptor. |
ftw (const char *path, int(*fn)(const char *file, const struct stat *sb, int flag), int depth) | |
nftw (const char *path, int(*fn)(const char *file, const struct stat *sb, int flag, struct FTW *s), int fd_limit, int flags) | |
glob (const char *__restrict pattern, int flags, int(*errfunc)(const char *, int), glob_t *__restrict pglob) | Searches for path names that meet a specified pattern. |
Frees allocated memory from a call to glob(). | |
dirname (char *path) | Obtains a directory name in a specified path. |
basename (char *path) | Obtains a file name (excluding the directory) in a specified path. |
ioctl (int fd, int cmd,...) | |
mount (const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data) | |
umount (const char *target) | |
umount2 (const char *target, int flags) | |
stat (const char *__restrict path, struct stat *__restrict buf) | |
fstat (int fd, struct stat *buf) | Obtains file status information. |
lstat (const char *__restrict path, struct stat *__restrict buf) | |
mkdir (const char *pathname, mode_t mode) | |
mkfifo (const char *name, mode_t mode) | Creates a named pipe to implement inter-process communication. |
mkdirat (int fd, const char *pathname, mode_t mode) | |
chmod (const char *pathname, mode_t mode) | Modifies permissions for a file. |
umask (mode_t mode) | |
statfs (const char *path, struct statfs *buf) | Obtains file system information of a file in a specified path. |
statvfs (const char *__restrict path, struct statvfs *__restrict buf) | Obtains the file system information. |
utime (const char *filename, const struct utimbuf *times) | Sets the access time and modification time of a file. |
## **Details**
## **Macro Definition Documentation**
## FTW\_DP
```
#define FTW_DP 6
```
**Description:**
@briefDirectory. All subdirectories in this directory have been traversed.
## **Function Documentation**
## alphasort\(\)
```
int alphasort (const struct [dirent](dirent.md) ** a, const struct [dirent](dirent.md) ** b )
```
**Description:**
Sorts the directory entries in alphabetical order.
This function is used to sort the two directory entries passed through the input parameters in alphabetical order. Generally, these parameters are passed in [scandir](FS.md#gaca6df630e382cf13bac90ed6e5c4141c) as its last parameter.
**Parameters:**
a | Indicates the pointer to directory entry a. |
a | Indicates the pointer to directory entry b. |
**Returns:**
Returns an integer greater than, equal to, or less than **0**, respectively, based on whether the name of the directory entry to which **a** points is lexically greater than, equal to, or less than the directory.
## basename\(\)
```
char* basename (char * path)
```
**Description:**
Obtains a file name \(excluding the directory\) in a specified path.
**Parameters:**
path | Indicates the pointer to the path. |
**Returns:**
Returns the file name if the operation is successful; returns **NULL** otherwise.
## chmod\(\)
```
int chmod (const char * pathname, mode_t mode )
```
**Description:**
Modifies permissions for a file.
**Parameters:**
pathname | Indicates the pointer to the path of the file. |
mode | Indicates the new file permission. |
**Attention:**
This function can be used only in the JFFS2 file system.
**Returns:**
Returns **0** if the operation is successful; returns **-1** and sets **errno** to a value in the following table otherwise.
The pathname is a null pointer or an empty string. | |
The permission bit of the file mode does not allow the requested access, or the search permission is denied on the path prefix directory. | |
The path name length is greater than the value of NAME_MAX. | |
The directory component in the path name does not exist. | |
A component of the path prefix is the name of an existing file. The file is neither a directory nor a symbolic link of a directory. | |
Operation not permitted or access denied because the access is prohibited or the directory is full. | |
The physical drive is write-protected. | |
The file or directory already exists. | |
The function is not supported. |
## closedir\(\)
```
int closedir ([DIR](FS.md#ga0ebe68390948c14bb9d82987adbfc849) * dirp)
```
**Description:**
Closes a specified directory.
**Parameters:**
dirp | Indicates the pointer to the structure representing the directory to close. |
**Returns:**
Returns **0** if the directory is successfully closed; returns **-1** and sets **errno** to the following value otherwise.
dirp is not a valid opened directory stream. |
## creat\(\)
```
int creat (const char * path, mode_t mode )
```
**Description:**
Creates a file or rewrites an existing file.
**Parameters:**
path | Indicates the pointer to the name of the file to create or rewrite. |
mode | Indicates permissions on the file. |
**Returns:**
Returns **0** if the file is created or rewritten successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
path points to an invalid path. | |
The length of path is greater than the value of NAME_MAX. | |
Invalid inode or the inode is not a mount point. | |
All file descriptors that can be used by the process are opened. | |
The file structure corresponding to the file descriptor cannot be obtained. | |
Access denied by the permission bit of file mode | |
A hardware error occurs at the low-level disk I/O layer. As a result, the physical drive cannot work. | |
The number of opened files in the system has reached the maximum. | |
A component of the path prefix is the name of an existing file and is not a directory. | |
The operation is rejected according to the file sharing policy. | |
Too many symbolic links are encountered. | |
## dirname\(\)
```
char* dirname (char * path)
```
**Description:**
Obtains a directory name in a specified path.
**Parameters:**
path | Indicates the pointer to the path. |
**Returns:**
Returns the directory name if the operation is successful; returns **NULL** otherwise.
## fallocate\(\)
```
int fallocate (int fd, int mode, off_t offset, off_t len )
```
**Description:**
Pre-allocates space to a file.
**Parameters:**
**Attention:**
This function can be used only in the FAT file system.
**Returns:**
Returns **0** if the operation is successful; returns **-1** and sets **errno** to a value in the following table otherwise.
The value of len or offset is less than 0 or greater than that of INT_MAX, or the value of mode is not FALLOC_FL_KEEP_SIZE. | |
fd is not a valid file descriptor, or the basic file system does not support this operation. | |
Access denied by the authority bit of file mode | |
An I/O error occurs when data is read from or written to the file system. | |
The physical drive is write-protected. | |
The operation is not allowed or the access is rejected. | |
The operation is rejected according to the file sharing policy. |
## fcntl\(\)
```
int fcntl (int fd, int cmd, ... )
```
**Description:**
Manipulates a specified file descriptor.
**Parameters:**
fd | Indicates the file descriptor. |
cmd | Indicates the command used to manipulate the file descriptor. |
**Returns:**
Returns the value depending on **cmd** if the operation is successful; returns **-1** and sets **errno** to a value in the following table otherwise.
## fstat\(\)
```
int fstat (int fd, struct [stat](stat.md) * buf )
```
**Description:**
Obtains file status information.
**Parameters:**
fd | Indicates the file descriptor. |
buf | Indicates the pointer to a stat structure into which file information is placed. |
**Returns:**
Returns **0** if file information is obtained successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
fd is an invalid file descriptor. | |
A component of path does not name an existing file or path is an empty string. | |
The path name length is greater than the value of NAME_MAX. | |
The function is not supported. | |
Search permission is denied on a component of the path prefix. | |
An I/O error occurs when data is read from or written to the file system. | |
The physical drive is write-protected. | |
No available space on the device. | |
The named file is a directory. | |
Operation not permitted or access denied because the access is prohibited or the directory is full. | |
The operation is rejected according to the file sharing policy. | |
The protocol in NFS is incorrect. | |
## ftw\(\)
```
int ftw (const char * path, int(*)(const char *file, const struct [stat](stat.md) *sb, int flag) fn, int depth )
```
**Description:**
Traverses a file tree.
This function is used to traverse a file tree for search.
**Parameters:**
path | Indicates the pointer to the file directory to traverse. |
fn | Indicates the pointer to the function to be called for the found entry. For the fn function, file identifies the path of the file relative to path, and sb indicates the pointer to the stat structure. flag indicates the flag. The values of flag are as follows: |
depth | Indicates the number of files that can be opened during traversal. |
Unreadable directory. Its subdirectories will not be traversed. | |
The data of the stat structure cannot be obtained. The possible cause is that the permission is incorrect. |
**Returns:**
Returns **0** if the tree is traversed; returns the value that is returned by the **fn\(\)** function if the traversal is interrupted; returns **-1** if an error occurs.
## glob\(\)
```
int glob (const char *__restrict pattern, int flags, int(*)(const char *, int) errfunc, [glob_t](glob_t.md) *__restrict pglob )
```
**Description:**
Searches for path names that meet a specified pattern.
**Parameters:**
pattern | Indicates the pattern you want to match. |
flags | Indicates the matching mode. |
errfunc | Indicates the pointer to the error processing callback function. If errfunc is not a null pointer, errfunc() is called when an error occurs (opendir(), readdir(), or stat() fails) during the search. If the function returns a non-zero value or GLOB_ERR is set, glob() terminates the entire search process. |
pglob | Indicates the pointer to the address storing the matched path names. |
**Returns:**
Returns **0** on successful completion; returns [GLOB\_NOSPACE](FS.md#gab53de39e075e6fb9a11678341772930b) for running out of memory; returns [GLOB\_ABORTED](FS.md#gab5de50cedafa21283878657d05fb2ba8) for a read error; returns [GLOB\_NOMATCH](FS.md#gaed760cf90fd4398067cdb679ebe60312) for no match found.
## globfree\(\)
```
void globfree ([glob_t](glob_t.md) * pglob)
```
**Description:**
Frees allocated memory from a call to **[glob\(\)](FS.md#gae98601409da7fd3c85a9c219e1a9020c)**.
**Parameters:**
pglob | Indicates the pointer to the address of memory dynamically allocated for a glob call. |
## ioctl\(\)
```
int ioctl (int fd, int cmd, ... )
```
**Description:**
Manipulates a device.
This function is used to perform specified operations on an input device file descriptor.
**Parameters:**
fd | Indicates the file descriptor of the device (file-related file descriptors are not supported). |
cmd | Indicates the operation instruction for the device. You can define it based on the specific device. |
**Returns:**
Returns **0** if the operation is successful; returns **-1** and sets **errno** to a value in the following table otherwise.
fd is an invalid file descriptor. | |
An inaccessible memory area is referenced. | |
The command request is invalid. | |
fd is not associated with a character special device. |
## lstat\(\)
```
int lstat (const char *__restrict path, struct [stat](stat.md) *__restrict buf )
```
**Description:**
Obtains file information.
**Parameters:**
path | Indicates the file path. |
buf | Indicates the pointer to a stat structure into which file information is placed. |
**Returns:**
Returns **0** if file information is obtained successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
A component of path does not name an existing file or path is an empty string. | |
The path name length is greater than the value of NAME_MAX. | |
The function is not supported. | |
The permission bit of the file mode does not allow the requested access, or the search permission is denied on the path prefix component. | |
The file or directory already exists. | |
An I/O error occurs when data is read from or written to the file system. | |
The physical drive is write-protected. | |
No available space on the device. | |
The number of opened files in the system has reached the maximum. | |
The named file is a directory. | |
A component of the path prefix is the name of an existing file. The file is neither a directory nor a symbolic link of a directory. | |
Operation not permitted or access denied because the access is prohibited or the directory is full. | |
The operation is rejected according to the file sharing policy. | |
The protocol in NFS is incorrect. | |
## mkdir\(\)
```
int mkdir (const char * pathname, mode_t mode )
```
**Description:**
Creates a directory.
**Parameters:**
pathname | Indicates the pointer to the name of the directory to create. |
mode | Indicates the directory permission. |
**Attention:**
This function can NOT be used in the PROC file system.
**Returns:**
Returns **0** if the directory is created successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
The pathname is a null pointer or an empty string. | |
The permission bit of the file mode does not allow the requested access, or the search permission is denied on the path prefix directory. | |
The path name length is greater than the value of NAME_MAX. | |
The directory component in the path name does not exist. | |
The file or directory already exists. | |
An I/O error occurs when data is read from or written to the file system. | |
The physical drive is write-protected. | |
No available space on the device. | |
Operation not permitted or access denied because the access is prohibited or the directory is full. | |
The operation is rejected according to the file sharing policy. | |
The function is not supported. | |
The protocol in NFS is incorrect. | |
## mkdirat\(\)
```
int mkdirat (int fd, const char * pathname, mode_t mode )
```
**Description:**
Creates a directory.
**Parameters:**
**Attention:**
This function can NOT be used in the PROC file system.
**Returns:**
Returns **0** if the directory is created successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
The pathname is a null pointer or an empty string. | |
The permission bit of the file mode does not allow the requested access, or the search permission is denied on the path prefix directory. | |
The path name length is greater than the value of NAME_MAX. | |
The directory component in the path name does not exist. | |
The file or directory already exists. | |
An I/O error occurs when data is read from or written to the file system. | |
The physical drive is write-protected. | |
No available space on the device. | |
Operation not permitted or access denied because the access is prohibited or the directory is full. | |
The operation is rejected according to the file sharing policy. | |
The function is not supported. | |
The protocol in NFS is incorrect. | |
## mkfifo\(\)
```
int mkfifo (const char * name, mode_t mode )
```
**Description:**
Creates a named pipe to implement inter-process communication.
**Parameters:**
name | Indicates the pointer to the name of the pipe to create. |
mode | Not supported. |
**Attention:**
Permission control is not supported. The number of pipes that can be created is not limited. Pipes can be created only in the **/dev** directory.
**Returns:**
Returns **0** if the pipe is created successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
Invalid input parameter (for example, empty address, file name too long or the file is not in the /dev directory). | |
## mount\(\)
```
int mount (const char * source, const char * target, const char * filesystemtype, unsigned long mountflags, const void * data )
```
**Description:**
Mounts a file system.
Mounts a device \(referenced by a file system name\) to a specified directory.
**Parameters:**
source | Indicates the pointer to the device to mount. |
target | Indicates the pointer to the path of the mount point. |
filesystemtype | Indicates the pointer to the file system type. |
mountflags | Indicates the mounting flag. |
data | Indicates the pointer to the mounting data. |
**Returns:**
Returns **0** if the mounting is successful; returns **-1** and sets **errno** to a value in the following table otherwise.
## nftw\(\)
```
int nftw (const char * path, int(*)(const char *file, const struct [stat](stat.md) *sb, int flag, struct [FTW](FTW.md) *s) fn, int fd_limit, int flags )
```
**Description:**
Traverses a file tree.
This function is used to traverse a file tree. It has a similar effect to [ftw](FS.md#ga8dda75835c2b90f305d96e908dc0f84d) except that it takes an additional parameter **flags**.
**Parameters:**
path | Indicates the pointer to the file directory to traverse. |
fn | Indicates the pointer to the function to be called for the found entry. For the fn function, file identifies the path of the file relative to path, and sb indicates the pointer to the stat structure. flag indicates the flag. The values of flag are as follows: The fourth argument of fn() is a pointer to a FTW structure. |
fd_limit | Indicates the number of files that can be opened during traversal. |
flags | Indicates the traversal action. It is a bitwise inclusive-OR of zero or more of the following flags: |
**Returns:**
Returns **0** if the tree is traversed; returns the value that is returned by the **fn\(\)** function if the traversal is interrupted; returns **-1** if an error occurs.
## open\(\)
```
int open (const char * path, int oflags, ... )
```
**Description:**
Opens a file.
**Parameters:**
path | Indicates the pointer to the name of the file to open. |
oflags | Indicates the file access mode. Available values are as follows: |
If set, the file offset will be set to the end of the file prior to each write. | |
If the file does not exist, it will be created. | |
A file exceeding 2 GB can be created. | |
If the file is opened successfully with O_WRONLY or O_RDWR, its length is truncated to 0. | |
Used together with O_CREAT. This function fails if the file exists. | |
This flag must be added for opening a directory. Otherwise, the directory fails to be opened. |
**Attention:**
This function can NOT be used in the PROC file system to create a file. This function is used to open a file. If the file does not exist, this function creates a file and opens it.
**Returns:**
Returns the file descriptor if the file is opened successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
Search permission is denied on a component of the path prefix. | |
The path name format is invalid. | |
The length of path is greater than the value of NAME_MAX. | |
The O_CREAT flag is not set and the named file does not exist. | |
Inode is invalid, not a normal character driver, or not a mount point. | |
All available file descriptors of the process are opened. | |
The file structure corresponding to the file descriptor cannot be obtained. | |
A hardware error occurs at the low-level disk I/O layer. As a result, the physical drive cannot work. | |
The named file resides on a read-only file system, and either O_WRONLY, O_RDWR, O_CREAT (if file does not exist), or O_TRUNC is set in the oflags parameter. | |
The directory or file system that would contain the new file cannot be expanded, the file does not exist, and O_CREAT is specified. | |
The number of opened files in the system has reached the maximum. | |
The named file is a directory, and oflags includes O_WRONLY, O_RDWR, or O_CREAT without O_DIRECTORY. | |
A component of the path prefix names an existing file that is not a directory. | |
The operation is rejected according to the file sharing policy. | |
Too many symbolic links are encountered. | |
## opendir\(\)
```
[DIR](FS.md#ga0ebe68390948c14bb9d82987adbfc849)* opendir (const char * dirname)
```
**Description:**
Opens a specified directory.
**Parameters:**
dirname | Indicates the pointer to the name of directory to open. |
**Returns:**
Returns the pointer to the **DIR** structure representing the directory if it is opened successfully; returns **NULL** and sets **errno** to a value in the following table otherwise.
The length of the path name string is longer than the value of NAME_MAX. | |
The path component does not exist. | |
The storage memory is insufficient. | |
## readdir\(\)
```
struct [dirent](dirent.md)* readdir ([DIR](FS.md#ga0ebe68390948c14bb9d82987adbfc849) * dirp)
```
**Description:**
Reads a specified directory.
**Parameters:**
dirp | Indicates the pointer to the directory structure. |
**Returns:**
Returns the pointer to the **dirent** structure representing the directory if it is read successfully; returns **NULL** if reaching the end of the directory stream or the directory fails to be read. If the directory fails to be read, the corresponding error code is returned.
This feature is not supported by the file system. | |
The path name length is greater than the value of NAME_MAX. | |
The current position in the directory stream is invalid. | |
dirp is not an opened directory stream. |
## readdir\_r\(\)
```
int readdir_r ([DIR](FS.md#ga0ebe68390948c14bb9d82987adbfc849) *__restrict dirp, struct [dirent](dirent.md) *__restrict entry, struct [dirent](dirent.md) **__restrict result )
```
**Description:**
Reads a specified directory \(thread-safe version\).
**Parameters:**
dirp | Indicates the pointer to the directory structure. |
entry | Indicates the entry read from the dirp stream. |
result | Indicates the pointer to the returned buffer. |
**Returns:**
Returns **0**. If the directory fails to be read, **errno** is sets to a value in the following table.
This feature is not supported by the file system. | |
The path name length is greater than the value of NAME_MAX. | |
The current position in the directory stream is invalid. | |
dirp is not an opened directory stream. |
## rewinddir\(\)
```
void rewinddir ([DIR](FS.md#ga0ebe68390948c14bb9d82987adbfc849) * dirp)
```
**Description:**
Resets a directory stream read position.
This function is used to change the current read position of the specified directory stream to the original read position \(that is, the start position after the directory stream is opened by [opendir](FS.md#gad09dd96447776d2bc5d8321e4b499591)\).
**Parameters:**
dirp | Indicates the pointer to the directory stream whose read position needs to be reset. |
dirp is not an opened directory stream. |
## scandir\(\)
```
int scandir (const char * dir, struct [dirent](dirent.md) *** namelist, int(*)(const struct [dirent](dirent.md) *) sel, int(*)(const struct [dirent](dirent.md) **, const struct [dirent](dirent.md) **) compar )
```
**Description:**
Scans directory to find the target entries.
**Parameters:**
**Returns:**
Returns the number of entries copied to the **namelist** array if the scanning is successful; returns **-1** and sets **errno** to a value in the following table otherwise.
The length of the path name string is greater than the value of NAME_MAX. | |
The directory component does not exist. | |
The storage memory is insufficient. | |
This feature is not supported by the file system. |
## seekdir\(\)
```
void seekdir ([DIR](FS.md#ga0ebe68390948c14bb9d82987adbfc849) * dirp, long offset )
```
**Description:**
Sets the position of the next [readdir](FS.md#ga58257faf8b13b3f14558613c632b2373) call in the directory stream.
**Parameters:**
dirp | Indicates the pointer to the directory stream in which the position of the next readdir call needs to be set. |
offset | Indicates the offset of the position relative to the current position. |
## stat\(\)
```
int [stat](stat.md) (const char *__restrict path, struct [stat](stat.md) *__restrict buf )
```
**Description:**
Obtains file information.
**Parameters:**
path | Indicates the file path. |
buf | Indicates the pointer to a stat structure into which file information is placed. |
**Returns:**
Returns **0** if file information is obtained successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
A component of path does not name an existing file or path is an empty string. | |
The path name length is greater than the value of NAME_MAX. | |
The function is not supported. | |
The permission bit of the file mode does not allow the requested access, or the search permission is denied on the path prefix component. | |
The file or directory already exists. | |
An I/O error occurs when data is read from or written to the file system. | |
The physical drive is write-protected. | |
No available space on the device. | |
The number of opened files in the system has reached the maximum. | |
The named file is a directory. | |
A component of the path prefix is the name of an existing file. The file is neither a directory nor a symbolic link of a directory. | |
Operation not permitted or access denied because the access is prohibited or the directory is full. | |
The operation is rejected according to the file sharing policy. | |
The protocol in NFS is incorrect. | |
## statfs\(\)
```
int statfs (const char * path, struct statfs * buf )
```
**Description:**
Obtains file system information of a file in a specified path.
**Parameters:**
path | Indicates the pointer to the name of the target file. |
buf | Indicates the pointer to a statfs structure that stores the information about the file system. |
**Returns:**
Returns **0** if the operation is successful; returns **-1** and sets **errno** to a value in the following table if the operation fails.
## statvfs\(\)
```
int [statvfs](statvfs.md) (const char *__restrict path, struct [statvfs](statvfs.md) *__restrict buf )
```
**Description:**
Obtains the file system information.
**Parameters:**
path | Indicates the pointer to the path name of the file. |
buf | Indicates the pointer to the statvfs structure that stores the obtained file system information. |
**Returns:**
Returns **0** if the file system information is obtained successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
## telldir\(\)
```
long telldir ([DIR](FS.md#ga0ebe68390948c14bb9d82987adbfc849) * dirp)
```
**Description:**
Obtains the current position in the specified directory stream.
**Parameters:**
dirp | Indicates the pointer to the directory stream. |
**Returns:**
Returns the current position in the directory stream if the operation is successful; returns **-1** and sets **errno** to the value in the following table otherwise.
drip is not an opened directory stream. |
## umask\(\)
```
mode_t umask (mode_t mode)
```
**Description:**
Sets umask for a process.
This function sets the umask of the current process file and returns the previous value of the umask. umask is used to turn off permission bits corresponding to in the **mode** parameter.
**Parameters:**
mode | Used to specify the umask value of a process. |
**Returns:**
Returns the previous value of the umask. This function call always succeeds.
## umount\(\)
```
int umount (const char * target)
```
**Description:**
Unmounts a file system.
**Parameters:**
target | Indicates the pointer to the path of the file system to unmount. |
**Returns:**
Returns **0** if the file system is unmounted successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
## umount2\(\)
```
int umount2 (const char * target, int flags )
```
**Description:**
Unmounts a file system.
This function is used to unmount a file system. Currently, the value of **flags** can only be **0**. In this case, this function is the same as **[umount\(\)](FS.md#ga44634cfa8bcc732c29bcdf5822095422)**.
**Parameters:**
target | Indicates the pointer to the path of the file system to unmount. |
flags | Indicates the control flag. (Currently, the value of flags can only be 0. In this case, this function is the same as umount().) |
**Returns:**
Returns **0** if the file system is unmounted successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
## utime\(\)
```
int utime (const char * filename, const struct [utimbuf](utimbuf.md) * times )
```
**Description:**
Sets the access time and modification time of a file.
**Parameters:**
**Returns:**
Returns **0** if the access time and modification time are set successfully; returns **-1** and sets **errno** to a value in the following table otherwise.
filename is null or times is invalid. | |
The length of the component in the path name is greater than the value of NAME_MAX. | |
This function is not supported. | |
A hardware error occurs at the underlying disk I/O layer. |