CfgMgr::CreateSnapshot

Description

Creates a parameter snapshot, which records all persistent parameters for restoration.

Prototype

uint32_t CfgMgr::CreateSnapshot(const std::string &snapshotName, const std::string &snapshotNamespace = "/", const bool isSync = true)

Function Security Level

ASIL-D

Parameters

Parameter

Input/Output

Description

snapshotName

Input

Snapshot file name, which is used for restoration.

snapshotNamespace

Input

Name space of a snapshot. By default, all snapshots are included.

isSync

Input

Whether to write snapshot files synchronously. The default value is true.

Returns

The return value is of the uint32_t type. If the operation is successful, CFGMGR_SUCCESS is returned. If the operation fails, an error code is returned.

Usage

  • A snapshot will be overwritten by that with the same name.
  • Only persistent parameters are saved during snapshot creation.
  • After SELinux permission control is enabled, non-privileged processes can be called only after the read and write permissions on dp:/res/cfgmgr/mgmt are configured.

Precautions

  • The snapshot name cannot exceed 32 bytes and cannot be empty. Only letters, digits, and underscores (_) are allowed. Otherwise, a failure message is returned.
  • The snapshot name cannot be suffixed with _backup to avoid name conflicts with internal backup files. Otherwise, a failure message is returned.
  • If a snapshot file fails to be created, determine whether to report the fault or perform other operations.