Compressed Dump

Compressed Dump White Paper, Version 1.3
page 12
Example 4: Using CCERR_STRINGS and CCWARN_STRINGS
Assume only one device, devices[0], is being added to the dump configuration. The
following code will check the device_return[0] value and print corresponding error or
warning messages.
char *ccerrs[] = {
CCERR_STRINGS
};
int num_ccerrs = sizeof(ccerrs)/sizeof(*ccerrs);
char *ccwarns[] = {
CCWARN_STRINGS
};
int num_ccwarns = sizeof(ccwarns)/sizeof(*ccwarns);
char *device_to_add[1];
int device_return[1];
...
crashconf(DC_DEVICES, 0, 0, 1, device_to_add, device_return);
if (device_return[0] < 0) {
if (device_return[0] > -num_ccerrs)
fprintf(stderr, "%s: error: %s", device_to_add[0],
ccerrs[-device_return[0]]);
} else if (device_return[0] > 0) {
int warn_num;
for (warn_num = 0; warn_num < NUM_CCWARNS; warn_num++)
if (device_return[0] & (1 << warn_num))
fprintf(stderr,"%s: warning: %s",
device_to_add[0], ccwarns[warn_num]);
}
Example 5: Setting Compressed Dump ON, Excluding Unused Pages
crashconf(DC_SETCOMPRESS | DC_EXCLUDE, DT_UNUSED, 0,
NULL, NULL);
RETURN VALUE
Upon successful completion, zero is returned. Otherwise, a value of -1 is returned
and errno is set to indicate the error. If DC_DEVICES is set, a one (1) may be
returned to indicate that at least one device has been configured but one or more
devices failed to configure.
ERRORS
crashconf() fails if one or more of the following is true:
[EPERM] The calling process does not have appropriate privileges.
[EINVAL] operation does not have at least one of DC_INCLUDE,
DC_EXCLUDE, DC_SETCOMPRESS,
DC_SETNOCOMPRESS, or DC_DEVICES set.