.\" Automatically generated by Pandoc 2.0.6 .\" .TH "PMEM2_SOURCE_DEVICE_USC" "3" "2022-08-25" "PMDK - pmem2 API version 1.0" "PMDK Programmer's Manual" .hy .\" SPDX-License-Identifier: BSD-3-Clause .\" Copyright 2020, Intel Corporation .SH NAME .PP \f[B]pmem2_source_device_usc\f[]() \- returns the \f[I]unsafe shutdown counter\f[] value of a device .SH SYNOPSIS .IP .nf \f[C] #include\ struct\ pmem2_source; int\ pmem2_source_device_usc(const\ struct\ pmem2_source\ *source,\ uint64_t\ *usc); \f[] .fi .SH DESCRIPTION .PP The \f[B]pmem2_source_device_usc\f[]() function retrieves the sum of the \f[I]unsafe shutdown count\f[](\f[B]USC\f[]) values of all hardware devices backing the data source and stores it in \f[I]*usc\f[]. .PP Please refer to \f[B]libpmem2_unsafe_shutdown\f[](7) for detailed description on how to properly consume this information. .SH RETURN VALUE .PP The \f[B]pmem2_source_device_usc\f[]() function returns 0 on success. If the function fails, the \f[I]*usc\f[] variable content is left unmodified and a negative error code is returned. .SH ERRORS .PP The \f[B]pmem2_source_device_usc\f[]() can fail with the following errors: .PP On all systems: .IP \[bu] 2 \f[B]PMEM2_E_NOSUPP\f[] \- the underlying platform does not expose unsafe shutdown count information. .PP On Windows: .IP \[bu] 2 \-\f[B]errno\f[] equivalent of return code set by failing \f[B]GetFinalPathNameByHandleW\f[](), while trying to resolve volume path from the file handle. .IP \[bu] 2 \-\f[B]errno\f[] set by failing \f[B]malloc\f[](3), while trying to allocate a buffer for storing volume path. .IP \[bu] 2 \-\f[B]errno\f[] equivalent of return code set by failing \f[B]CreateFileW\f[](), while trying to obtain a handle to the volume. .IP \[bu] 2 \-\f[B]errno\f[] equivalent of return code set by failing \f[B]DeviceIoControl\f[](), while trying to obtain volume \f[B]USC\f[] value. .PP On Linux: .IP \[bu] 2 \-\f[B]errno\f[] set by failing \f[B]fstat\f[](2), while trying to validate the file descriptor. .IP \[bu] 2 \-\f[B]errno\f[] set by failing \f[B]ndctl_new\f[](), while trying to initiate a new NDCTL library context. .IP \[bu] 2 \-\f[B]errno\f[] set by failing \f[B]ndctl_dimm_get_dirty_shutdown\f[](), while trying to obtain DIMM \f[B]USC\f[] value. .SH SEE ALSO .PP \f[B]fstat\f[](2), \f[B]errno\f[](3), \f[B]malloc\f[](3), \f[B]libpmem2_unsafe_shutdown\f[](7), and \f[B]\f[]