summaryrefslogtreecommitdiff
path: root/share/man/man9/VOP_GETATTR.9
blob: 3989a35cf6411e76f96ee5bfa95a402c2c7e35a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
.\"	$OpenBSD: VOP_GETATTR.9,v 1.4 2007/12/09 20:54:01 jmc Exp $
.\"
.\" Copyright (c) 2005 Pedro Martelletto <pedro@ambientworks.net>
.\" All rights reserved.
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: December 9 2007 $
.Dt VOP_GETATTR 9
.Os
.Sh NAME
.Nm VOP_GETATTR ,
.Nm VOP_SETATTR
.Nd get or set vnode attributes
.Sh SYNOPSIS
.Fd #include <sys/vnode.h>
.Ft int
.Fo VOP_GETATTR
.Fa "struct vnode *vp"
.Fa "struct vattr *vap"
.Fa "struct ucred *cred"
.Fa "struct proc *p"
.Fc
.Ft int
.Fo VOP_SETATTR
.Fa "struct vnode *vp"
.Fa "struct vattr *vap"
.Fa "struct ucred *cred"
.Fa "struct proc *p"
.Fc
.Sh DESCRIPTION
The
.Nm VOP_GETATTR
and
.Nm VOP_SETATTR
routines implement a generic way of representing, retrieving, and setting many
vnode attributes such as size, number of references, access mode, and last
modified time.
All attributes are held in the
.Fa vattr
structure described below.
.Bd -literal
struct vattr {
        enum vtype      va_type;        /* vnode type */
        mode_t          va_mode;        /* files access mode and type */
        nlink_t         va_nlink;       /* number of references */
        uid_t           va_uid;         /* owner user id */
        gid_t           va_gid;         /* owner group id */
        long            va_fsid;        /* file system id */
        long            va_fileid;      /* file id */
        u_quad_t        va_size;        /* file size in bytes */
        long            va_blocksize;   /* blocksize preferred for i/o */
        struct timespec va_atime;       /* time of last access */
        struct timespec va_mtime;       /* time of last modification */
        struct timespec va_ctime;       /* time file changed */
        u_long          va_gen;         /* generation number of file */
        u_long          va_flags;       /* flags defined for file */
        dev_t           va_rdev;        /* device the vnode represents */
        u_quad_t        va_bytes;       /* bytes of held disk space */
        u_quad_t        va_filerev;     /* file modification number */
        u_int           va_vaflags;     /* operations flags */
        long            va_spare;       /* remain quad aligned */
};
.Ed
.Sh IMPLEMENTATION NOTES
Depending on the specific filesystem implementation, some values may not be
available for modification and/or retrieval.
In these cases, the corresponding fields in the
.Fa vattr
structure should be set to
.Dv VNOVAL .
.Pp
Upon return from a
.Fn VOP_GETATTR
call made on a directory, the
.Fa va_nlink
field should contain the number of entries in the directory, if possible,
or 1 otherwise.
.Sh RETURN VALUES
The
.Fn VOP_GETATTR
and
.Fn VOP_SETATTR
functions return 0 to indicate success and a non-zero error code
to indicate failure.
See
.Xr errno 2
for more information.
.Sh SEE ALSO
.Xr errno 2 ,
.Xr vfs 9 ,
.Xr vn_stat 9 ,
.Xr vnode 9
.Sh AUTHORS
This man page was written by
.An Pedro Martelletto
for
.Ox .