Home | History | Annotate | Line # | Download | only in libperfuse
perfuse_priv.h revision 1.1
      1  1.1  manu /*  $NetBSD: perfuse_priv.h,v 1.1 2010/08/25 07:16:00 manu Exp $ */
      2  1.1  manu 
      3  1.1  manu /*-
      4  1.1  manu  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
      5  1.1  manu  *
      6  1.1  manu  *  Redistribution and use in source and binary forms, with or without
      7  1.1  manu  *  modification, are permitted provided that the following conditions
      8  1.1  manu  *  are met:
      9  1.1  manu  *  1. Redistributions of source code must retain the above copyright
     10  1.1  manu  *     notice, this list of conditions and the following disclaimer.
     11  1.1  manu  *  2. Redistributions in binary form must reproduce the above copyright
     12  1.1  manu  *     notice, this list of conditions and the following disclaimer in the
     13  1.1  manu  *     documentation and/or other materials provided with the distribution.
     14  1.1  manu  *
     15  1.1  manu  *  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16  1.1  manu  *  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17  1.1  manu  *  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  1.1  manu  *  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19  1.1  manu  *  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20  1.1  manu  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21  1.1  manu  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22  1.1  manu  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  1.1  manu  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24  1.1  manu  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1  manu  *  POSSIBILITY OF SUCH DAMAGE.
     26  1.1  manu  */
     27  1.1  manu 
     28  1.1  manu #ifndef _PERFUSE_PRIV_H_
     29  1.1  manu #define _PERFUSE_PRIV_H_
     30  1.1  manu 
     31  1.1  manu #include <syslog.h>
     32  1.1  manu #include <paths.h>
     33  1.1  manu #include <err.h>
     34  1.1  manu #include <sysexits.h>
     35  1.1  manu #include <puffs.h>
     36  1.1  manu 
     37  1.1  manu #include "perfuse_if.h"
     38  1.1  manu #include "fuse.h"
     39  1.1  manu 
     40  1.1  manu struct perfuse_state {
     41  1.1  manu 	void *ps_private;	/* Private field for libperfuse user */
     42  1.1  manu 	struct puffs_usermount *ps_pu;
     43  1.1  manu 	struct puffs_node *ps_root;
     44  1.1  manu 	uid_t ps_uid;
     45  1.1  manu 	gid_t ps_gid;
     46  1.1  manu 	pid_t ps_pid;
     47  1.1  manu 	int ps_flags;
     48  1.1  manu #define PS_NO_ACCESS	0x0001	/* access is unimplemented; */
     49  1.1  manu #define PS_NO_FSYNC	0x0002	/* fsync is unimplemented */
     50  1.1  manu #define PS_NO_CREAT	0x0004	/* create is unimplemented */
     51  1.1  manu #define PS_INLOOP	0x0008	/* puffs mainloop started */
     52  1.1  manu 	long ps_fsid;
     53  1.1  manu 	uint32_t ps_max_readahead;
     54  1.1  manu 	uint32_t ps_max_write;
     55  1.1  manu 	uint64_t ps_syncreads;
     56  1.1  manu 	uint64_t ps_syncwrites;
     57  1.1  manu 	uint64_t ps_asyncreads;
     58  1.1  manu 	uint64_t ps_asyncwrites;
     59  1.1  manu 	char *ps_source;
     60  1.1  manu 	char *ps_target;
     61  1.1  manu 	char *ps_filesystemtype;
     62  1.1  manu 	int ps_mountflags;
     63  1.1  manu 	uint64_t ps_unique;
     64  1.1  manu 	uint32_t ps_readahead;
     65  1.1  manu 	uint32_t ps_write;
     66  1.1  manu 	perfuse_new_msg_fn ps_new_msg;
     67  1.1  manu 	perfuse_xchg_msg_fn ps_xchg_msg;
     68  1.1  manu 	perfuse_destroy_msg_fn ps_destroy_msg;
     69  1.1  manu 	perfuse_get_inhdr_fn ps_get_inhdr;
     70  1.1  manu 	perfuse_get_inpayload_fn ps_get_inpayload;
     71  1.1  manu 	perfuse_get_outhdr_fn ps_get_outhdr;
     72  1.1  manu 	perfuse_get_outpayload_fn ps_get_outpayload;
     73  1.1  manu };
     74  1.1  manu 
     75  1.1  manu 
     76  1.1  manu struct perfuse_file_handle {
     77  1.1  manu 	uint64_t pfh_fh;
     78  1.1  manu 	TAILQ_ENTRY(perfuse_file_handle) pfh_entries;
     79  1.1  manu };
     80  1.1  manu 
     81  1.1  manu 
     82  1.1  manu enum perfuse_qtype { PCQ_READDIR, PCQ_READ, PCQ_WRITE };
     83  1.1  manu 
     84  1.1  manu struct perfuse_cc_queue {
     85  1.1  manu 	enum perfuse_qtype pcq_type;
     86  1.1  manu 	struct puffs_cc *pcq_cc;
     87  1.1  manu 	TAILQ_ENTRY(perfuse_cc_queue) pcq_next;
     88  1.1  manu };
     89  1.1  manu 
     90  1.1  manu 
     91  1.1  manu struct perfuse_node_data {
     92  1.1  manu 	TAILQ_HEAD(,perfuse_file_handle) pnd_fh;
     93  1.1  manu 	uint64_t pnd_ino;			/* inode */
     94  1.1  manu 	uint64_t pnd_nlookup;			/* vnode refcount */
     95  1.1  manu 	uint64_t pnd_offset;			/* seek state */
     96  1.1  manu 	uint64_t pnd_lock_owner;
     97  1.1  manu 	struct dirent *pnd_dirent;		/* native buffer for readdir */
     98  1.1  manu 	size_t pnd_dirent_len;
     99  1.1  manu 	struct fuse_dirent *pnd_all_fd;		/* FUSE buffer for readdir */
    100  1.1  manu 	size_t pnd_all_fd_len;
    101  1.1  manu 	TAILQ_HEAD(,perfuse_cc_queue) pnd_pcq;	/* queued requests */
    102  1.1  manu 	int pnd_flags;
    103  1.1  manu #define PND_RECLAIMED		0x1	/* reclaim pending */
    104  1.1  manu #define PND_INREADDIR		0x2	/* readdir in progress */
    105  1.1  manu 	puffs_cookie_t pnd_parent;
    106  1.1  manu 	int pnd_childcount;
    107  1.1  manu };
    108  1.1  manu 
    109  1.1  manu #define PERFUSE_NODE_DATA(opc)	\
    110  1.1  manu 	((struct perfuse_node_data *)puffs_pn_getpriv((struct puffs_node *)opc))
    111  1.1  manu 
    112  1.1  manu 
    113  1.1  manu #define UNSPEC_REPLY_LEN PERFUSE_UNSPEC_REPLY_LEN /* shorter! */
    114  1.1  manu #define NO_PAYLOAD_REPLY_LEN 0
    115  1.1  manu 
    116  1.1  manu #define GET_INHDR(ps, pm) ps->ps_get_inhdr(pm)
    117  1.1  manu #define GET_INPAYLOAD(ps, pm, type) \
    118  1.1  manu 	(struct type *)(void *)ps->ps_get_inpayload(pm)
    119  1.1  manu #define _GET_INPAYLOAD(ps, pm, type) (type)ps->ps_get_inpayload(pm)
    120  1.1  manu #define GET_OUTHDR(ps, pm) ps->ps_get_outhdr(pm)
    121  1.1  manu #define GET_OUTPAYLOAD(ps, pm, type) \
    122  1.1  manu 	(struct type *)(void *)ps->ps_get_outpayload(pm)
    123  1.1  manu #define _GET_OUTPAYLOAD(ps, pm, type) (type)ps->ps_get_outpayload(pm)
    124  1.1  manu 
    125  1.1  manu #define XCHG_MSG(ps, pu, opc, len) ps->ps_xchg_msg(pu, opc, len, wait_reply)
    126  1.1  manu #define XCHG_MSG_NOREPLY(ps, pu, opc, len) \
    127  1.1  manu     ps->ps_xchg_msg(pu, opc, len, no_reply)
    128  1.1  manu 
    129  1.1  manu __BEGIN_DECLS
    130  1.1  manu 
    131  1.1  manu struct puffs_node *perfuse_new_pn(struct puffs_usermount *,
    132  1.1  manu     struct puffs_node *);
    133  1.1  manu void perfuse_destroy_pn(struct puffs_node *);
    134  1.1  manu void perfuse_new_fh(puffs_cookie_t, uint64_t);
    135  1.1  manu void perfuse_destroy_fh(puffs_cookie_t, uint64_t);
    136  1.1  manu uint64_t perfuse_get_fh(puffs_cookie_t);
    137  1.1  manu uint64_t perfuse_next_unique(struct puffs_usermount *);
    138  1.1  manu 
    139  1.1  manu char *perfuse_fs_mount(int, ssize_t);
    140  1.1  manu 
    141  1.1  manu 
    142  1.1  manu /*
    143  1.1  manu  * opc.c - filesystem operations
    144  1.1  manu  */
    145  1.1  manu int perfuse_fs_unmount(struct puffs_usermount *, int);
    146  1.1  manu int perfuse_fs_statvfs(struct puffs_usermount *, struct statvfs *);
    147  1.1  manu int perfuse_fs_sync(struct puffs_usermount *, int,
    148  1.1  manu     const struct puffs_cred *);
    149  1.1  manu int perfuse_fs_fhtonode(struct puffs_usermount *, void *, size_t,
    150  1.1  manu     struct puffs_newinfo *);
    151  1.1  manu int perfuse_fs_nodetofh(struct puffs_usermount *, puffs_cookie_t,
    152  1.1  manu     void *, size_t *);
    153  1.1  manu void perfuse_fs_suspend(struct puffs_usermount *, int);
    154  1.1  manu int perfuse_node_lookup(struct puffs_usermount *,
    155  1.1  manu     puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *);
    156  1.1  manu int perfuse_node_create(struct puffs_usermount *,
    157  1.1  manu     puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *,
    158  1.1  manu     const struct vattr *);
    159  1.1  manu int perfuse_node_mknod(struct puffs_usermount *,
    160  1.1  manu     puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *,
    161  1.1  manu     const struct vattr *);
    162  1.1  manu int perfuse_node_open(struct puffs_usermount *,
    163  1.1  manu     puffs_cookie_t, int, const struct puffs_cred *);
    164  1.1  manu int perfuse_node_close(struct puffs_usermount *,
    165  1.1  manu     puffs_cookie_t, int, const struct puffs_cred *);
    166  1.1  manu int perfuse_node_access(struct puffs_usermount *,
    167  1.1  manu     puffs_cookie_t, int, const struct puffs_cred *);
    168  1.1  manu int perfuse_node_getattr(struct puffs_usermount *,
    169  1.1  manu     puffs_cookie_t, struct vattr *, const struct puffs_cred *);
    170  1.1  manu int perfuse_node_setattr(struct puffs_usermount *,
    171  1.1  manu     puffs_cookie_t, const struct vattr *, const struct puffs_cred *);
    172  1.1  manu int perfuse_node_poll(struct puffs_usermount *, puffs_cookie_t, int *);
    173  1.1  manu int perfuse_node_mmap(struct puffs_usermount *,
    174  1.1  manu     puffs_cookie_t, vm_prot_t, const struct puffs_cred *);
    175  1.1  manu int perfuse_node_fsync(struct puffs_usermount *,
    176  1.1  manu     puffs_cookie_t, const struct puffs_cred *, int, off_t, off_t);
    177  1.1  manu int perfuse_node_seek(struct puffs_usermount *,
    178  1.1  manu     puffs_cookie_t, off_t, off_t, const struct puffs_cred *);
    179  1.1  manu int perfuse_node_remove(struct puffs_usermount *,
    180  1.1  manu     puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
    181  1.1  manu int perfuse_node_link(struct puffs_usermount *,
    182  1.1  manu     puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
    183  1.1  manu int perfuse_node_rename(struct puffs_usermount *,
    184  1.1  manu     puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *,
    185  1.1  manu     puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
    186  1.1  manu int perfuse_node_mkdir(struct puffs_usermount *,
    187  1.1  manu     puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *,
    188  1.1  manu     const struct vattr *);
    189  1.1  manu int perfuse_node_rmdir(struct puffs_usermount *,
    190  1.1  manu     puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
    191  1.1  manu int perfuse_node_symlink(struct puffs_usermount *,
    192  1.1  manu     puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *,
    193  1.1  manu     const struct vattr *, const char *);
    194  1.1  manu int perfuse_node_readdir(struct puffs_usermount *,
    195  1.1  manu     puffs_cookie_t, struct dirent *, off_t *, size_t *,
    196  1.1  manu     const struct puffs_cred *, int *, off_t *, size_t *);
    197  1.1  manu int perfuse_node_readlink(struct puffs_usermount *,
    198  1.1  manu     puffs_cookie_t, const struct puffs_cred *, char *, size_t *);
    199  1.1  manu int perfuse_node_reclaim(struct puffs_usermount *, puffs_cookie_t);
    200  1.1  manu int perfuse_node_inactive(struct puffs_usermount *, puffs_cookie_t);
    201  1.1  manu int perfuse_node_print(struct puffs_usermount *, puffs_cookie_t);
    202  1.1  manu int perfuse_node_pathconf(struct puffs_usermount *,
    203  1.1  manu     puffs_cookie_t, int, int *);
    204  1.1  manu int perfuse_node_advlock(struct puffs_usermount *,
    205  1.1  manu     puffs_cookie_t, void *, int, struct flock *, int);
    206  1.1  manu int perfuse_node_read(struct puffs_usermount *, puffs_cookie_t,
    207  1.1  manu     uint8_t *, off_t, size_t *, const struct puffs_cred *, int);
    208  1.1  manu int perfuse_node_write(struct puffs_usermount *, puffs_cookie_t,
    209  1.1  manu     uint8_t *, off_t, size_t *, const struct puffs_cred *, int);
    210  1.1  manu void perfuse_cache_write(struct puffs_usermount *,
    211  1.1  manu     puffs_cookie_t, size_t, struct puffs_cacherun *);
    212  1.1  manu 
    213  1.1  manu __END_DECLS
    214  1.1  manu 
    215  1.1  manu #endif /* _PERFUSE_PRIV_H_ */
    216