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