1*0a6a1f1dSLionel Sambuc.\" $NetBSD: puffs_ops.3,v 1.42 2015/02/16 10:48:56 wiz Exp $ 2490e0de5SThomas Veerman.\" 3490e0de5SThomas Veerman.\" Copyright (c) 2007 Antti Kantee. All rights reserved. 4490e0de5SThomas Veerman.\" 5490e0de5SThomas Veerman.\" Redistribution and use in source and binary forms, with or without 6490e0de5SThomas Veerman.\" modification, are permitted provided that the following conditions 7490e0de5SThomas Veerman.\" are met: 8490e0de5SThomas Veerman.\" 1. Redistributions of source code must retain the above copyright 9490e0de5SThomas Veerman.\" notice, this list of conditions and the following disclaimer. 10490e0de5SThomas Veerman.\" 2. Redistributions in binary form must reproduce the above copyright 11490e0de5SThomas Veerman.\" notice, this list of conditions and the following disclaimer in the 12490e0de5SThomas Veerman.\" documentation and/or other materials provided with the distribution. 13490e0de5SThomas Veerman.\" 14490e0de5SThomas Veerman.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15490e0de5SThomas Veerman.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16490e0de5SThomas Veerman.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17490e0de5SThomas Veerman.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18490e0de5SThomas Veerman.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19490e0de5SThomas Veerman.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20490e0de5SThomas Veerman.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21490e0de5SThomas Veerman.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22490e0de5SThomas Veerman.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23490e0de5SThomas Veerman.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24490e0de5SThomas Veerman.\" SUCH DAMAGE. 25490e0de5SThomas Veerman.\" 26*0a6a1f1dSLionel Sambuc.Dd October 31, 2014 27490e0de5SThomas Veerman.Dt PUFFS_OPS 3 28490e0de5SThomas Veerman.Os 29490e0de5SThomas Veerman.Sh NAME 30490e0de5SThomas Veerman.Nm puffs_ops 31490e0de5SThomas Veerman.Nd puffs callback operations 32490e0de5SThomas Veerman.Sh LIBRARY 33490e0de5SThomas Veerman.Lb libpuffs 34490e0de5SThomas Veerman.Sh SYNOPSIS 35490e0de5SThomas Veerman.In puffs.h 36490e0de5SThomas Veerman.Ft int 37490e0de5SThomas Veerman.Fo puffs_fs_statvfs 38490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "struct statvfs *sbp" 39490e0de5SThomas Veerman.Fc 40490e0de5SThomas Veerman.Ft int 41490e0de5SThomas Veerman.Fo puffs_fs_sync 42490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "int waitfor" "const struct puffs_cred *pcr" 43490e0de5SThomas Veerman.Fc 44490e0de5SThomas Veerman.Ft int 45490e0de5SThomas Veerman.Fo puffs_fs_fhtonode 46490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "void *fid" "size_t fidsize" 47490e0de5SThomas Veerman.Fa "struct puffs_newinfo *pni" 48490e0de5SThomas Veerman.Fc 49490e0de5SThomas Veerman.Ft int 50490e0de5SThomas Veerman.Fo puffs_fs_nodetofh 5184d9c625SLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t cookie" "void *fid" 52490e0de5SThomas Veerman.Fa "size_t *fidsize" 53490e0de5SThomas Veerman.Fc 54490e0de5SThomas Veerman.Ft void 5584d9c625SLionel Sambuc.Fo puffs_fs_extattrctl 5684d9c625SLionel Sambuc.Fa "struct puffs_usermount *pu" "int cmd" "puffs_cookie_t cookie" "int flags" 5784d9c625SLionel Sambuc.Fa "int attrnamespace" "const char *attrname" 5884d9c625SLionel Sambuc.Fc 59490e0de5SThomas Veerman.Ft int 60490e0de5SThomas Veerman.Fo puffs_fs_unmount 61490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "int flags" 62490e0de5SThomas Veerman.Fc 63490e0de5SThomas Veerman.Ft int 64490e0de5SThomas Veerman.Fo puffs_node_lookup 65490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 66490e0de5SThomas Veerman.Fa "struct puffs_newinfo *pni" "const struct puffs_cn *pcn" 67490e0de5SThomas Veerman.Fc 68490e0de5SThomas Veerman.Ft int 69490e0de5SThomas Veerman.Fo puffs_node_create 70490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 71490e0de5SThomas Veerman.Fa "struct puffs_newinfo *pni" "const struct puffs_cn *pcn" 72490e0de5SThomas Veerman.Fa "const struct vattr *vap" 73490e0de5SThomas Veerman.Fc 74490e0de5SThomas Veerman.Ft int 75490e0de5SThomas Veerman.Fo puffs_node_mknod 76490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 77490e0de5SThomas Veerman.Fa "struct puffs_newinfo *pni" "const struct puffs_cn *pcn" 78490e0de5SThomas Veerman.Fa "const struct vattr *vap" 79490e0de5SThomas Veerman.Fc 80490e0de5SThomas Veerman.Ft int 81490e0de5SThomas Veerman.Fo puffs_node_open 82490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int mode" 83490e0de5SThomas Veerman.Fa "const struct puffs_cred *pcr" 84490e0de5SThomas Veerman.Fc 85490e0de5SThomas Veerman.Ft int 86*0a6a1f1dSLionel Sambuc.Fo puffs_node_open2 87*0a6a1f1dSLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int modep" 88*0a6a1f1dSLionel Sambuc.Fa "const struct puffs_cred *pcr" "int *oflags" 89*0a6a1f1dSLionel Sambuc.Fc 90*0a6a1f1dSLionel Sambuc.Ft int 91490e0de5SThomas Veerman.Fo puffs_node_close 92490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int flags" 93490e0de5SThomas Veerman.Fa "const struct puffs_cred *pcr" 94490e0de5SThomas Veerman.Fc 95490e0de5SThomas Veerman.Ft int 96490e0de5SThomas Veerman.Fo puffs_node_access 97490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int mode" 98490e0de5SThomas Veerman.Fa "const struct puffs_cred *pcr" 99490e0de5SThomas Veerman.Fc 100490e0de5SThomas Veerman.Ft int 101490e0de5SThomas Veerman.Fo puffs_node_getattr 102490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "struct vattr *vap" 103490e0de5SThomas Veerman.Fa "const struct puffs_cred *pcr" 104490e0de5SThomas Veerman.Fc 105490e0de5SThomas Veerman.Ft int 106490e0de5SThomas Veerman.Fo puffs_node_setattr 107490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "const struct vattr *vap" 108490e0de5SThomas Veerman.Fa "const struct puffs_cred *pcr" 109490e0de5SThomas Veerman.Fc 110490e0de5SThomas Veerman.Ft int 11184d9c625SLionel Sambuc.Fo puffs_node_getattr_ttl 11284d9c625SLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "struct vattr *vap" 11384d9c625SLionel Sambuc.Fa "const struct puffs_cred *pcr" "struct timespec *va_ttl" 11484d9c625SLionel Sambuc.Fc 11584d9c625SLionel Sambuc.Ft int 11684d9c625SLionel Sambuc.Fo puffs_node_setattr_ttl 11784d9c625SLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "const struct vattr *vap" 11884d9c625SLionel Sambuc.Fa "const struct puffs_cred *pcr" "struct timespec *va_ttl" "int xflag" 11984d9c625SLionel Sambuc.Fc 12084d9c625SLionel Sambuc.Ft int 121490e0de5SThomas Veerman.Fo puffs_node_poll 122490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int *events" 123490e0de5SThomas Veerman.Fc 124490e0de5SThomas Veerman.Ft int 125490e0de5SThomas Veerman.Fo puffs_node_mmap 126490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int flags" 127490e0de5SThomas Veerman.Fa "const struct puffs_cred *pcr" 128490e0de5SThomas Veerman.Fc 129490e0de5SThomas Veerman.Ft int 130490e0de5SThomas Veerman.Fo puffs_node_fsync 131490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 132490e0de5SThomas Veerman.Fa "const struct puffs_cred *pcr" "int flags" "off_t offlo" "off_t offhi" 133490e0de5SThomas Veerman.Fc 134490e0de5SThomas Veerman.Ft int 135490e0de5SThomas Veerman.Fo puffs_node_seek 136490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "off_t oldoff" 137490e0de5SThomas Veerman.Fa "off_t newoff" "const struct puffs_cred *pcr" 138490e0de5SThomas Veerman.Fc 139490e0de5SThomas Veerman.Ft int 140490e0de5SThomas Veerman.Fo puffs_node_remove 141490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "puffs_cookie_t targ" 142490e0de5SThomas Veerman.Fa "const struct puffs_cn *pcn" 143490e0de5SThomas Veerman.Fc 144490e0de5SThomas Veerman.Ft int 145490e0de5SThomas Veerman.Fo puffs_node_link 146490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "puffs_cookie_t targ" 147490e0de5SThomas Veerman.Fa "const struct puffs_cn *pcn" 148490e0de5SThomas Veerman.Fc 149490e0de5SThomas Veerman.Ft int 150490e0de5SThomas Veerman.Fo puffs_node_rename 151490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "puffs_cookie_t src" 152490e0de5SThomas Veerman.Fa "const struct puffs_cn *pcn_src" "puffs_cookie_t targ_dir" 153490e0de5SThomas Veerman.Fa "puffs_cookie_t targ" "const struct puffs_cn *pcn_targ" 154490e0de5SThomas Veerman.Fc 155490e0de5SThomas Veerman.Ft int 156490e0de5SThomas Veerman.Fo puffs_node_mkdir 157490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 158490e0de5SThomas Veerman.Fa "struct puffs_newinfo *pni" "const struct puffs_cn *pcn" 159490e0de5SThomas Veerman.Fa "const struct vattr *vap" 160490e0de5SThomas Veerman.Fc 161490e0de5SThomas Veerman.Ft int 162490e0de5SThomas Veerman.Fo puffs_node_rmdir 163490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "puffs_cookie_t targ" 164490e0de5SThomas Veerman.Fa "const struct puffs_cn *pcn" 165490e0de5SThomas Veerman.Fc 166490e0de5SThomas Veerman.Ft int 167490e0de5SThomas Veerman.Fo puffs_node_readdir 168490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "struct dirent *dent" 169490e0de5SThomas Veerman.Fa "off_t *readoff" "size_t *reslen" "const struct puffs_cred *pcr" 170490e0de5SThomas Veerman.Fa "int *eofflag" "off_t *cookies" "size_t *ncookies" 171490e0de5SThomas Veerman.Fc 172490e0de5SThomas Veerman.Ft int 173490e0de5SThomas Veerman.Fo puffs_node_symlink 174490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 175490e0de5SThomas Veerman.Fa "struct puffs_newinfo *pni" 176490e0de5SThomas Veerman.Fa "const struct puffs_cn *pcn_src" "const struct vattr *vap" 177490e0de5SThomas Veerman.Fa "const char *link_target" 178490e0de5SThomas Veerman.Fc 179490e0de5SThomas Veerman.Ft int 180490e0de5SThomas Veerman.Fo puffs_node_readlink 181490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 182490e0de5SThomas Veerman.Fa "const struct puffs_cred *pcr" "char *link" "size_t *linklen" 183490e0de5SThomas Veerman.Fc 184490e0de5SThomas Veerman.Ft int 185490e0de5SThomas Veerman.Fo puffs_node_read 186490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "uint8_t *buf" 187490e0de5SThomas Veerman.Fa "off_t offset" "size_t *resid" "const struct puffs_cred *pcr" "int ioflag" 188490e0de5SThomas Veerman.Fc 189490e0de5SThomas Veerman.Ft int 190490e0de5SThomas Veerman.Fo puffs_node_write 191490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "uint8_t *buf" 192490e0de5SThomas Veerman.Fa "off_t offset" "size_t *resid" "const struct puffs_cred *pcr" "int ioflag" 193490e0de5SThomas Veerman.Fc 194490e0de5SThomas Veerman.Ft int 19584d9c625SLionel Sambuc.Fo puffs_node_write2 19684d9c625SLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "uint8_t *buf" 19784d9c625SLionel Sambuc.Fa "off_t offset" "size_t *resid" "const struct puffs_cred *pcr" "int ioflag" 19884d9c625SLionel Sambuc.Fa "int xflag" 19984d9c625SLionel Sambuc.Fc 20084d9c625SLionel Sambuc.Ft int 20184d9c625SLionel Sambuc.Fo puffs_node_abortop 20284d9c625SLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 20384d9c625SLionel Sambuc.Fa "const struct puffs_cn *pcn" 20484d9c625SLionel Sambuc.Fc 20584d9c625SLionel Sambuc.Ft int 20684d9c625SLionel Sambuc.Fo puffs_node_getextattr 20784d9c625SLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int attrnamespace" 20884d9c625SLionel Sambuc.Fa "const char *attrname" "size_t *attrsize" "uint8_t *attr" "size_t *resid" 20984d9c625SLionel Sambuc.Fa "const struct puffs_cred *pcr" 21084d9c625SLionel Sambuc.Fc 21184d9c625SLionel Sambuc.Ft int 21284d9c625SLionel Sambuc.Fo puffs_node_setextattr 21384d9c625SLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int attrnamespace" 21484d9c625SLionel Sambuc.Fa "const char *attrname" "uint8_t *attr" "size_t *resid" 21584d9c625SLionel Sambuc.Fa "const struct puffs_cred *pcr" 21684d9c625SLionel Sambuc.Fc 21784d9c625SLionel Sambuc.Ft int 21884d9c625SLionel Sambuc.Fo puffs_node_listextattr 21984d9c625SLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int attrnamespace" 22084d9c625SLionel Sambuc.Fa "size_t *attrssize" "uint8_t *attrs" "iint flag" "size_t *resid" 22184d9c625SLionel Sambuc.Fa "const struct puffs_cred *pcr" 22284d9c625SLionel Sambuc.Fc 22384d9c625SLionel Sambuc.Ft int 22484d9c625SLionel Sambuc.Fo puffs_node_deleteextattr 22584d9c625SLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int attrnamespace" 22684d9c625SLionel Sambuc.Fa "const char *attrname" 22784d9c625SLionel Sambuc.Fa "const struct puffs_cred *pcr" 22884d9c625SLionel Sambuc.Fc 22984d9c625SLionel Sambuc.Ft int 230*0a6a1f1dSLionel Sambuc.Fo puffs_node_fallocate 231*0a6a1f1dSLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "off_t pos" "off_t len" 232*0a6a1f1dSLionel Sambuc.Fc 233*0a6a1f1dSLionel Sambuc.Ft int 234*0a6a1f1dSLionel Sambuc.Fo puffs_node_fdiscard 235*0a6a1f1dSLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "off_t pos" "off_t len" 236*0a6a1f1dSLionel Sambuc.Fc 237*0a6a1f1dSLionel Sambuc.Ft int 238*0a6a1f1dSLionel Sambuc.Fo puffs_node_print 239*0a6a1f1dSLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 240*0a6a1f1dSLionel Sambuc.Fc 241490e0de5SThomas Veerman.Ft int 242490e0de5SThomas Veerman.Fo puffs_node_reclaim 243490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 244490e0de5SThomas Veerman.Fc 245490e0de5SThomas Veerman.Ft int 24684d9c625SLionel Sambuc.Fo puffs_node_reclaim2 24784d9c625SLionel Sambuc.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int nlookup" 24884d9c625SLionel Sambuc.Fc 24984d9c625SLionel Sambuc.Ft int 250490e0de5SThomas Veerman.Fo puffs_node_inactive 251490e0de5SThomas Veerman.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 252490e0de5SThomas Veerman.Fc 253490e0de5SThomas Veerman.Ft void 254490e0de5SThomas Veerman.Fn puffs_setback "struct puffs_cc *pcc" "int op" 255490e0de5SThomas Veerman.Ft void 256490e0de5SThomas Veerman.Fn puffs_newinfo_setcookie "struct puffs_newinfo *pni" "puffs_cookie_t cookie" 257490e0de5SThomas Veerman.Ft void 258490e0de5SThomas Veerman.Fn puffs_newinfo_setvtype "struct puffs_newinfo *pni" "enum vtype vtype" 259490e0de5SThomas Veerman.Ft void 260490e0de5SThomas Veerman.Fn puffs_newinfo_setsize "struct puffs_newinfo *pni" "voff_t size" 261490e0de5SThomas Veerman.Ft void 262490e0de5SThomas Veerman.Fn puffs_newinfo_setrdev "struct puffs_newinfo *pni" "dev_t rdev" 26384d9c625SLionel Sambuc.Ft void 26484d9c625SLionel Sambuc.Fn puffs_newinfo_setva "struct puffs_newinfo *pni" "struct vattr *vap" 26584d9c625SLionel Sambuc.Ft void 26684d9c625SLionel Sambuc.Fn puffs_newinfo_setvattl "struct puffs_newinfo *pni" "struct timespec *va_ttl" 26784d9c625SLionel Sambuc.Ft void 26884d9c625SLionel Sambuc.Fn puffs_newinfo_setcnttl "struct puffs_newinfo *pni" "struct timespec *cn_ttl" 269490e0de5SThomas Veerman.Sh DESCRIPTION 270490e0de5SThomas VeermanThe operations 271490e0de5SThomas Veerman.Nm puffs 272490e0de5SThomas Veermanrequires to function can be divided into two categories: file system 273490e0de5SThomas Veermancallbacks and node callbacks. 274490e0de5SThomas VeermanThe former affect the entire file system while the latter are targeted 275490e0de5SThomas Veermanat a file or a directory and a file. 276490e0de5SThomas VeermanThey are roughly equivalent to the vfs and vnode operations in the 277490e0de5SThomas Veermankernel. 278490e0de5SThomas Veerman.Pp 279490e0de5SThomas VeermanAll callbacks can be prototyped with the file system name and operation 280490e0de5SThomas Veermanname using the macro 281490e0de5SThomas Veerman.Fn PUFFSOP_PROTOS fsname . 282490e0de5SThomas Veerman.Ss File system callbacks (puffs_fs) 283490e0de5SThomas Veerman.Bl -tag -width xxxx 284490e0de5SThomas Veerman.It Fn puffs_fs_statvfs "pu" "sbp" 285490e0de5SThomas VeermanThe following fields of the argument 286490e0de5SThomas Veerman.Fa sbp 287490e0de5SThomas Veermanneed to be filled: 288490e0de5SThomas Veerman.Bd -literal 289490e0de5SThomas Veerman * unsigned long f_bsize; file system block size 290490e0de5SThomas Veerman * unsigned long f_frsize; fundamental file system block size 291490e0de5SThomas Veerman * fsblkcnt_t f_blocks; number of blocks in file system, 292490e0de5SThomas Veerman * (in units of f_frsize) 293490e0de5SThomas Veerman * 294490e0de5SThomas Veerman * fsblkcnt_t f_bfree; free blocks avail in file system 295490e0de5SThomas Veerman * fsblkcnt_t f_bavail; free blocks avail to non-root 296490e0de5SThomas Veerman * fsblkcnt_t f_bresvd; blocks reserved for root 297490e0de5SThomas Veerman 298490e0de5SThomas Veerman * fsfilcnt_t f_files; total file nodes in file system 299490e0de5SThomas Veerman * fsfilcnt_t f_ffree; free file nodes in file system 300490e0de5SThomas Veerman * fsfilcnt_t f_favail; free file nodes avail to non-root 301490e0de5SThomas Veerman * fsfilcnt_t f_fresvd; file nodes reserved for root 302490e0de5SThomas Veerman 303490e0de5SThomas Veerman.Ed 304490e0de5SThomas Veerman.It Fn puffs_fs_sync "pu" "waitfor" "pcr" 305490e0de5SThomas VeermanAll the dirty buffers that have been cached at the file server 306490e0de5SThomas Veermanlevel including metadata should be committed to stable storage. 307490e0de5SThomas VeermanThe 308490e0de5SThomas Veerman.Fa waitfor 309490e0de5SThomas Veermanparameter affects the operation. 310490e0de5SThomas VeermanPossible values are: 311490e0de5SThomas Veerman.Bl -tag -width XMNT_NOWAITX 312490e0de5SThomas Veerman.It Dv MNT_WAIT 313490e0de5SThomas VeermanWait for all I/O for complete until returning. 314490e0de5SThomas Veerman.It Dv MNT_NOWAIT 315490e0de5SThomas VeermanInitiate I/O, but do not wait for completion. 316490e0de5SThomas Veerman.It Dv MNT_LAZY 317490e0de5SThomas VeermanSynchorize data not synchoronized by the file system syncer, 31884d9c625SLionel Sambuci.e., data not written when 319490e0de5SThomas Veerman.Fn node_fsync 320490e0de5SThomas Veermanis called with 321490e0de5SThomas Veerman.Dv FSYNC_LAZY . 322490e0de5SThomas Veerman.El 323490e0de5SThomas Veerman.Pp 324490e0de5SThomas VeermanThe credentials for the initiator of the sync operation are present in 325490e0de5SThomas Veerman.Fa pcr 326490e0de5SThomas Veermanand will usually be either file system or kernel credentials, but might 327490e0de5SThomas Veermanalso be user credentials. 328490e0de5SThomas VeermanHowever, most of the time it is advisable to sync regardless of the 329490e0de5SThomas Veermancredentials of the caller. 330490e0de5SThomas Veerman.It Fn puffs_fs_fhtonode "pu" "fid" "fidsize" "pni" 331490e0de5SThomas VeermanTranslates a file handle 332490e0de5SThomas Veerman.Fa fid 333490e0de5SThomas Veermanto a node. 334490e0de5SThomas VeermanThe parameter 335490e0de5SThomas Veerman.Fa fidsize 336490e0de5SThomas Veermanindicates how large the file handle is. 337490e0de5SThomas VeermanIn case the file system's handles are static length, this parameter can 338490e0de5SThomas Veermanbe ignored as the kernel guarantees all file handles passed to the file 339490e0de5SThomas Veermanserver are of correct length. 340490e0de5SThomas VeermanFor dynamic length handles the field should be examined and 341490e0de5SThomas Veerman.Er EINVAL 342490e0de5SThomas Veermanreturned in case the file handle length is not correct. 343490e0de5SThomas Veerman.Pp 344490e0de5SThomas VeermanThis function provides essentially the same information to the kernel as 345490e0de5SThomas Veerman.Fn puffs_node_lookup . 346490e0de5SThomas VeermanThe information is necessary for creating a new vnode corresponding to 347490e0de5SThomas Veermanthe file handle. 348490e0de5SThomas Veerman.It Fn puffs_fs_nodetofh "pu" "cookie" "fid" "fidsize" 349490e0de5SThomas VeermanCreate a file handle from the node described by 350490e0de5SThomas Veerman.Fa cookie . 351490e0de5SThomas VeermanThe file handle should contain enough information to reliably identify 352490e0de5SThomas Veermanthe node even after reboots and the pathname/inode being replaced by 353490e0de5SThomas Veermananother file. 354490e0de5SThomas VeermanIf this is not possible, it is up to the author of the file system to 355490e0de5SThomas Veermanact responsibly and decide if the file system can support file handles 356490e0de5SThomas Veermanat all. 357490e0de5SThomas Veerman.Pp 358490e0de5SThomas VeermanFor file systems which want dynamic length file handles, this function 359490e0de5SThomas Veermanmust check if the file handle space indicated by 360490e0de5SThomas Veerman.Fa fidsize 361490e0de5SThomas Veermanis large enough to accommodate the file handle for the node. 362490e0de5SThomas VeermanIf not, it must fill in the correct size and return 363490e0de5SThomas Veerman.Er E2BIG . 364490e0de5SThomas VeermanIn either case, the handle length should be supplied to the kernel in 365490e0de5SThomas Veerman.Fa fidsize . 366490e0de5SThomas VeermanFile systems with static length handles can ignore the size parameter as 367490e0de5SThomas Veermanthe kernel always supplies the correct size buffer. 368490e0de5SThomas Veerman.It Fn puffs_fs_unmount "pu" "flags" 369490e0de5SThomas VeermanUnmount the file system. 370490e0de5SThomas VeermanThe kernel has assumedly flushed all cached data when this callback 371490e0de5SThomas Veermanis executed. 372490e0de5SThomas VeermanIf the file system cannot currently be safely be unmounted, for whatever 373490e0de5SThomas Veermanreason, the kernel will honor an error value and not forcibly unmount. 374490e0de5SThomas VeermanHowever, if the flag 375490e0de5SThomas Veerman.Dv MNT_FORCE 376490e0de5SThomas Veermanis not honored by the file server, the kernel will forcibly unmount 377490e0de5SThomas Veermanthe file system. 378490e0de5SThomas Veerman.El 379490e0de5SThomas Veerman.Ss Node callbacks 380490e0de5SThomas VeermanThese operations operate in the level of individual files. 381490e0de5SThomas VeermanThe file cookie is always provided as the second argument 382490e0de5SThomas Veerman.Fa opc . 383490e0de5SThomas VeermanIf the operation is for a file, it will be the cookie of the file. 384490e0de5SThomas VeermanThe case the operation involves a directory (such as 385490e0de5SThomas Veerman.Dq create file in directory ) , 386490e0de5SThomas Veermanthe cookie will be for the directory. 387490e0de5SThomas VeermanSome operations take additional cookies to describe the rest of 388490e0de5SThomas Veermanthe operands. 389490e0de5SThomas VeermanThe return value 0 signals success, else an appropriate errno value 390490e0de5SThomas Veermanshould be returned. 391490e0de5SThomas VeermanPlease note that neither this list nor the descriptions are complete. 392490e0de5SThomas Veerman.Bl -tag -width xxxx 393490e0de5SThomas Veerman.It Fn puffs_node_lookup "pu" "opc" "pni" "pcn" 394490e0de5SThomas VeermanThis function is used to locate nodes, or in other words translate 395490e0de5SThomas Veermanpathname components to file system data structures. 396490e0de5SThomas VeermanThe implementation should match the name in 397490e0de5SThomas Veerman.Fa pcn 398490e0de5SThomas Veermanagainst the existing entries in the directory provided by the cookie 399490e0de5SThomas Veerman.Fa opc . 400490e0de5SThomas VeermanIf found, the cookie for the located node should be set in 401490e0de5SThomas Veerman.Fa pni 402490e0de5SThomas Veermanusing 403490e0de5SThomas Veerman.Fn puffs_newinfo_setcookie . 404490e0de5SThomas VeermanAdditionally, the vnode type and size (latter applicable to regular files only) 405490e0de5SThomas Veermanshould be set using 406490e0de5SThomas Veerman.Fn puffs_newinfo_setvtype 407490e0de5SThomas Veermanand 408490e0de5SThomas Veerman.Fn puffs_newinfo_setsize , 409490e0de5SThomas Veermanrespectively. 410490e0de5SThomas VeermanIf the located entry is a block device or character device file, 411490e0de5SThomas Veermanthe dev_t for the entry should be set using 412490e0de5SThomas Veerman.Fn puffs_newinfo_setrdev . 413490e0de5SThomas Veerman.Pp 41484d9c625SLionel SambucIf 41584d9c625SLionel Sambuc.Fn puffs_init 41684d9c625SLionel Sambucwas called with 41784d9c625SLionel Sambuc.Dv PUFFS_KFLAG_CACHE_FS_TTL 41884d9c625SLionel Sambucthen 41984d9c625SLionel Sambuc.Fn puffs_newinfo_setva , 42084d9c625SLionel Sambuc.Fn puffs_newinfo_setvattl , 42184d9c625SLionel Sambucand 42284d9c625SLionel Sambuc.Fn puffs_newinfo_setcnttl 42384d9c625SLionel Sambuccan be called to specify the new node attributes, cached attributes 42484d9c625SLionel Sambuctime to live, and cached name time to live. 42584d9c625SLionel Sambuc.Pp 426490e0de5SThomas VeermanThe type of operation is found from 427490e0de5SThomas Veerman.Va pcn-\*[Gt]pcn_nameiop : 42884d9c625SLionel Sambuc.Bl -tag -width XNAMEI_LOOKUPX 42984d9c625SLionel Sambuc.It Dv NAMEI_LOOKUP 430490e0de5SThomas VeermanNormal lookup operation. 43184d9c625SLionel Sambuc.It Dv NAMEI_CREATE 432490e0de5SThomas VeermanLookup to create a node. 43384d9c625SLionel Sambuc.It Dv NAMEI_DELETE 434490e0de5SThomas VeermanLookup for node deletion. 43584d9c625SLionel Sambuc.It Dv NAMEI_RENAME 436490e0de5SThomas VeermanLookup for the target of a rename operation (source will be looked 437490e0de5SThomas Veermanup using 43884d9c625SLionel Sambuc.Dv NAMEI_DELETE ) . 439490e0de5SThomas Veerman.El 440490e0de5SThomas Veerman.Pp 441490e0de5SThomas VeermanThe final component from a pathname lookup usually requires special 442490e0de5SThomas Veermantreatment. 443490e0de5SThomas VeermanIt can be identified by looking at the 444490e0de5SThomas Veerman.Va pcn-\*[Gt]pcn_flags 445490e0de5SThomas Veermanfields for the flag 446490e0de5SThomas Veerman.Dv PUFFSLOOKUP_ISLASTCN . 447490e0de5SThomas VeermanFor example, in most cases the lookup operation will want to check if 448490e0de5SThomas Veermana delete, rename or create operation has enough credentials to perform 449490e0de5SThomas Veermanthe operation. 450490e0de5SThomas Veerman.Pp 451490e0de5SThomas VeermanThe return value 0 signals a found node and a nonzero value signals 452490e0de5SThomas Veermanan errno. 453490e0de5SThomas VeermanAs a special case, 454490e0de5SThomas Veerman.Er ENOENT 455490e0de5SThomas Veermansignals "success" for cases where the lookup operation is 45684d9c625SLionel Sambuc.Dv NAMEI_CREATE 457490e0de5SThomas Veermanor 45884d9c625SLionel Sambuc.Dv NAMEI_RENAME . 459490e0de5SThomas VeermanFailure in these cases can be signalled by returning another appropriate 460490e0de5SThomas Veermanerror code, for example 461490e0de5SThomas Veerman.Er EACCESS . 462490e0de5SThomas Veerman.Pp 463490e0de5SThomas VeermanUsually a null-terminated string for the next pathname component is 464490e0de5SThomas Veermanprovided in 465490e0de5SThomas Veerman.Ar pcn-\*[Gt]pcn_name . 466490e0de5SThomas VeermanIn case the file system is using the option 467490e0de5SThomas Veerman.Dv PUFFS_KFLAG_LOOKUP_FULLPNBUF , 468490e0de5SThomas Veermanthe remainder of the complete pathname under lookup is found in 469490e0de5SThomas Veermanthe same location. 470490e0de5SThomas Veerman.Ar pcn-\*[Gt]pcn_namelen 471490e0de5SThomas Veermanalways specifies the length of the next component. 472490e0de5SThomas VeermanIf operating with a full path, the file system is allowed to consume 473490e0de5SThomas Veermanmore than the next component's length in node lookup. 474490e0de5SThomas VeermanThis is done by setting 475490e0de5SThomas Veerman.Ar pcn-\*[Gt]pcn_consume 476490e0de5SThomas Veermanto indicate the amount of 477490e0de5SThomas Veerman.Em extra 478490e0de5SThomas Veermancharacters in addition to 479490e0de5SThomas Veerman.Ar pcn-\*[Gt]pcn_namelen 480490e0de5SThomas Veermanprocessed. 481490e0de5SThomas Veerman.It Fn puffs_node_create "pu" "opc" "pni" "pcn" "va" 482490e0de5SThomas Veerman.It Fn puffs_node_mkdir "pu" "opc" "pni" "pcn" "va" 483490e0de5SThomas Veerman.It Fn puffs_node_mknod "pu" "opc" "pni" "pcn" "va" 484490e0de5SThomas VeermanA file node is created in the directory denoted by the cookie 485490e0de5SThomas Veerman.Fa opc 486490e0de5SThomas Veermanby any of the above callbacks. 487490e0de5SThomas VeermanThe name of the new file can be found from 488490e0de5SThomas Veerman.Fa pcn 489490e0de5SThomas Veermanand the attributes are specified by 490490e0de5SThomas Veerman.Fa va 491490e0de5SThomas Veermanand the cookie for the newly created node should be set in 492490e0de5SThomas Veerman.Fa pni . 493490e0de5SThomas VeermanThe only difference between these three is that they create a regular 494490e0de5SThomas Veermanfile, directory and device special file, respectively. 495490e0de5SThomas Veerman.Pp 496490e0de5SThomas VeermanIn case of mknod, the device identifier can be found in 497490e0de5SThomas Veerman.Fa va-\*[Gt]va_rdev . 498490e0de5SThomas Veerman.It Fn puffs_node_open "pu" "opc" "mode" "pcr" 499*0a6a1f1dSLionel Sambuc.It Fn puffs_node_open2 "pu" "opc" "mode" "pcr" "oflags" 500490e0de5SThomas VeermanOpen the node denoted by the cookie 501490e0de5SThomas Veerman.Fa opc . 502490e0de5SThomas VeermanThe parameter 503490e0de5SThomas Veerman.Fa mode 504490e0de5SThomas Veermanspecifies the flags that 505490e0de5SThomas Veerman.Xr open 2 506490e0de5SThomas Veermanwas called with, e.g. 507490e0de5SThomas Veerman.Dv O_APPEND 508490e0de5SThomas Veermanand 509490e0de5SThomas Veerman.Dv O_NONBLOCK . 510*0a6a1f1dSLionel Sambuc.Fn puffs_node_open2 511*0a6a1f1dSLionel Sambucallows the file system to pass back information for the file in 512*0a6a1f1dSLionel Sambuc.Fa oflags . 513*0a6a1f1dSLionel SambucThe only implemented flag for now is 514*0a6a1f1dSLionel Sambuc.Dv PUFFS_OPEN_IO_DIRECT 515*0a6a1f1dSLionel Sambucthat cause file read/write to bypass the page cache. 516490e0de5SThomas Veerman.It Fn puffs_node_close "pu" "opc" "flags" "pcr" 517490e0de5SThomas VeermanClose a node. 518490e0de5SThomas VeermanThe parameter 519490e0de5SThomas Veerman.Fa flags 520490e0de5SThomas Veermanparameter describes the flags that the file was opened with. 521490e0de5SThomas Veerman.It Fn puffs_node_access "pu" "opc" "mode" "pcr" 522490e0de5SThomas VeermanCheck if the credentials of 523490e0de5SThomas Veerman.Fa pcr 524490e0de5SThomas Veermanhave the right to perform the operation specified by 525490e0de5SThomas Veerman.Fa mode 526490e0de5SThomas Veermanonto the node 527490e0de5SThomas Veerman.Fa opc . 528490e0de5SThomas VeermanThe argument 529490e0de5SThomas Veerman.Fa mode 530490e0de5SThomas Veermancan specify read, write or execute by 531490e0de5SThomas Veerman.Dv PUFFS_VREAD , 532490e0de5SThomas Veerman.Dv PUFFS_VWRITE , 533490e0de5SThomas Veermanand 534490e0de5SThomas Veerman.Dv PUFFS_VEXEC , 535490e0de5SThomas Veermanrespectively. 536490e0de5SThomas Veerman.It Fn puffs_node_getattr "pu" "opc" "va" "pcr" 537490e0de5SThomas VeermanThe attributes of the node specified by 538490e0de5SThomas Veerman.Fa opc 539490e0de5SThomas Veermanmust be copied to the space pointed by 540490e0de5SThomas Veerman.Fa va . 54184d9c625SLionel Sambuc.It Fn puffs_node_getattr_ttl "pu" "opc" "va" "pcr" "va_ttl" 54284d9c625SLionel SambucSame as 54384d9c625SLionel Sambuc.Fn puffs_node_getattr 54484d9c625SLionel Sambucwith cached attribute time to live specified in 54584d9c625SLionel Sambuc.Fa va_ttl 546490e0de5SThomas Veerman.It Fn puffs_node_setattr "pu" "opc" "va" "pcr" 547490e0de5SThomas VeermanThe attributes for the node specified by 548490e0de5SThomas Veerman.Fa opc 549490e0de5SThomas Veermanmust be set to those contained in 550490e0de5SThomas Veerman.Fa va . 551490e0de5SThomas VeermanOnly fields of 552490e0de5SThomas Veerman.Fa va 553490e0de5SThomas Veermanwhich contain a value different from 554490e0de5SThomas Veerman.Dv PUFFS_VNOVAL 555490e0de5SThomas Veerman(typecast to the field's type!) contain a valid value. 55684d9c625SLionel Sambuc.It Fn puffs_node_setattr_ttl "pu" "opc" "va" "pcr" "va_ttl" "xflag" 55784d9c625SLionel SambucSame as 55884d9c625SLionel Sambuc.Fn puffs_node_setattr 55984d9c625SLionel Sambucwith cached attribute time to live specified in 56084d9c625SLionel Sambuc.Fa va_ttl . 56184d9c625SLionel Sambuc.Dv PUFFS_SETATTR_FAF 56284d9c625SLionel Sambucwill be set in 56384d9c625SLionel Sambuc.Fa xflag 56484d9c625SLionel Sambucfor Fire-And-Forget operations. 565490e0de5SThomas Veerman.It Fn puffs_node_poll "pu" "opc" "events" 566490e0de5SThomas VeermanPoll for events on node 567490e0de5SThomas Veerman.Ar opc . 568490e0de5SThomas VeermanIf 569490e0de5SThomas Veerman.Xr poll 2 570490e0de5SThomas Veermanevents specified in 571490e0de5SThomas Veerman.Ar events 572490e0de5SThomas Veermanare available, the function should set the bitmask to match available 573490e0de5SThomas Veermanevents and return immediately. 574490e0de5SThomas VeermanOtherwise, the function should block (yield) until some events in 575490e0de5SThomas Veerman.Ar events 576490e0de5SThomas Veermanbecome available and only then set the 577490e0de5SThomas Veerman.Ar events 578490e0de5SThomas Veermanbitmask and return. 579490e0de5SThomas Veerman.Pp 580490e0de5SThomas VeermanIn case this function returns an error, 581490e0de5SThomas Veerman.Dv POLLERR 582*0a6a1f1dSLionel Sambuc(or its 583490e0de5SThomas Veerman.Xr select 2 584490e0de5SThomas Veermanequivalent) will be delivered to the calling process. 585490e0de5SThomas Veerman.Pp 586490e0de5SThomas Veerman.Em NOTE! 587490e0de5SThomas VeermanThe system call interface for 588490e0de5SThomas Veerman.Fn poll 589490e0de5SThomas Veermancontains a timeout parameter. 590490e0de5SThomas VeermanAt this level, however, the timeout is not supplied. 591490e0de5SThomas VeermanIn case input does not arrive, the file system should periodically 592490e0de5SThomas Veermanunblock and return 0 new events to avoid hanging forever. 593490e0de5SThomas VeermanThis will hopefully be better supported by libpuffs in the future. 594490e0de5SThomas Veerman.It Fn puffs_node_mmap "pu" "opc" "flags" "pcr" 595490e0de5SThomas VeermanCalled when a regular file is being memory mapped by 596490e0de5SThomas Veerman.Xr mmap 2 . 597490e0de5SThomas Veerman.Fa flags 598490e0de5SThomas Veermanis currently always 0. 599490e0de5SThomas Veerman.It Fn puffs_node_fsync "pu" "opc" "pcr" "flags" "offlo" "offhi" 600490e0de5SThomas VeermanSychronize a node's contents onto stable storage. 601490e0de5SThomas VeermanThis is necessary only if the file server caches some information 602490e0de5SThomas Veermanbefore committing it. 603490e0de5SThomas VeermanThe parameter 604490e0de5SThomas Veerman.Fa flags 605490e0de5SThomas Veermanspecifies the minimum level of sychronization required (XXX: they are 606490e0de5SThomas Veermannot yet available). 607490e0de5SThomas VeermanThe parameters 608490e0de5SThomas Veerman.Fa offlo 609490e0de5SThomas Veermanand 610490e0de5SThomas Veerman.Fa offhi 611490e0de5SThomas Veermanspecify the data offsets requiring to be synced. 612490e0de5SThomas VeermanA high offset of 0 means sync from 613490e0de5SThomas Veerman.Fa offlo 614490e0de5SThomas Veermanto the end of the file. 615490e0de5SThomas Veerman.It Fn puffs_node_seek "pu" "opc" "oldoff" "newoff" "pcr" 616490e0de5SThomas VeermanTest if the node 617490e0de5SThomas Veerman.Ar opc 618490e0de5SThomas Veermanis seekable to the location 619490e0de5SThomas Veerman.Ar newoff . 620490e0de5SThomas VeermanThe argument 621490e0de5SThomas Veerman.Ar oldoff 622490e0de5SThomas Veermanspecifies the offset we are starting the seek from. 623490e0de5SThomas VeermanMost file systems dealing only with regular will choose to not 624490e0de5SThomas Veermanimplement this. 625490e0de5SThomas VeermanHowever, it is useful for example in cases where files are 626490e0de5SThomas Veermanunseekable streams. 627490e0de5SThomas Veerman.It Fn puffs_node_remove "pu" "opc" "targ" "pcn" 628490e0de5SThomas Veerman.It Fn puffs_node_rmdir "pu" "opc" "targ" "pcn" 629490e0de5SThomas VeermanRemove the node 630490e0de5SThomas Veerman.Fa targ 631490e0de5SThomas Veermanfrom the directory indicated by 632490e0de5SThomas Veerman.Fa opc . 633490e0de5SThomas VeermanThe directory entry name to be removed is provided by 634490e0de5SThomas Veerman.Fa pcn . 635490e0de5SThomas VeermanThe rmdir operation removes only directories, while the remove 636490e0de5SThomas Veermanoperation removes all other types except directories. 637490e0de5SThomas Veerman.Pp 638490e0de5SThomas VeermanIt is paramount to note that the file system may not remove the 639490e0de5SThomas Veermannode data structures at this point, only the directory entry and prevent 640490e0de5SThomas Veermanlookups from finding the node again. 641490e0de5SThomas VeermanThis is to retain the 642490e0de5SThomas Veerman.Ux 643490e0de5SThomas Veermanopen file semantics. 644490e0de5SThomas VeermanThe data may be removed only when 645490e0de5SThomas Veerman.Fn puffs_node_reclaim 64684d9c625SLionel Sambucor 64784d9c625SLionel Sambuc.Fn puffs_node_reclaim2 648490e0de5SThomas Veermanis called for the node, as this assures there are no further users. 649490e0de5SThomas Veerman.It Fn puffs_node_link "pu" "opc" "targ" "pcn" 650490e0de5SThomas VeermanCreate a hard link for the node 651490e0de5SThomas Veerman.Fa targ 652490e0de5SThomas Veermaninto the directory 653490e0de5SThomas Veerman.Fa opc . 654490e0de5SThomas VeermanThe argument 655490e0de5SThomas Veerman.Fa pcn 656490e0de5SThomas Veermanprovides the directory entry name for the new link. 657490e0de5SThomas Veerman.It Fn puffs_node_rename "pu" "src_dir" "src" "pcn_src" "targ_dir" "targ" "pcn_targ" 658490e0de5SThomas VeermanRename the node 659490e0de5SThomas Veerman.Fa src 660490e0de5SThomas Veermanwith the name specified by 661490e0de5SThomas Veerman.Fa pcn_src 662490e0de5SThomas Veermanfrom the directory 663490e0de5SThomas Veerman.Fa src_dir . 664490e0de5SThomas VeermanThe target directory and target name are given by 665490e0de5SThomas Veerman.Fa targ_dir 666490e0de5SThomas Veermanand 667490e0de5SThomas Veerman.Fa pcn_targ , 668490e0de5SThomas Veermanrespectively. 669490e0de5SThomas Veerman.Em If 670490e0de5SThomas Veermanthe target node already exists, it is specified by 671490e0de5SThomas Veerman.Fa targ 672490e0de5SThomas Veermanand must be replaced atomically. 673490e0de5SThomas VeermanOtherwise 674490e0de5SThomas Veerman.Fa targ 675490e0de5SThomas Veermanis gives as 676490e0de5SThomas Veerman.Dv NULL . 677490e0de5SThomas Veerman.Pp 678490e0de5SThomas VeermanIt is legal to replace a directory node by another directory node with 679490e0de5SThomas Veermanthe means of rename if the target directory is empty, otherwise 680490e0de5SThomas Veerman.Er ENOTEMPTY 681490e0de5SThomas Veermanshould be returned. 682490e0de5SThomas VeermanAll other types can replace all other types. 683490e0de5SThomas VeermanIn case a rename between incompatible types is attempted, the errors 684490e0de5SThomas Veerman.Er ENOTDIR 685490e0de5SThomas Veermanor 686490e0de5SThomas Veerman.Er EISDIR 687490e0de5SThomas Veermanshould be returned, depending on the target type. 688490e0de5SThomas Veerman.It Fn puffs_node_readdir "pu" "opc" "dent" "readoff" "reslen" "pcr" "eofflag" "cookies" "ncookies" 689490e0de5SThomas VeermanTo read directory entries, 690490e0de5SThomas Veerman.Fn puffs_node_readdir 691490e0de5SThomas Veermanis called. 692490e0de5SThomas VeermanIt should store directories as 693490e0de5SThomas Veerman.Va struct dirent 694490e0de5SThomas Veermanin the space pointed to by 695490e0de5SThomas Veerman.Fa dent . 696490e0de5SThomas VeermanThe amount of space available is given by 697490e0de5SThomas Veerman.Fa reslen 698490e0de5SThomas Veermanand before returning it should be set to the amount of space 699490e0de5SThomas Veerman.Em remaining 700490e0de5SThomas Veermanin the buffer. 701490e0de5SThomas VeermanThe argument 702490e0de5SThomas Veerman.Fa offset 703490e0de5SThomas Veermanis used to specify the offset to the directory. 704490e0de5SThomas VeermanIts intepretation is up to the file system and it should be set to 705490e0de5SThomas Veermansignal the continuation point when there is no more room for the next 706490e0de5SThomas Veermanentry in 707490e0de5SThomas Veerman.Fa dent . 708490e0de5SThomas VeermanIt is most performant to return the maximal amount of directory 709490e0de5SThomas Veermanentries each call. 710490e0de5SThomas VeermanIt is easiest to generate directory entries by using 711490e0de5SThomas Veerman.Fn puffs_nextdent , 712490e0de5SThomas Veermanwhich also automatically advances the necessary pointers. 713490e0de5SThomas Veerman.Pp 714490e0de5SThomas VeermanIn case end-of-directory is reached, 715490e0de5SThomas Veerman.Fa eofflag 716490e0de5SThomas Veermanshould be set to one. 717490e0de5SThomas VeermanNote that even a new call to readdir may start where 718490e0de5SThomas Veerman.Fa readoff 719490e0de5SThomas Veermanpoints to end-of-directory. 720490e0de5SThomas Veerman.Pp 721490e0de5SThomas VeermanIf the file system supports file handles, the arguments 722490e0de5SThomas Veerman.Fa cookies 723490e0de5SThomas Veermanand 724490e0de5SThomas Veerman.Fa ncookies 725490e0de5SThomas Veermanmust be filled out. 726490e0de5SThomas Veerman.Fa cookies 727490e0de5SThomas Veermanis a vector for offsets corresponding to read offsets. 728490e0de5SThomas VeermanOne cookie should be filled out for each directory entry. 729490e0de5SThomas VeermanThe value of the cookie should equal the offset of the 730490e0de5SThomas Veerman.Em next 73184d9c625SLionel Sambucdirectory entry, i.e., which offset should be passed to readdir for 732490e0de5SThomas Veermanthe first entry read to be the entry following the current one. 733490e0de5SThomas Veerman.Fa ncookies 734490e0de5SThomas Veermanis the number of slots for cookies in the cookie vector upon entry to 735490e0de5SThomas Veermanthe function and must be set to the amount of cookies stored in the 73684d9c625SLionel Sambucvector (i.e., amount of directory entries read) upon exit. 737490e0de5SThomas VeermanThere is always enough space in the cookie vector for the maximal number 738490e0de5SThomas Veermanof entries that will fit into the directory entry buffer. 739490e0de5SThomas VeermanFor filling out the vector, the helper function 740490e0de5SThomas Veerman.Fn PUFFS_STORE_DCOOKIE cookies ncookies offset 741490e0de5SThomas Veermancan be used. 742490e0de5SThomas VeermanThis properly checks against 743490e0de5SThomas Veerman.Fa cookies 744490e0de5SThomas Veermanbeing 745490e0de5SThomas Veerman.Dv NULL . 746490e0de5SThomas VeermanNote that 747490e0de5SThomas Veerman.Fa ncookies 748490e0de5SThomas Veermanmust be initialized to zero before the first call to 749490e0de5SThomas Veerman.Fn PUFFS_STORE_DCOOKIE . 750490e0de5SThomas Veerman.It Fn puffs_node_symlink "pu" "opc" "pni" "pcn_src" "va" "link_target" 751490e0de5SThomas VeermanCreate a symbolic link into the directory 752490e0de5SThomas Veerman.Fa opc 753490e0de5SThomas Veermanwith the name in 754490e0de5SThomas Veerman.Fa pcn_src 755490e0de5SThomas Veermanand the initial attributes in 756490e0de5SThomas Veerman.Fa va . 757490e0de5SThomas VeermanThe argument 758490e0de5SThomas Veerman.Ar link_target 759490e0de5SThomas Veermancontains a null-terminated string for the link target. 760490e0de5SThomas VeermanThe created node cookie should be set in 761490e0de5SThomas Veerman.Fa pni . 762490e0de5SThomas Veerman.It Fn puffs_node_readlink "pu" "opc" "pcr" "link" "linklen" 763490e0de5SThomas VeermanRead the target of a symbolic link 764490e0de5SThomas Veerman.Fa opc . 765490e0de5SThomas VeermanThe result is placed in the buffer pointed to by 766490e0de5SThomas Veerman.Fa link . 767490e0de5SThomas VeermanThis buffer's length is given in 768490e0de5SThomas Veerman.Fa linklen 769490e0de5SThomas Veermanand it must be updated to reflect the real link length. 770490e0de5SThomas VeermanA terminating nul character should not be put into the buffer and 771490e0de5SThomas Veerman.Em "must not" 772490e0de5SThomas Veermanbe included in the link length. 773490e0de5SThomas Veerman.It Fn puffs_node_read "pu" "opc" "buf" "offset" "resid" "pcr" "ioflag" 774490e0de5SThomas VeermanRead the contents of a file 775490e0de5SThomas Veerman.Fa opc . 776490e0de5SThomas VeermanIt will gather the data from 777490e0de5SThomas Veerman.Fa offset 778490e0de5SThomas Veermanin the file and read the number 779490e0de5SThomas Veerman.Fa resid 780490e0de5SThomas Veermanoctets. 781490e0de5SThomas VeermanThe buffer is guaranteed to have this much space. 782490e0de5SThomas VeermanThe amount of data requested by 783490e0de5SThomas Veerman.Fa resid 784490e0de5SThomas Veermanshould be read, except in the case of eof-of-file or an error. 785490e0de5SThomas VeermanThe parameter 786490e0de5SThomas Veerman.Fa resid 787490e0de5SThomas Veermanshould be set to indicate the amount of request NOT completed. 788490e0de5SThomas VeermanIn the normal case this should be 0. 789490e0de5SThomas Veerman.It Fn puffs_node_write "pu" "opc" "buf" "offset" "resid" "pcr" "ioflag" 79084d9c625SLionel Sambuc.It Fn puffs_node_write2 "pu" "opc" "buf" "offset" "resid" "pcr" "ioflag" \ 79184d9c625SLionel Sambuc"xflag" 792490e0de5SThomas Veerman.Fn puffs_node_write 79384d9c625SLionel Sambucwrites data to a file 794490e0de5SThomas Veerman.Fa opc 795490e0de5SThomas Veermanat 796490e0de5SThomas Veerman.Fa offset 797490e0de5SThomas Veermanand extend the file if necessary. 798490e0de5SThomas VeermanThe number of octets written is indicated by 799490e0de5SThomas Veerman.Fa resid ; 800490e0de5SThomas Veermaneverything must be written or an error will be generated. 801490e0de5SThomas VeermanThe parameter must be set to indicate the amount of data NOT written. 80284d9c625SLionel SambucIn case the ioflag 803490e0de5SThomas Veerman.Dv PUFFS_IO_APPEND 804490e0de5SThomas Veermanis specified, the data should be appended to the end of the file. 80584d9c625SLionel Sambuc.Fn puffs_node_write2 80684d9c625SLionel Sambucserves the same purpose as 80784d9c625SLionel Sambuc.Fn puffs_node_write 80884d9c625SLionel Sambucwith an additional 80984d9c625SLionel Sambuc.Fa xflag 81084d9c625SLionel Sambucin which 81184d9c625SLionel Sambuc.Dv PUFFS_WRITE_FAF 81284d9c625SLionel Sambucis set for Fire-And-Forget operations. 813*0a6a1f1dSLionel Sambuc.It Fn puffs_node_fallocate "pu" "opc" "pos" "len" 814*0a6a1f1dSLionel SambucAllocate 815*0a6a1f1dSLionel Sambuc.Fa len 816*0a6a1f1dSLionel Sambucbytes of backing store at offset 817*0a6a1f1dSLionel Sambuc.Fa pos 818*0a6a1f1dSLionel Sambucfor the node referenced by the cookie 819*0a6a1f1dSLionel Sambuc.Fa opc . 820*0a6a1f1dSLionel Sambuc.It Fn puffs_node_fdiscard "pu" "opc" "pos" "len" 821*0a6a1f1dSLionel SambucFree 822*0a6a1f1dSLionel Sambuc.Fa len 823*0a6a1f1dSLionel Sambucbytes of backing store (creating a hole) at offset 824*0a6a1f1dSLionel Sambuc.Fa pos 825*0a6a1f1dSLionel Sambucfor the node referenced by the cookie 826*0a6a1f1dSLionel Sambuc.Fa opc . 827490e0de5SThomas Veerman.It Fn puffs_node_print "pu" "opc" 82884d9c625SLionel SambucPrint information about node. 82984d9c625SLionel SambucThis is used only for kernel-initiated diagnostic purposes. 830490e0de5SThomas Veerman.It Fn puffs_node_reclaim "pu" "opc" 831490e0de5SThomas VeermanThe kernel will no longer reference the cookie and resources associated 832490e0de5SThomas Veermanwith it may be freed. 833490e0de5SThomas VeermanIn case the file 834490e0de5SThomas Veerman.Fa opc 835490e0de5SThomas Veermanhas a link count of zero, it may be safely removed now. 83684d9c625SLionel Sambuc.It Fn puffs_node_reclaim2 "pu" "opc" "nlookup" 83784d9c625SLionel SambucSame as 83884d9c625SLionel Sambuc.Fn puffs_node_reclaim 83984d9c625SLionel Sambucwith an addditional argument for the number of lookups that have been done 84084d9c625SLionel Sambucon the node (Node creation is counted as a lookup). This can be used by the 84184d9c625SLionel Sambucfile system to avoid a race condition, where the kernel sends a reclaim 84284d9c625SLionel Sambucwhile it does not have received the reply for a lookup. 84384d9c625SLionel SambucIf the file system tracks lookup count, and compares to 84484d9c625SLionel Sambuc.Fa nlookup 84584d9c625SLionel Sambucit can detect this situation and ignore the reclaim. 84684d9c625SLionel Sambuc.Pp 84784d9c625SLionel SambucIf the file system maps cookies to 84884d9c625SLionel Sambuc.Vt struct puffs_node 84984d9c625SLionel Sambucthen the framework will do that work, and 85084d9c625SLionel Sambuc.Fn puffs_node_reclaim 85184d9c625SLionel Sambuccan be reliabily used without the race condition. 85284d9c625SLionel Sambuc.It Fn puffs_node_abortop "pu" "opc" "pcn" 85384d9c625SLionel SambucIn case the operation following lookup (e.g., mkdir or remove) is not 85484d9c625SLionel Sambucexecuted for some reason, abortop will be issued. 85584d9c625SLionel SambucThis is useful only for servers which cache state between lookup 85684d9c625SLionel Sambucand a directory operation and is generally left unimplemented. 857490e0de5SThomas Veerman.It Fn puffs_node_inactive "pu" "opc" 858490e0de5SThomas VeermanThe node 859490e0de5SThomas Veerman.Fa opc 860490e0de5SThomas Veermanhas lost its last reference in the kernel. 861490e0de5SThomas VeermanHowever, the cookie must still remain valid until 862490e0de5SThomas Veerman.Fn puffs_node_reclaim 86384d9c625SLionel Sambucor 86484d9c625SLionel Sambuc.Fn puffs_node_reclaim2 865490e0de5SThomas Veermanis called. 866490e0de5SThomas Veerman.It Fn puffs_setback "pcc" "op" 867490e0de5SThomas VeermanIssue a "setback" operation which will be handled when the request response 868490e0de5SThomas Veermanis returned to the kernel. 869490e0de5SThomas VeermanCurrently this can be only called from mmap, open, remove and rmdir. 870490e0de5SThomas VeermanThe valid parameters for 871490e0de5SThomas Veerman.Ar op 872490e0de5SThomas Veermanare 873490e0de5SThomas Veerman.Dv PUFFS_SETBACK_INACT_N1 874490e0de5SThomas Veermanand 875490e0de5SThomas Veerman.Dv PUFFS_SETBACK_INACT_N2 . 876490e0de5SThomas VeermanThese signal that a file system mounted with 877490e0de5SThomas Veerman.Dv PUFFS_KFLAG_IAONDEMAND 878490e0de5SThomas Veermanshould call the file system inactive method for the specified node. 879490e0de5SThomas VeermanThe node number 1 always means the operation cookie 880490e0de5SThomas Veerman.Ar opc , 881490e0de5SThomas Veermanwhile the node number 2 can be used to specify the second node argument 88284d9c625SLionel Sambucpresent in some methods, e.g., remove. 883490e0de5SThomas Veerman.It Fn puffs_newinfo_setcookie pni cookie 884490e0de5SThomas VeermanSet cookie for node provided by this method to 885490e0de5SThomas Veerman.Ar cookie . 886490e0de5SThomas Veerman.It Fn puffs_newinfo_setvtype pni vtype 887490e0de5SThomas VeermanSet the type of the newly located node to 888490e0de5SThomas Veerman.Ar vtype . 889490e0de5SThomas VeermanThis call is valid only for 890490e0de5SThomas Veerman.Fn lookup 891490e0de5SThomas Veermanand 892490e0de5SThomas Veerman.Fn fhtonode . 893490e0de5SThomas Veerman.It Fn puffs_newinfo_setsize pni size 894490e0de5SThomas VeermanSet the size of the newly located node to 895490e0de5SThomas Veerman.Ar size . 896490e0de5SThomas VeermanIf left unset, the value defaults to 0. 897490e0de5SThomas VeermanThis call is valid only for 898490e0de5SThomas Veerman.Fn lookup 899490e0de5SThomas Veermanand 900490e0de5SThomas Veerman.Fn fhtovp . 901490e0de5SThomas Veerman.It Fn puffs_newinfo_setrdev pni rdev 902490e0de5SThomas VeermanSet the type of the newly located node to 903490e0de5SThomas Veerman.Ar vtype . 904490e0de5SThomas VeermanThis call is valid only for 905490e0de5SThomas Veerman.Fn lookup 906490e0de5SThomas Veermanand 907490e0de5SThomas Veerman.Fn fhtovp 908490e0de5SThomas Veermanproducing device type nodes. 90984d9c625SLionel Sambuc.It Fn puffs_newinfo_setva pni vap 91084d9c625SLionel SambucSet the attributes for newly created vnode. 91184d9c625SLionel SambucThis call is valid for 91284d9c625SLionel Sambuc.Fn lookup , 91384d9c625SLionel Sambuc.Fn create , 91484d9c625SLionel Sambuc.Fn mkdir , 91584d9c625SLionel Sambuc.Fn mknod , 91684d9c625SLionel Sambucand 91784d9c625SLionel Sambuc.Fn symlink , 91884d9c625SLionel Sambucif 91984d9c625SLionel Sambuc.Fn puffs_init 92084d9c625SLionel Sambucwas called with 92184d9c625SLionel Sambuc.Dv PUFFS_KFLAG_CACHE_FS_TTL 92284d9c625SLionel Sambucflag set. 92384d9c625SLionel Sambuc.It Fn puffs_newinfo_setvattl pni va_ttl 92484d9c625SLionel SambucSet cached attribute time to live for newly created vnode. 92584d9c625SLionel SambucThis call is valid for 92684d9c625SLionel Sambuc.Fn lookup , 92784d9c625SLionel Sambuc.Fn create , 92884d9c625SLionel Sambuc.Fn mkdir , 92984d9c625SLionel Sambuc.Fn mknod , 93084d9c625SLionel Sambucand 93184d9c625SLionel Sambuc.Fn symlink , 93284d9c625SLionel Sambucif 93384d9c625SLionel Sambuc.Fn puffs_init 93484d9c625SLionel Sambucwas called with 93584d9c625SLionel Sambuc.Dv PUFFS_KFLAG_CACHE_FS_TTL 93684d9c625SLionel Sambucflag set. 93784d9c625SLionel Sambuc.It Fn puffs_newinfo_setcnttl pni cn_ttl 93884d9c625SLionel SambucSet cached name time to live for newly created vnode. 93984d9c625SLionel SambucThis call is valid for 94084d9c625SLionel Sambuc.Fn lookup , 94184d9c625SLionel Sambuc.Fn create , 94284d9c625SLionel Sambuc.Fn mkdir , 94384d9c625SLionel Sambuc.Fn mknod , 94484d9c625SLionel Sambucand 94584d9c625SLionel Sambuc.Fn symlink , 94684d9c625SLionel Sambucif 94784d9c625SLionel Sambuc.Fn puffs_init 94884d9c625SLionel Sambucwas called with 94984d9c625SLionel Sambuc.Dv PUFFS_KFLAG_CACHE_FS_TTL 95084d9c625SLionel Sambucflag set. 951490e0de5SThomas Veerman.El 952490e0de5SThomas Veerman.Sh SEE ALSO 953490e0de5SThomas Veerman.Xr puffs 3 , 954490e0de5SThomas Veerman.Xr vfsops 9 , 955490e0de5SThomas Veerman.Xr vnodeops 9 956