1331722Seadler/* 2241519Sattilio * Copyright (c) 2007-2009 Google Inc. and Amit Singh 3241519Sattilio * All rights reserved. 4241519Sattilio * 5241519Sattilio * Redistribution and use in source and binary forms, with or without 6241519Sattilio * modification, are permitted provided that the following conditions are 7241519Sattilio * met: 8241519Sattilio * 9241519Sattilio * * Redistributions of source code must retain the above copyright 10241519Sattilio * notice, this list of conditions and the following disclaimer. 11241519Sattilio * * Redistributions in binary form must reproduce the above 12241519Sattilio * copyright notice, this list of conditions and the following disclaimer 13241519Sattilio * in the documentation and/or other materials provided with the 14241519Sattilio * distribution. 15241519Sattilio * * Neither the name of Google Inc. nor the names of its 16241519Sattilio * contributors may be used to endorse or promote products derived from 17241519Sattilio * this software without specific prior written permission. 18241519Sattilio * 19241519Sattilio * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20241519Sattilio * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21241519Sattilio * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22241519Sattilio * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23241519Sattilio * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24241519Sattilio * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25241519Sattilio * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26241519Sattilio * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27241519Sattilio * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28241519Sattilio * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29241519Sattilio * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30241519Sattilio * 31241519Sattilio * Copyright (C) 2005 Csaba Henk. 32241519Sattilio * All rights reserved. 33241519Sattilio * 34241519Sattilio * Redistribution and use in source and binary forms, with or without 35241519Sattilio * modification, are permitted provided that the following conditions 36241519Sattilio * are met: 37241519Sattilio * 1. Redistributions of source code must retain the above copyright 38241519Sattilio * notice, this list of conditions and the following disclaimer. 39241519Sattilio * 2. Redistributions in binary form must reproduce the above copyright 40241519Sattilio * notice, this list of conditions and the following disclaimer in the 41241519Sattilio * documentation and/or other materials provided with the distribution. 42241519Sattilio * 43241519Sattilio * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 44241519Sattilio * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 45241519Sattilio * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 46241519Sattilio * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 47241519Sattilio * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 48241519Sattilio * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 49241519Sattilio * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 50241519Sattilio * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 51241519Sattilio * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 52241519Sattilio * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 53241519Sattilio * SUCH DAMAGE. 54241519Sattilio * 55241519Sattilio * $FreeBSD: stable/11/sys/fs/fuse/fuse_node.h 349308 2019-06-23 14:49:30Z asomers $ 56241519Sattilio */ 57241519Sattilio 58241519Sattilio#ifndef _FUSE_NODE_H_ 59241519Sattilio#define _FUSE_NODE_H_ 60241519Sattilio 61241519Sattilio#include <sys/types.h> 62241519Sattilio#include <sys/mutex.h> 63241519Sattilio 64241519Sattilio#include "fuse_file.h" 65241519Sattilio 66241519Sattilio#define FN_REVOKED 0x00000020 67241519Sattilio#define FN_FLUSHINPROG 0x00000040 68241519Sattilio#define FN_FLUSHWANT 0x00000080 69241519Sattilio#define FN_SIZECHANGE 0x00000100 70279536Strasz#define FN_DIRECTIO 0x00000200 71241519Sattilio 72241519Sattiliostruct fuse_vnode_data { 73241519Sattilio /** self **/ 74241519Sattilio uint64_t nid; 75241519Sattilio 76241519Sattilio /** parent **/ 77241519Sattilio /* XXXIP very likely to be stale, it's not updated in rename() */ 78241519Sattilio uint64_t parent_nid; 79241519Sattilio 80241519Sattilio /** I/O **/ 81241519Sattilio struct fuse_filehandle fufh[FUFH_MAXTYPE]; 82241519Sattilio 83241519Sattilio /** flags **/ 84241519Sattilio uint32_t flag; 85241519Sattilio 86241519Sattilio /** meta **/ 87241519Sattilio struct vattr cached_attrs; 88241519Sattilio off_t filesize; 89241519Sattilio uint64_t nlookup; 90241519Sattilio enum vtype vtype; 91241519Sattilio}; 92241519Sattilio 93241519Sattilio#define VTOFUD(vp) \ 94241519Sattilio ((struct fuse_vnode_data *)((vp)->v_data)) 95241519Sattilio#define VTOI(vp) (VTOFUD(vp)->nid) 96241519Sattilio#define VTOVA(vp) (&(VTOFUD(vp)->cached_attrs)) 97241519Sattilio#define VTOILLU(vp) ((uint64_t)(VTOFUD(vp) ? VTOI(vp) : 0)) 98241519Sattilio 99241519Sattilio#define FUSE_NULL_ID 0 100241519Sattilio 101241519Sattilioextern struct vop_vector fuse_vnops; 102241519Sattilio 103241519Sattiliostatic __inline void 104241519Sattiliofuse_vnode_setparent(struct vnode *vp, struct vnode *dvp) 105241519Sattilio{ 106241519Sattilio if (dvp != NULL && vp->v_type == VDIR) { 107241519Sattilio MPASS(dvp->v_type == VDIR); 108241519Sattilio VTOFUD(vp)->parent_nid = VTOI(dvp); 109241519Sattilio } 110241519Sattilio} 111241519Sattilio 112241519Sattiliovoid fuse_vnode_destroy(struct vnode *vp); 113241519Sattilio 114241519Sattilioint fuse_vnode_get(struct mount *mp, 115241519Sattilio uint64_t nodeid, 116241519Sattilio struct vnode *dvp, 117241519Sattilio struct vnode **vpp, 118241519Sattilio struct componentname *cnp, 119241519Sattilio enum vtype vtyp); 120241519Sattilio 121241519Sattiliovoid fuse_vnode_open(struct vnode *vp, 122241519Sattilio int32_t fuse_open_flags, 123241519Sattilio struct thread *td); 124241519Sattilio 125241519Sattiliovoid fuse_vnode_refreshsize(struct vnode *vp, struct ucred *cred); 126241519Sattilio 127241519Sattilioint fuse_vnode_savesize(struct vnode *vp, struct ucred *cred); 128241519Sattilio 129349308Sasomersint fuse_vnode_setsize(struct vnode *vp, off_t newsize); 130241519Sattilio 131241519Sattilio#endif /* _FUSE_NODE_H_ */ 132