1 /* 2 * Copyright (c) 2007-2009 Google Inc. and Amit Singh 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * * Redistributions in binary form must reproduce the above 12 * copyright notice, this list of conditions and the following disclaimer 13 * in the documentation and/or other materials provided with the 14 * distribution. 15 * * Neither the name of Google Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * Copyright (C) 2005 Csaba Henk. 32 * All rights reserved. 33 * 34 * Redistribution and use in source and binary forms, with or without 35 * modification, are permitted provided that the following conditions 36 * are met: 37 * 1. Redistributions of source code must retain the above copyright 38 * notice, this list of conditions and the following disclaimer. 39 * 2. Redistributions in binary form must reproduce the above copyright 40 * notice, this list of conditions and the following disclaimer in the 41 * documentation and/or other materials provided with the distribution. 42 * 43 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 46 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 53 * SUCH DAMAGE. 54 * 55 * $FreeBSD$ 56 */ 57 58 #ifndef _FUSE_NODE_H_ 59 #define _FUSE_NODE_H_ 60 61 #include <sys/types.h> 62 #include <sys/mutex.h> 63 64 #include "fuse_file.h" 65 66 #define FN_REVOKED 0x00000020 67 #define FN_FLUSHINPROG 0x00000040 68 #define FN_FLUSHWANT 0x00000080 69 #define FN_SIZECHANGE 0x00000100 70 71 struct fuse_vnode_data { 72 /** self **/ 73 uint64_t nid; 74 75 /** parent **/ 76 /* XXXIP very likely to be stale, it's not updated in rename() */ 77 uint64_t parent_nid; 78 79 /** I/O **/ 80 struct fuse_filehandle fufh[FUFH_MAXTYPE]; 81 82 /** flags **/ 83 uint32_t flag; 84 85 /** meta **/ 86 struct vattr cached_attrs; 87 off_t filesize; 88 uint64_t nlookup; 89 enum vtype vtype; 90 }; 91 92 #define VTOFUD(vp) \ 93 ((struct fuse_vnode_data *)((vp)->v_data)) 94 #define VTOI(vp) (VTOFUD(vp)->nid) 95 #define VTOVA(vp) (&(VTOFUD(vp)->cached_attrs)) 96 #define VTOILLU(vp) ((uint64_t)(VTOFUD(vp) ? VTOI(vp) : 0)) 97 98 #define FUSE_NULL_ID 0 99 100 extern struct vop_vector fuse_vnops; 101 102 static __inline void 103 fuse_vnode_setparent(struct vnode *vp, struct vnode *dvp) 104 { 105 if (dvp != NULL && vp->v_type == VDIR) { 106 MPASS(dvp->v_type == VDIR); 107 VTOFUD(vp)->parent_nid = VTOI(dvp); 108 } 109 } 110 111 void fuse_vnode_destroy(struct vnode *vp); 112 113 int fuse_vnode_get(struct mount *mp, 114 uint64_t nodeid, 115 struct vnode *dvp, 116 struct vnode **vpp, 117 struct componentname *cnp, 118 enum vtype vtyp); 119 120 void fuse_vnode_open(struct vnode *vp, 121 int32_t fuse_open_flags, 122 struct thread *td); 123 124 void fuse_vnode_refreshsize(struct vnode *vp, struct ucred *cred); 125 126 int fuse_vnode_savesize(struct vnode *vp, struct ucred *cred); 127 128 int fuse_vnode_setsize(struct vnode *vp, struct ucred *cred, off_t newsize); 129 130 #endif /* _FUSE_NODE_H_ */ 131