1# OpenHarmony SELinux APIs 2 3## Introduction 4 5This topic describes the APIs provided to update the SELinux labels of files or directories, and how to use the APIs. 6 7## Available APIs 8 9All the SELinux APIs are native C APIs that provide underlying capabilities only. These APIs are not available to applications. 10 11| API| Description| Parameter Description| 12| --------- | ---------- | ---------- | 13| int **Restorecon**(const char *path); | Updates the label of a single file or directory without recursively traversing subdirectories.<br>If **0** is returned, the operation is successful. Otherwise, the operation fails.| **path** indicates the pointer to the absolute path of the target file or directory.| 14| int **RestoreconRecurse**(const char *path); | Updates the file or directory label for a single thread, and recursively traverses and updates the labels of subdirectories and their files.<br>If **0** is returned, the operation is successful. Otherwise, the operation fails.| **path** indicates the pointer to the absolute path of the target file or directory.| 15| int **RestoreconRecurseParallel**(const char *path, unsigned int nthreads); | Updates the file or directory labels for multiple threads, and recursively traverses and updates the labels of subdirectories and their files.<br>If **0** is returned, the operation is successful. Otherwise, the operation fails.| **path** indicates the pointer to the absolute path of the target file or directory.<br>**nthreads** indicates the number of threads. | 16| int **RestoreconRecurseForce**(const char *path); | Forcibly updates the file or directory label for a single thread, and recursively traverses and updates the labels of subdirectories and their files.<br>If **0** is returned, the operation is successful. Otherwise, the operation fails.| **path** indicates the pointer to the absolute path of the target file or directory.| 17| int **RestoreconFromParentDir**(const char *path); | Updates the label of the directory based on its parent directory for a single thread, and recursively traverses and updates the entire directory.<br>If **0** is returned, the operation is successful. Otherwise, the operation fails.| **path** indicates the pointer to the absolute path of the parent directory.| 18 19## How to Develop 20 211. Add the dependency for compilation. 22 23 ```text 24 external_deps += [ "selinux_adapter:librestorecon" ] 25 ``` 26 272. Include the header file. 28 29 ```cpp 30 #include "policycoreutils.h" 31 ``` 32 333. Call the APIs. 34 35 For example, call **Restorecon** to update the labe of **/data**. 36 ```cpp 37 // Update the label of /data. 38 int ret = Restorecon("/data"); 39 ``` 40 41