.\" Automatically generated by Pandoc 2.0.6 .\" .TH "PMEM2_CONFIG_SET_PROTECTION" "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_config_set_protection\f[]() \- set a protection flags in pmem2_config structure. .SH SYNOPSIS .IP .nf \f[C] #include\ struct\ pmem2_config; #define\ PMEM2_PROT_EXEC\ \ \ \ \ (1U\ <<\ 29) #define\ PMEM2_PROT_READ\ \ \ \ \ (1U\ <<\ 30) #define\ PMEM2_PROT_WRITE\ \ \ \ (1U\ <<\ 31) #define\ PMEM2_PROT_NONE\ \ \ \ \ 0 int\ pmem2_config_set_protection(struct\ pmem2_config\ *cfg, \ \ \ \ \ \ \ \ unsigned\ prot); \f[] .fi .SH DESCRIPTION .PP The \f[B]pmem2_config_set_protection\f[]() function sets the protection flags which will be used for memory mapping. The default value in pmem2_config structure is \f[B]PMEM2_PROT_READ | PMEM2_PROT_WRITE\f[]. The \f[I]argument describes the desired memory protection of the mapping. The memory protection cannot conflict with the file opening\-mode. \f[]*config* should be already initialized, please see \f[B]pmem2_config_new\f[](3) for details. .PP It is either PROT_NONE or the bitwise OR of one or more of the following flags: .IP \[bu] 2 \f[B]PMEM2_PROT_EXEC\f[] \- Pages may be executed. .IP \[bu] 2 \f[B]PMEM2_PROT_READ\f[] \- Pages may be read. .IP \[bu] 2 \f[B]PMEM2_PROT_WRITE\f[] \- Pages may be written. .IP \[bu] 2 \f[B]PMEM2_PROT_NONE\f[] \- Pages may not be accessed. On Windows this flag is not supported. .SH RETURN VALUE .PP The \f[B]pmem2_config_set_protection\f[]() function returns 0 on success or a negative error code on failure. .SH ERRORS .PP The \f[B]pmem2_config_set_protection\f[]() can fail with the following errors: .IP \[bu] 2 \f[B]PMEM2_E_INVALID_PROT_FLAG\f[] \- some or all of the provided flags are not valid. .SH SEE ALSO .PP \f[B]libpmem2\f[](7), \f[B]pmem2_config_new\f[](3), \f[B]pmem2_map_new\f[](3) and \f[B]\f[]