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.Dd December 13, 2021 30.Dt VOP_READDIR 9 31.Os 32.Sh NAME 33.Nm VOP_READDIR 34.Nd read contents of a directory 35.Sh SYNOPSIS 36.In sys/param.h 37.In sys/dirent.h 38.In sys/vnode.h 39.Ft int 40.Fn VOP_READDIR "struct vnode *vp" "struct uio *uio" "struct ucred *cred" "int *eofflag" "int *ncookies" "uint64_t **cookies" 41.Sh DESCRIPTION 42Read directory entries. 43.Bl -tag -width ncookies 44.It Fa vp 45The vnode of the directory. 46.It Fa uio 47Where to read the directory contents. 48.It Fa cred 49The caller's credentials. 50.It Fa eofflag 51Return end of file status 52.Dv ( NULL 53if not wanted). 54.It Fa ncookies 55Number of directory cookies generated for NFS 56.Dv ( NULL 57if not wanted). 58.It Fa cookies 59Directory seek cookies generated for NFS 60.Dv ( NULL 61if not wanted). 62.El 63The directory contents are read into 64.Vt struct dirent 65structures. 66If the on-disc data structures differ from this then they 67should be translated. 68.Sh LOCKS 69The directory should be locked on entry and will still be locked on exit. 70.Sh RETURN VALUES 71Zero is returned on success, otherwise an error code is returned. 72.Pp 73If this is called from the NFS server, the extra arguments 74.Fa eofflag , 75.Fa ncookies 76and 77.Fa cookies 78are given. 79The value of 80.Fa *eofflag 81should be set to TRUE if the end of the directory is reached while 82reading. 83The directory seek cookies are returned to the NFS client and may be used 84later to restart a directory read part way through the directory. 85There should be one cookie returned per directory entry. 86The value of 87the cookie should be the offset within the directory where the on-disc 88version of the appropriate directory entry starts. 89Memory for the cookies should be allocated using: 90.Bd -literal 91 ...; 92 *ncookies = number of entries read; 93 *cookies = malloc(*ncookies * sizeof(**cookies), M_TEMP, M_WAITOK); 94.Ed 95.Sh ERRORS 96.Bl -tag -width Er 97.It Bq Er EINVAL 98An attempt was made to read from an illegal offset in the directory. 99.It Bq Er EIO 100A read error occurred while reading the directory. 101.It Bq Er EINTEGRITY 102Corrupted data was detected while reading the directory. 103.El 104.Sh SEE ALSO 105.Xr vnode 9 106.Sh AUTHORS 107This manual page was written by 108.An Doug Rabson . 109