This module provides an easy-to-use key-value pair access interface for system services to configure service functions based on their own system parameters. The following figure shows the basic primitives used to access and operate system parameters.
**Figure 1** Operation primitives for system parameters<aname="fig1976004014480"></a>
<tdclass="cellrowborder"valign="top"width="84.03%"headers="mcps1.2.3.1.2 "><pid="p199021165116"><aname="p199021165116"></a><aname="p199021165116"></a>Obtains the value of a system parameter.</p>
<tdclass="cellrowborder"valign="top"width="84.03%"headers="mcps1.2.3.1.2 "><pid="p1990181115112"><aname="p1990181115112"></a><aname="p1990181115112"></a>Sets the value of a system parameter.</p>
<tdclass="cellrowborder"valign="top"width="84.03%"headers="mcps1.2.3.1.2 "><pid="p399010135114"><aname="p399010135114"></a><aname="p399010135114"></a>Waits for value change of a system parameter synchronously.</p>
<tdclass="cellrowborder"valign="top"width="84.03%"headers="mcps1.2.3.1.2 "><pid="p49914114514"><aname="p49914114514"></a><aname="p49914114514"></a>Observes value change of a system parameter asynchronously.</p>
</td>
</tr>
</tbody>
</table>
A system parameter name consists of multiple segments in dotted notation. Each segment consists of letters, digits, and underscores \(\_\). The total length cannot exceed 96 bytes. System parameter names are categorized into the following two types.
<tdclass="cellrowborder"valign="top"width="40.63%"headers="mcps1.2.5.1.4 "><pid="p179491489392"><aname="p179491489392"></a><aname="p179491489392"></a>Complete system parameter name. It does not end with a period (.).</p>
<tdclass="cellrowborder"valign="top"width="40.63%"headers="mcps1.2.5.1.4 "><pid="p49502843912"><aname="p49502843912"></a><aname="p49502843912"></a>Name of the directory storing system parameters with the same prefix. It ends with a period (.).</p>
</td>
</tr>
</tbody>
</table>
System parameters are categorized into three types.
<tdclass="cellrowborder"valign="top"width="62.15621562156216%"headers="mcps1.2.4.1.3 "><pid="p04018486398"><aname="p04018486398"></a><aname="p04018486398"></a>Constant parameter, which will not be changed once a value is assigned. The value can contain a maximum of 4,096 bytes (including the terminator).</p>
<tdclass="cellrowborder"valign="top"width="62.15621562156216%"headers="mcps1.2.4.1.3 "><pid="p17401548203919"><aname="p17401548203919"></a><aname="p17401548203919"></a>Writable parameter, which will be lost after system restart. The value can contain a maximum of 96 bytes (including the terminator).</p>
<tdclass="cellrowborder"valign="top"width="62.15621562156216%"headers="mcps1.2.4.1.3 "><pid="p124011485394"><aname="p124011485394"></a><aname="p124011485394"></a>Writable and persistent parameter, which will not be lost after system restart. The value can contain a maximum of 96 bytes (including the terminator).</p>
</td>
</tr>
</tbody>
</table>
The naming format of system parameters is as follows: \[**const**|**persist**\].**$sub\_system**.**$desc**.
**$sub\_system** is the name of the subsystem or module.
**$desc** indicates the description of a system parameter. The description can contain multiple segments in dotted notation.
## System Parameter Definition Rules<a name="section431671411293"></a>
Each subsystem defines the system parameters of its own modules, including the system parameter name, default value, and access permission information.
### System Parameter Value Definition File<a name="section885018321291"></a>
The system parameter value definition file ends with the **.para** extension. An example of the file format is as follows:
```
# This is comment
const.product.name=OHOS-PRODUCT
const.os.version.api=26
const.telephony.enable=false|true
const.test.withblank=My Value
```
Note: System parameter values do not support comments and line breaks.
```
# Not supported
const.test.withcomment=MyValue # This should be ommitted
# Not supported
const.test.multiline="This is a multiline parameter.
Line2 value.
Last line."
```
You must use a complete system parameter command when assigning a value for a system parameter. The following table describes the value assignment modes.
<tdclass="cellrowborder"valign="top"width="53.36533653365336%"headers="mcps1.2.4.1.3 "><pid="p154513142069"><aname="p154513142069"></a><aname="p154513142069"></a>Multi-line character strings and comments are not supported.</p>
<tdclass="cellrowborder"valign="top"width="53.36533653365336%"headers="mcps1.2.4.1.3 "><pid="p1453146614"><aname="p1453146614"></a><aname="p1453146614"></a>Numbers do not need to be enclosed in quotation marks.</p>
<tdclass="cellrowborder"valign="top"width="53.36533653365336%"headers="mcps1.2.4.1.3 "><pid="p164551415610"><aname="p164551415610"></a><aname="p164551415610"></a>A Boolean value can be <strongid="b8188102315415"><aname="b8188102315415"></a><aname="b8188102315415"></a>0</strong>, <strongid="b64910241414"><aname="b64910241414"></a><aname="b64910241414"></a>1</strong>, <strongid="b116922684114"><aname="b116922684114"></a><aname="b116922684114"></a>false</strong>, or <strongid="b13402102744114"><aname="b13402102744114"></a><aname="b13402102744114"></a>true</strong>.</p>
</td>
</tr>
</tbody>
</table>
### System Parameter DAC Definition File<a name="section1333155762915"></a>
Currently, access permissions of system parameters are managed in Discretionary Access Control \(DAC\) mode. The access permission definition file ends with the **.para.dac** extension. The following is an example:
```
const.product.="root:root:660"
```
As shown above, we can use **parameter directory** to define the same access permission for system parameters with the same prefix. The DAC information is divided into three segments, user, group, and UGO rule information, which are separated using a semicolon \(:\).
The following figure shows the structure of the UGO rule information.
<tdclass="cellrowborder"valign="top"width="53.15531553155315%"headers="mcps1.2.4.1.3 "><pid="p7342151818115"><aname="p7342151818115"></a><aname="p7342151818115"></a>In kernel parameters, <strongid="b93436589497"><aname="b93436589497"></a><aname="b93436589497"></a>ohospara.xxx=valXXX</strong> is converted to <strongid="b5967204145020"><aname="b5967204145020"></a><aname="b5967204145020"></a>ohos.boot.xxx=valXXX</strong>.</p>
<tdclass="cellrowborder"valign="top"width="53.15531553155315%"headers="mcps1.2.4.1.3 "><pid="p163421186115"><aname="p163421186115"></a><aname="p163421186115"></a>The definition file containing OS constants is preferentially loaded.</p>
</td>
</tr>
<trid="row1098101119"><tdclass="cellrowborder"valign="top"width="16.661666166616662%"headers="mcps1.2.4.1.1 "><pid="p14342171815115"><aname="p14342171815115"></a><aname="p14342171815115"></a>System parameters in the <strongid="b19874122065519"><aname="b19874122065519"></a><aname="b19874122065519"></a>vendor</strong> directory</p>
<tdclass="cellrowborder"valign="top"width="53.15531553155315%"headers="mcps1.2.4.1.3 "><pid="p9342171861112"><aname="p9342171861112"></a><aname="p9342171861112"></a>The definition file containing system parameters in the <strongid="b974219911015"><aname="b974219911015"></a><aname="b974219911015"></a>vendor</strong> directory is loaded with the secondary priority. It can overwrite the definition file containing system parameters in the <strongid="b1544125011115"><aname="b1544125011115"></a><aname="b1544125011115"></a>system</strong> directory.</p>
</td>
</tr>
<trid="row1301784115"><tdclass="cellrowborder"valign="top"width="16.661666166616662%"headers="mcps1.2.4.1.1 "><pid="p234241851115"><aname="p234241851115"></a><aname="p234241851115"></a>System parameters in the <strongid="b0483162515513"><aname="b0483162515513"></a><aname="b0483162515513"></a>system</strong> directory</p>
<tdclass="cellrowborder"valign="top"width="53.15531553155315%"headers="mcps1.2.4.1.3 "><pid="p134351881120"><aname="p134351881120"></a><aname="p134351881120"></a>The definition file containing system parameters in the <strongid="b1769018221223"><aname="b1769018221223"></a><aname="b1769018221223"></a>system</strong> directory is last loaded. If a system parameter value already exists in the file, it will be ignored.</p>
</td>
</tr>
</tbody>
</table>
## Usage of Shell Commands<a name="section2039119283111"></a>
The following table describes the shell commands used to set system parameters.
<tbody><trid="row169122781510"><tdclass="cellrowborder"valign="top"width="20.5%"headers="mcps1.2.3.1.1 "><pid="p6942112161517"><aname="p6942112161517"></a><aname="p6942112161517"></a>param get [<strongid="b1942161281515"><aname="b1942161281515"></a><aname="b1942161281515"></a>key</strong>]</p>
</td>
<tdclass="cellrowborder"valign="top"width="79.5%"headers="mcps1.2.3.1.2 "><pid="p594291216151"><aname="p594291216151"></a><aname="p594291216151"></a>Obtains the system parameter value of the specified key. If no key name is specified, all system parameter values will be returned.</p>
</td>
</tr>
<trid="row17912472157"><tdclass="cellrowborder"valign="top"width="20.5%"headers="mcps1.2.3.1.1 "><pid="p3942191271519"><aname="p3942191271519"></a><aname="p3942191271519"></a>param set <strongid="b7942171219153"><aname="b7942171219153"></a><aname="b7942171219153"></a>key value</strong></p>
</td>
<tdclass="cellrowborder"valign="top"width="79.5%"headers="mcps1.2.3.1.2 "><pid="p1494271218159"><aname="p1494271218159"></a><aname="p1494271218159"></a>Sets the specified value for the specified key.</p>
<tdclass="cellrowborder"valign="top"width="79.5%"headers="mcps1.2.3.1.2 "><pid="p6943912161512"><aname="p6943912161512"></a><aname="p6943912161512"></a>Waits for the system parameter value of the specified key to match the specified value. Fuzzy match is supported. For example, <strongid="b79411030762"><aname="b79411030762"></a><aname="b79411030762"></a>*</strong> indicates any value, and <strong id="b162794371964"><a name="b162794371964"></a><a name="b162794371964"></a>val*</strong> indicates matching of only the first three val characters.</p>
<tdclass="cellrowborder"valign="top"width="79.5%"headers="mcps1.2.3.1.2 "><pid="p89431212201516"><aname="p89431212201516"></a><aname="p89431212201516"></a>Displays the statistics of system parameters.</p>
</td>
</tr>
</tbody>
</table>
## Available APIs<a name="section0137175692616"></a>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p13562171015712"><aname="p13562171015712"></a><aname="p13562171015712"></a>Obtains a system parameter.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p8150164120555"><aname="p8150164120555"></a><aname="p8150164120555"></a>Sets or updates a system parameter.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p12366194110514"><aname="p12366194110514"></a><aname="p12366194110514"></a>Obtains the device type.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p191521415555"><aname="p191521415555"></a><aname="p191521415555"></a>Obtains the device manufacturer.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p2371719599"><aname="p2371719599"></a><aname="p2371719599"></a>Obtains the device brand.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p65011156165811"><aname="p65011156165811"></a><aname="p65011156165811"></a>Obtains the device series name.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p1827910551901"><aname="p1827910551901"></a><aname="p1827910551901"></a>Obtains the device serial number (SN).</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p181037531301"><aname="p181037531301"></a><aname="p181037531301"></a>Obtains the operating system name.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p582251708"><aname="p582251708"></a><aname="p582251708"></a>Obtains the software version visible to users.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p11122497014"><aname="p11122497014"></a><aname="p11122497014"></a>Obtains the bootloader version of this device.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p8852114628"><aname="p8852114628"></a><aname="p8852114628"></a>Obtains the list of application binary interfaces (ABIs) supported on this device.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p18940171215214"><aname="p18940171215214"></a><aname="p18940171215214"></a>Obtains the SDK API version that matches the current system software.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p3820810521"><aname="p3820810521"></a><aname="p3820810521"></a>Obtains the first SDK API version of the system software.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p95621087211"><aname="p95621087211"></a><aname="p95621087211"></a>Obtains the incremental version.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p148761512312"><aname="p148761512312"></a><aname="p148761512312"></a>Obtains the version ID.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p67491212437"><aname="p67491212437"></a><aname="p67491212437"></a>Obtains the build type.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p178466109315"><aname="p178466109315"></a><aname="p178466109315"></a>Obtains the build account user name.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p1466114365814"><aname="p1466114365814"></a><aname="p1466114365814"></a>Obtains the build time.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p7945171118466"><aname="p7945171118466"></a><aname="p7945171118466"></a>Obtains the buildroot hash value of this version.</p>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p1510173425513"><aname="p1510173425513"></a><aname="p1510173425513"></a>Obtains the system release type.</p>
</td>
</tr>
<trid="row39251243533"><tdclass="cellrowborder"valign="top"width="57.29%"headers="mcps1.2.3.1.1 "><pid="p119261643535"><aname="p119261643535"></a><aname="p119261643535"></a>int GetDevUdid(char *udid, int size)</p>
</td>
<tdclass="cellrowborder"valign="top"width="42.71%"headers="mcps1.2.3.1.2 "><pid="p1292654125319"><aname="p1292654125319"></a><aname="p1292654125319"></a>Obtains the device identifier (UDID).</p>
</td>
</tr>
</tbody>
</table>
## How to Use<a name="section118404913233"></a>
The following is an example of using syspara.
```
// set && get
char key1[] = "rw.sys.version";
char value1[] = "10.1.0";
int ret = SetParameter(key1, value1);
char valueGet1[128] = {0};
ret = GetParameter(key1, "version=10.1.0", valueGet1, 128);