1*84d9c625SLionel Sambuc.\" $NetBSD: stat_flags.3,v 1.8 2012/09/19 23:22:56 wiz Exp $ 20c3983b2SBen Gras.\" 30c3983b2SBen Gras.\" Copyright (c) 1996 The NetBSD Foundation, Inc. 40c3983b2SBen Gras.\" All rights reserved. 50c3983b2SBen Gras.\" 60c3983b2SBen Gras.\" This code is derived from software contributed to The NetBSD Foundation 70c3983b2SBen Gras.\" by Christos Zoulas. 80c3983b2SBen Gras.\" 90c3983b2SBen Gras.\" Redistribution and use in source and binary forms, with or without 100c3983b2SBen Gras.\" modification, are permitted provided that the following conditions 110c3983b2SBen Gras.\" are met: 120c3983b2SBen Gras.\" 1. Redistributions of source code must retain the above copyright 130c3983b2SBen Gras.\" notice, this list of conditions and the following disclaimer. 140c3983b2SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright 150c3983b2SBen Gras.\" notice, this list of conditions and the following disclaimer in the 160c3983b2SBen Gras.\" documentation and/or other materials provided with the distribution. 170c3983b2SBen Gras.\" 180c3983b2SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 190c3983b2SBen Gras.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 200c3983b2SBen Gras.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 210c3983b2SBen Gras.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 220c3983b2SBen Gras.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 230c3983b2SBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 240c3983b2SBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 250c3983b2SBen Gras.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 260c3983b2SBen Gras.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 270c3983b2SBen Gras.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 280c3983b2SBen Gras.\" POSSIBILITY OF SUCH DAMAGE. 290c3983b2SBen Gras.\" 30*84d9c625SLionel Sambuc.Dd September 20, 2012 310c3983b2SBen Gras.Dt STAT_FLAGS 3 320c3983b2SBen Gras.Os 330c3983b2SBen Gras.Sh NAME 340c3983b2SBen Gras.Nm string_to_flags , 350c3983b2SBen Gras.Nm flags_to_string 360c3983b2SBen Gras.Nd Stat flags parsing and printing functions 370c3983b2SBen Gras.Sh LIBRARY 380c3983b2SBen Gras.Lb libutil 390c3983b2SBen Gras.Sh SYNOPSIS 400c3983b2SBen Gras.In util.h 410c3983b2SBen Gras.Ft char * 420c3983b2SBen Gras.Fn flags_to_string "u_long flags" "const char *def" 430c3983b2SBen Gras.Ft int 44*84d9c625SLionel Sambuc.Fn string_to_flags "char **stringp" "u_long *setp" "u_long *clrp" 450c3983b2SBen Gras.Sh DESCRIPTION 460c3983b2SBen GrasThe 470c3983b2SBen Gras.Fn flags_to_string 480c3983b2SBen Grasand 490c3983b2SBen Gras.Fn string_to_flags 500c3983b2SBen Grasfunctions are used by 510c3983b2SBen Grasprograms such as 520c3983b2SBen Gras.Xr ls 1 , 530c3983b2SBen Gras.Xr mtree 8 , 540c3983b2SBen Gras.Xr makefs 8 , 550c3983b2SBen Grasetc., to parse and/or print the 560c3983b2SBen Gras.Dv st_flags field in the 570c3983b2SBen Gras.Xr stat 2 580c3983b2SBen Grasstructure. 590c3983b2SBen Gras.Pp 600c3983b2SBen GrasThey recognize the following flags: 610c3983b2SBen Gras.Bl -column -offset indent "uappnd " "SF_IMMUTABLE" "xxx" 620c3983b2SBen Gras.It Sy String Ta Sy Flag Ta Sy Description 630c3983b2SBen Gras.It Va arch Ta Dv SF_ARCHIVED Ta file is archived 640c3983b2SBen Gras.It Va nodump Ta Dv UF_NODUMP Ta do not dump file 650c3983b2SBen Gras.It Va opaque Ta Dv UF_OPAQUE Ta directory is opaque in union filesystems 660c3983b2SBen Gras.It Va sappnd Ta Dv SF_APPEND Ta writes to the file may only append 670c3983b2SBen Gras.It Va schg Ta Dv SF_IMMUTABLE Ta file cannot be changed; it is immutable 680c3983b2SBen Gras.It Va snap Ta Dv SF_SNAPSHOT Ta file is a snapshot inode 690c3983b2SBen Gras.It Va uappnd Ta Dv UF_APPEND Ta writes to the file may only append 700c3983b2SBen Gras.It Va uchg Ta Dv UF_IMMUTABLE Ta file cannot be changed; it is immutable 710c3983b2SBen Gras.El 720c3983b2SBen Gras.Pp 730c3983b2SBen GrasThe 740c3983b2SBen Gras.Dv SF_APPEND 750c3983b2SBen Grasand 760c3983b2SBen Gras.Dv SF_IMMUTABLE 770c3983b2SBen Grasflags are for the superuser only, whereas 780c3983b2SBen Gras.Dv UF_APPEND 790c3983b2SBen Grasand 800c3983b2SBen Gras.Dv UF_IMMUTABLE 810c3983b2SBen Grasare for the user only. 820c3983b2SBen Gras.Pp 830c3983b2SBen GrasThe 840c3983b2SBen Gras.Fn flags_to_string 850c3983b2SBen Grasfunction converts the bits set in the 860c3983b2SBen Gras.Fa flags 870c3983b2SBen Grasargument to a comma-separated string and returns it. 880c3983b2SBen GrasIf no flags are set, then the 890c3983b2SBen Gras.Fa def 900c3983b2SBen Grasstring is returned. 910c3983b2SBen GrasThe returned string is allocated via 920c3983b2SBen Gras.Xr malloc 3 930c3983b2SBen Grasand it is the responsibility of the caller to 940c3983b2SBen Gras.Xr free 3 950c3983b2SBen Grasit. 960c3983b2SBen Gras.Pp 970c3983b2SBen GrasThe 980c3983b2SBen Gras.Fn string_to_flags 990c3983b2SBen Grasfunction takes a 1000c3983b2SBen Gras.Fa stringp 1010c3983b2SBen Grasof space, comma, or tab separated flag names 1020c3983b2SBen Grasand places their bit value on the 1030c3983b2SBen Gras.Fa setp 1040c3983b2SBen Grasargument. 1050c3983b2SBen GrasIf the flag name is prefixed by: 1060c3983b2SBen Gras.Dq no , 1070c3983b2SBen Grasthen the bit value is placed on the 1080c3983b2SBen Gras.Fa clrp 1090c3983b2SBen Grasargument. 1100c3983b2SBen Gras.Sh RETURN VALUES 1110c3983b2SBen Gras.Fn flags_to_string 1120c3983b2SBen Grasreturns the symbolic representation of flags, the default string, or 1130c3983b2SBen Gras.Dv NULL 1140c3983b2SBen Grasif allocation failed. 1150c3983b2SBen Gras.Pp 1160c3983b2SBen Gras.Fn string_to_flags 1170c3983b2SBen Grasreturns 1180c3983b2SBen Gras.Dv 0 1190c3983b2SBen Grason success and 1200c3983b2SBen Gras.Dv 1 1210c3983b2SBen Grasif it fails to parse the string, setting 1220c3983b2SBen Gras.Fa stringp 1230c3983b2SBen Grasto point to the first string that it failed to parse. 1240c3983b2SBen Gras.Sh SEE ALSO 125dba3562dSLionel Sambuc.Xr chflags 2 , 1260c3983b2SBen Gras.Xr stat 2 127