---
name: "semanage_fcontext"
section: "3"
platform: "linux"
package: "libsemanage-dev"
version: "3.8.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/semanage_fcontext"
---

# semanage\_fcontext(3)

SELinux File Context Management API

## NAME

semanage\_fcontext - SELinux File Context Management API

## SYNOPSIS

**#include \<semanage/fcontext\_record.h\>**\
 **#include \<semanage/fcontexts\_policy.h\>**\
 **#include \<semanage/fcontexts\_local.h\>**

This object contains properties associated with a SELinux file context specification

For details on a specific function, see its manual page.

## Record API Overview

**semanage\_fcontext\_create**(3)**-**\
 create a file context spec

**semanage\_fcontext\_free**(3)**-**\
 release resources for this file context spec

**semanage\_fcontext\_key\_create**(3)**-**\
 create a key, which can be used to identify a file context spec

**semanage\_fcontext\_key\_free**(3)**-**\
 release resources for this file context spec key

**semanage\_fcontext\_key\_extract**(3)**-**\
 create a key matching this file context spec

**semanage\_fcontext\_clone**(3)**-**\
 create an identical file context spec (deep-copy clone)

**semanage\_fcontext\_compare**(3)**-**\
 compare this file context spec to the provided key

**semanage\_fcontext\_compare2**(3)**-**\
 compare this file context spec to another

## Properties API Overview

**semanage\_fcontext\_get\_expr**(3)**-**\
 return the regular expression for this file context spec

**semanage\_fcontext\_set\_expr**(3)**-**\
 set the regular expression for this file context spec

**semanage\_fcontext\_get\_type**(3)**-**\
 return the file type for this file context spec

**semanage\_fcontext\_get\_type\_str**(3)**-**\
 return a string representation for this file context spec type

**semanage\_fcontext\_set\_type**(3)**-**\
 set the file type for this file context spec

**semanage\_fcontext\_get\_con**(3)**-**\
 return the SELinux context for this file context spec

**semanage\_fcontext\_set\_expr**(3)**-**\
 set the SELinux context for this file context spec

## Record Store API Overview

[**semanage\_fcontext\_modify\_local**(3)](/semanage_fcontext_modify_local/3.md)**-**\
 add or update a file context spec in the local store

[**semanage\_fcontext\_del\_local**(3)](/semanage_fcontext_del_local/3.md)**-**\
 delete a file context spec from the local store

[**semanage\_fcontext\_exists**(3)](/semanage_fcontext_exists/3.md)**-**\
 check if a file context spec is defined in the persistent policy

[**semanage\_fcontext\_exists\_local**(3)](/semanage_fcontext_exists_local/3.md)**-**\
 check if a file context spec is defined in the local store

[**semanage\_fcontext\_query**(3)](/semanage_fcontext_query/3.md)**-**\
 query a file context spec in the persistent policy

[**semanage\_fcontext\_query\_local**(3)](/semanage_fcontext_query_local/3.md)**-**\
 query a file context spec in the local store

[**semanage\_fcontext\_count**(3)](/semanage_fcontext_count/3.md)**-**\
 count the number of file context specs defined in the persistent policy

[**semanage\_fcontext\_count\_local**(3)](/semanage_fcontext_count_local/3.md)**-**\
 count the number of file context specs defined in the local store

[**semanage\_fcontext\_iterate**(3)](/semanage_fcontext_iterate/3.md)**-**\
 execute a callback for each file context spec in the persistent policy

[**semanage\_fcontext\_iterate\_local**(3)](/semanage_fcontext_iterate_local/3.md)**-**\
 execute a callback for each file context spec in the local store

[**semanage\_fcontext\_list**(3)](/semanage_fcontext_list/3.md)**-**\
 return an array containing all file context specs in the persistent policy

[**semanage\_fcontext\_list\_local**(3)](/semanage_fcontext_list_local/3.md)**-**\
 return an array containing all file context specs in the local store
