1.\" $NetBSD: setmode.3,v 1.7 1995/10/12 15:39:28 jtc Exp $ 2.\" 3.\" Copyright (c) 1989, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)setmode.3 8.1 (Berkeley) 6/9/93 35.\" 36.Dd June 9, 1993 37.Dt SETMODE 3 38.Os 39.Sh NAME 40.Nm getmode , 41.Nm setmode 42.Nd modify mode bits 43.Sh SYNOPSIS 44.Ft mode_t 45.Fn getmode "const void *set" "mode_t mode" 46.Ft void * 47.Fn setmode "const char *mode_str" 48.Sh DESCRIPTION 49The 50.Fn getmode 51function 52returns a copy of the file permission bits 53.Fa mode 54as altered by the values pointed to by 55.Fa set . 56While only the mode bits are altered, other parts of the file mode 57may be examined. 58.Pp 59The 60.Fn setmode 61function 62takes an absolute (octal) or symbolic value, as described in 63.Xr chmod 1 , 64as an argument 65and returns a pointer to mode values to be supplied to 66.Fn getmode . 67Because some of the symbolic values are relative to the file 68creation mask, 69.Fn setmode 70may call 71.Xr umask 2 . 72If this occurs, the file creation mask will be restored before 73.Fn setmode 74returns. 75If the calling program changes the value of its file creation mask 76after calling 77.Fn setmode , 78.Fn setmode 79must be called again if 80.Fn getmode 81is to modify future file modes correctly. 82.Pp 83If the mode passed to 84.Fn setmode 85is invalid, 86.Fn setmode 87returns 88.Dv NULL . 89.Sh ERRORS 90The 91.Fn setmode 92function 93may fail and set errno for any of the errors specified for the library 94routine 95.Xr malloc 3 . 96.Sh SEE ALSO 97.Xr chmod 1 , 98.Xr stat 2 , 99.Xr umask 2 , 100.Xr malloc 3 101.Sh HISTORY 102The 103.Fn getmode 104and 105.Fn setmode 106functions first appeared in 4.4BSD. 107