xref: /dflybsd-src/share/man/man9/VOP_ATTRIB.9 (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino.\" Copyright (c) 1996 Doug Rabson
2*86d7f5d3SJohn Marino.\"
3*86d7f5d3SJohn Marino.\" All rights reserved.
4*86d7f5d3SJohn Marino.\"
5*86d7f5d3SJohn Marino.\" This program is free software.
6*86d7f5d3SJohn Marino.\"
7*86d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without
8*86d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions
9*86d7f5d3SJohn Marino.\" are met:
10*86d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright
11*86d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer.
12*86d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright
13*86d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer in the
14*86d7f5d3SJohn Marino.\"    documentation and/or other materials provided with the distribution.
15*86d7f5d3SJohn Marino.\"
16*86d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17*86d7f5d3SJohn Marino.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18*86d7f5d3SJohn Marino.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19*86d7f5d3SJohn Marino.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20*86d7f5d3SJohn Marino.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21*86d7f5d3SJohn Marino.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22*86d7f5d3SJohn Marino.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23*86d7f5d3SJohn Marino.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24*86d7f5d3SJohn Marino.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25*86d7f5d3SJohn Marino.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*86d7f5d3SJohn Marino.\"
27*86d7f5d3SJohn Marino.\" $FreeBSD: src/share/man/man9/VOP_ATTRIB.9,v 1.9.2.2 2001/12/17 11:30:18 ru Exp $
28*86d7f5d3SJohn Marino.\"
29*86d7f5d3SJohn Marino.Dd July 24, 1996
30*86d7f5d3SJohn Marino.Dt VOP_ATTRIB 9
31*86d7f5d3SJohn Marino.Os
32*86d7f5d3SJohn Marino.Sh NAME
33*86d7f5d3SJohn Marino.Nm VOP_GETATTR ,
34*86d7f5d3SJohn Marino.Nm VOP_SETATTR
35*86d7f5d3SJohn Marino.Nd get and set attributes on a file or directory
36*86d7f5d3SJohn Marino.Sh SYNOPSIS
37*86d7f5d3SJohn Marino.In sys/param.h
38*86d7f5d3SJohn Marino.In sys/vnode.h
39*86d7f5d3SJohn Marino.Ft int
40*86d7f5d3SJohn Marino.Fn VOP_GETATTR "struct vnode *vp" "struct vattr *vap" "struct ucred *cred" "struct proc *p"
41*86d7f5d3SJohn Marino.Ft int
42*86d7f5d3SJohn Marino.Fn VOP_SETATTR "struct vnode *vp" "struct vattr *vap" "struct ucred *cred" "struct proc *p"
43*86d7f5d3SJohn Marino.Sh DESCRIPTION
44*86d7f5d3SJohn MarinoThese entry points manipulate various attributes of a file or directory,
45*86d7f5d3SJohn Marinoincluding file permissions, owner, group, size,
46*86d7f5d3SJohn Marinoaccess time and modification time.
47*86d7f5d3SJohn Marino.Pp
48*86d7f5d3SJohn MarinoThe arguments are:
49*86d7f5d3SJohn Marino.Bl -tag -width cred
50*86d7f5d3SJohn Marino.It Ar vp
51*86d7f5d3SJohn Marinothe vnode of the file
52*86d7f5d3SJohn Marino.It Ar vap
53*86d7f5d3SJohn Marinothe attributes of the file
54*86d7f5d3SJohn Marino.It Ar cred
55*86d7f5d3SJohn Marinothe user credentials of the calling process
56*86d7f5d3SJohn Marino.It Ar p
57*86d7f5d3SJohn Marinothe process
58*86d7f5d3SJohn Marino.El
59*86d7f5d3SJohn Marino.Pp
60*86d7f5d3SJohn MarinoAttributes which are not being modified by
61*86d7f5d3SJohn Marino.Xr VOP_SETATTR 9
62*86d7f5d3SJohn Marinoshould be set to the value
63*86d7f5d3SJohn Marino.Dv VNOVAL .
64*86d7f5d3SJohn Marino.Sh LOCKS
65*86d7f5d3SJohn Marino.Xr VOP_GETATTR 9
66*86d7f5d3SJohn Marinoexpects the vnode to be locked on entry and will leave the vnode locked on
67*86d7f5d3SJohn Marinoreturn.
68*86d7f5d3SJohn Marino.Pp
69*86d7f5d3SJohn Marino.Xr VOP_SETATTR 9
70*86d7f5d3SJohn Marinoexpects the vnode to be locked on entry and will leave the vnode locked on
71*86d7f5d3SJohn Marinoreturn.
72*86d7f5d3SJohn Marino.Sh RETURN VALUES
73*86d7f5d3SJohn Marino.Xr VOP_GETATTR 9
74*86d7f5d3SJohn Marinoreturns information about the file in
75*86d7f5d3SJohn Marino.Fa *vap .
76*86d7f5d3SJohn Marino.Xr VOP_SETATTR 9
77*86d7f5d3SJohn Marinoreturns zero if the attributes were changed successfully, otherwise an
78*86d7f5d3SJohn Marinoappropriate error is returned.
79*86d7f5d3SJohn Marino.Sh PSEUDOCODE
80*86d7f5d3SJohn Marino.Bd -literal
81*86d7f5d3SJohn Marinoint
82*86d7f5d3SJohn Marinovop_getattr(struct vnode *vp, struct vattr *vap,
83*86d7f5d3SJohn Marino	    struct ucred *cred, struct proc *p)
84*86d7f5d3SJohn Marino{
85*86d7f5d3SJohn Marino    /*
86*86d7f5d3SJohn Marino     * Fill in the contents of *vap with information from
87*86d7f5d3SJohn Marino     * the filesystem.
88*86d7f5d3SJohn Marino     */
89*86d7f5d3SJohn Marino    ...;
90*86d7f5d3SJohn Marino
91*86d7f5d3SJohn Marino    return 0;
92*86d7f5d3SJohn Marino}
93*86d7f5d3SJohn Marino
94*86d7f5d3SJohn Marinoint
95*86d7f5d3SJohn Marinovop_setattr(struct vnode *vp, struct vattr *vap,
96*86d7f5d3SJohn Marino	    struct ucred *cred, struct proc *p)
97*86d7f5d3SJohn Marino{
98*86d7f5d3SJohn Marino    /*
99*86d7f5d3SJohn Marino     * Check for unsettable attributes.
100*86d7f5d3SJohn Marino     */
101*86d7f5d3SJohn Marino    if ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) ||
102*86d7f5d3SJohn Marino	(vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) ||
103*86d7f5d3SJohn Marino	(vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) ||
104*86d7f5d3SJohn Marino	((int)vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) {
105*86d7f5d3SJohn Marino	return (EINVAL);
106*86d7f5d3SJohn Marino    }
107*86d7f5d3SJohn Marino
108*86d7f5d3SJohn Marino    if (vap->va_flags != VNOVAL) {
109*86d7f5d3SJohn Marino	/*
110*86d7f5d3SJohn Marino	 * Set the immutable and append flags of the file.
111*86d7f5d3SJohn Marino	 */
112*86d7f5d3SJohn Marino    }
113*86d7f5d3SJohn Marino
114*86d7f5d3SJohn Marino    if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) {
115*86d7f5d3SJohn Marino	/*
116*86d7f5d3SJohn Marino	 * Change owner and/or group of the file.
117*86d7f5d3SJohn Marino	 */
118*86d7f5d3SJohn Marino    }
119*86d7f5d3SJohn Marino
120*86d7f5d3SJohn Marino    if (vap->va_size != VNOVAL) {
121*86d7f5d3SJohn Marino	/*
122*86d7f5d3SJohn Marino	 * Truncate the file to the specified size.
123*86d7f5d3SJohn Marino	 */
124*86d7f5d3SJohn Marino    }
125*86d7f5d3SJohn Marino
126*86d7f5d3SJohn Marino    if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
127*86d7f5d3SJohn Marino	/*
128*86d7f5d3SJohn Marino	 * Change access and/or modification time of file.
129*86d7f5d3SJohn Marino	 */
130*86d7f5d3SJohn Marino    }
131*86d7f5d3SJohn Marino
132*86d7f5d3SJohn Marino    if (vap->va_mode != (mode_t)VNOVAL) {
133*86d7f5d3SJohn Marino	/*
134*86d7f5d3SJohn Marino	 * Change permissions of file.
135*86d7f5d3SJohn Marino	 */
136*86d7f5d3SJohn Marino    }
137*86d7f5d3SJohn Marino
138*86d7f5d3SJohn Marino    return 0;
139*86d7f5d3SJohn Marino}
140*86d7f5d3SJohn Marino.Ed
141*86d7f5d3SJohn Marino.Sh ERRORS
142*86d7f5d3SJohn Marino.Bl -tag -width Er
143*86d7f5d3SJohn Marino.It Bq Er EPERM
144*86d7f5d3SJohn MarinoThe file is immutable
145*86d7f5d3SJohn Marino.It Bq Er EACCES
146*86d7f5d3SJohn MarinoPermission denied
147*86d7f5d3SJohn Marino.It Bq Er EROFS
148*86d7f5d3SJohn MarinoThe filesystem is readonly
149*86d7f5d3SJohn Marino.El
150*86d7f5d3SJohn Marino.Sh SEE ALSO
151*86d7f5d3SJohn Marino.Xr vnode 9 ,
152*86d7f5d3SJohn Marino.Xr VOP_ACCESS 9
153*86d7f5d3SJohn Marino.Sh AUTHORS
154*86d7f5d3SJohn MarinoThis man page was written by
155*86d7f5d3SJohn Marino.An Doug Rabson .
156