cryptsetup API
Public cryptsetup API
Loading...
Searching...
No Matches
Macros | Enumerations | Functions
Function to wipe device

Macros

#define CRYPT_WIPE_NO_DIRECT_IO   (UINT32_C(1) << 0)
 

Enumerations

enum  crypt_wipe_pattern { CRYPT_WIPE_ZERO , CRYPT_WIPE_RANDOM , CRYPT_WIPE_ENCRYPTED_ZERO , CRYPT_WIPE_SPECIAL }
 
enum  { CRYPT_LUKS2_SEGMENT = -2 , CRYPT_NO_SEGMENT = -1 }
 

Functions

int crypt_wipe (struct crypt_device *cd, const char *dev_path, crypt_wipe_pattern pattern, uint64_t offset, uint64_t length, size_t wipe_block_size, uint32_t flags, int(*progress)(uint64_t size, uint64_t offset, void *usrptr), void *usrptr)
 
int crypt_wipe_hw_opal (struct crypt_device *cd, int segment, const char *password, size_t password_size, uint32_t flags)
 

Detailed Description

Macro Definition Documentation

◆ CRYPT_WIPE_NO_DIRECT_IO

#define CRYPT_WIPE_NO_DIRECT_IO   (UINT32_C(1) << 0)

Use direct-io

Enumeration Type Documentation

◆ crypt_wipe_pattern

Wipe pattern

Enumerator
CRYPT_WIPE_ZERO 

Fill with zeroes

CRYPT_WIPE_RANDOM 

Use RNG to fill data

CRYPT_WIPE_ENCRYPTED_ZERO 

Obsolete, same as CRYPT_WIPE_RANDOM

CRYPT_WIPE_SPECIAL 

Compatibility only, do not use (Gutmann method)

Function Documentation

◆ crypt_wipe()

int crypt_wipe ( struct crypt_device *  cd,
const char *  dev_path,
crypt_wipe_pattern  pattern,
uint64_t  offset,
uint64_t  length,
size_t  wipe_block_size,
uint32_t  flags,
int(*)(uint64_t size, uint64_t offset, void *usrptr)  progress,
void *  usrptr 
)

Wipe/Fill (part of) a device with the selected pattern.

Parameters
cdcrypt device handle
dev_pathpath to device to wipe or NULL if data device should be used
patternselected wipe pattern
offsetoffset on device (in bytes)
lengthlength of area to be wiped (in bytes)
wipe_block_sizeused block for wiping (one step) (in bytes)
flagswipe flags
progresscallback function called after each wipe_block_size or NULL
usrptrprovided identification in callback
Returns
0 on success or negative errno value otherwise.
Note
A progress callback can interrupt wipe process by returning non-zero code.
If the error values is -EIO or -EINTR, some part of the device could be overwritten. Other error codes (-EINVAL, -ENOMEM) means that no IO was performed.

◆ crypt_wipe_hw_opal()

int crypt_wipe_hw_opal ( struct crypt_device *  cd,
int  segment,
const char *  password,
size_t  password_size,
uint32_t  flags 
)

Safe erase of a partition or an entire OPAL device. WARNING: ALL DATA ON PARTITION/DISK WILL BE LOST. If the CRYPT_NO_SEGMENT is passed as the segment parameter, the entire device will be wiped, not just what is included in the LUKS2 device/partition.

Parameters
cdcrypt device handle
segmentthe segment number to wipe (0..8), or CRYPT_LUKS2_SEGMENT to wipe the segment configured in the LUKS2 header, or CRYPT_NO_SEGMENT to wipe the entire device via a factory reset.
passwordadmin password/PSID (for factory reset) to wipe the partition/device
password_sizelength of password/PSID
flags(currently unused)
Returns
0 on success or negative errno value otherwise.