1*6cb10275Sriastradh.\" $NetBSD: virtdir.3,v 1.4 2014/03/18 18:20:39 riastradh Exp $ 2777436c8Sagc.\" 3777436c8Sagc.\" Copyright � 2007 Alistair Crooks. All rights reserved. 4777436c8Sagc.\" 5777436c8Sagc.\" Redistribution and use in source and binary forms, with or without 6777436c8Sagc.\" modification, are permitted provided that the following conditions 7777436c8Sagc.\" are met: 8777436c8Sagc.\" 1. Redistributions of source code must retain the above copyright 9777436c8Sagc.\" notice, this list of conditions and the following disclaimer. 10777436c8Sagc.\" 2. Redistributions in binary form must reproduce the above copyright 11777436c8Sagc.\" notice, this list of conditions and the following disclaimer in the 12777436c8Sagc.\" documentation and/or other materials provided with the distribution. 13777436c8Sagc.\" 3. The name of the author may not be used to endorse or promote 14777436c8Sagc.\" products derived from this software without specific prior written 15777436c8Sagc.\" permission. 16777436c8Sagc.\" 17777436c8Sagc.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 18777436c8Sagc.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19777436c8Sagc.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20777436c8Sagc.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 21777436c8Sagc.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22777436c8Sagc.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23777436c8Sagc.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24777436c8Sagc.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25777436c8Sagc.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26777436c8Sagc.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27777436c8Sagc.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28777436c8Sagc.\" 29777436c8Sagc.Dd January 23, 2007 30777436c8Sagc.Dt VIRTDIR 3 31777436c8Sagc.Os 32777436c8Sagc.Sh NAME 33777436c8Sagc.Nm virtdir 34777436c8Sagc.Nd Utility routines for virtual directories for refuse operations 35777436c8Sagc.Sh SYNOPSIS 36777436c8Sagc.In virtdir.h 37777436c8Sagc.Ft int 38777436c8Sagc.Fo virtdir_init 39777436c8Sagc.Fa "virtdir_t *tree" "struct stat *dir" "struct stat *file" "struct stat *symlink" 40777436c8Sagc.Fc 41777436c8Sagc.Ft int 42777436c8Sagc.Fo virtdir_add 43777436c8Sagc.Fa "virtdir_t *tree" "const char *name" "size_t namesize" "uint8_t type" "char *target" 44777436c8Sagc.Fc 45777436c8Sagc.Ft int 46777436c8Sagc.Fo virtdir_del 47777436c8Sagc.Fa "virtdir_t *tree" "const char *name" "size_t namesize" 48777436c8Sagc.Fc 49777436c8Sagc.Ft int 50777436c8Sagc.Fo virtdir_find 51777436c8Sagc.Fa "virtdir_t *tree" "const char *name" "size_t namesize" 52777436c8Sagc.Fc 53777436c8Sagc.Ft int 54777436c8Sagc.Fo virtdir_find_tgt 55777436c8Sagc.Fa "virtdir_t *tree" "const char *name" "size_t namesize" 56777436c8Sagc.Fc 57777436c8Sagc.Ft void 58777436c8Sagc.Fo virtdir_drop 59777436c8Sagc.Fa "virtdir_t *tree" 60777436c8Sagc.Fc 61777436c8Sagc.Ft VIRTDIR * 62777436c8Sagc.Fo openvirtdir 63777436c8Sagc.Fa "virtdir_t *tree" "const char *directory" 64777436c8Sagc.Fc 65777436c8Sagc.Ft virt_dirent_t * 66777436c8Sagc.Fo readvirtdir 67777436c8Sagc.Fa "VIRTDIR *dirp" 68777436c8Sagc.Fc 69777436c8Sagc.Ft void 70777436c8Sagc.Fo closevirtdir 71777436c8Sagc.Fa "VIRTDIR *dirp" 72777436c8Sagc.Fc 73777436c8Sagc.Sh DESCRIPTION 74777436c8Sagc.Nm 75777436c8Sagcprovides virtual directory functionality for the benefit of 760d78c993Swiz.Xr refuse 3 77777436c8Sagcfile systems (and also for FUSE-based file systems). 78777436c8Sagc.Pp 79777436c8SagcIt uses the framework provided by the 80777436c8Sagc.Xr puffs 3 81777436c8Sagcsubsystem, and, through that, the kernel interface provided by 82777436c8Sagc.Xr puffs 4 . 83777436c8Sagc.Pp 84777436c8SagcThe 85777436c8Sagc.Nm 86777436c8Sagcroutines build up and manage a list of virtual directory entries. 87777436c8SagcEach virtual directory entry is indexed by its full pathname within 88777436c8Sagcthe file system. 89777436c8SagcThis is consistent with the way that 900d78c993Swiz.Xr refuse 3 91777436c8Sagclocates directory entries - by full pathname. 92777436c8Sagc.Pp 93777436c8SagcThe list of paths is sorted alphabetically. 94777436c8SagcEach of these virtual directory entries has a distinct type - 950d78c993Swizfile 960d78c993Swiz.Pq Sq f , 970d78c993Swizdirectory 980d78c993Swiz.Pq Sq d , 990d78c993Swizor symbolic link 1000d78c993Swiz.Pq Sq l . 101777436c8SagcAdditionally, an entry can point to a target - this 1020d78c993Swizis useful when modeling virtual directory entries which are 103777436c8Sagcsymbolic links. 104777436c8SagcThe list contains three basic 105777436c8Sagc.Xr stat 2 106777436c8Sagcstructures, which contain basic information for file, directory 1070d78c993Swizand symbolic link entries. 1080d78c993SwizThis information can be specified at 1090d78c993Swizinitialization time, and customized within the individual 110777436c8Sagcgetattr operation routines as specified by the 111777436c8Sagcindividual file systems. 112777436c8SagcThe 113777436c8Sagc.Nm 114777436c8Sagcfunctionality can also make virtual directory entries available 115777436c8Sagcon a per-directory basis 116777436c8Sagcto the caller by means of routines analogous to 117777436c8Sagc.Xr opendir 3 , 1180d78c993Swiz.Xr readdir 3 , 1190d78c993Swizand 120777436c8Sagc.Xr closedir 3 . 121777436c8SagcThese are 1220d78c993Swiz.Fn openvirtdir , 1230d78c993Swiz.Fn readvirtdir , 1240d78c993Swizand 1250d78c993Swiz.Fn closevirtdir , 1260d78c993Swizrespectively. 127777436c8Sagc.Sh SEE ALSO 128777436c8Sagc.Xr puffs 3 , 1290d78c993Swiz.Xr refuse 3 , 130777436c8Sagc.Xr puffs 4 131777436c8Sagc.Sh HISTORY 132777436c8SagcAn unsupported experimental version of 133777436c8Sagc.Nm 134777436c8Sagcfirst appeared in 135777436c8Sagc.Nx 5.0 . 1360d78c993Swiz.Sh AUTHORS 137a5684d07Swiz.An Alistair Crooks Aq Mt agc@NetBSD.org 138