1/*- 2 * Copyright (c) 2014 Hans Petter Selasky. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26#ifndef _CUSE_H_ 27#define _CUSE_H_ 28 29#ifdef __cplusplus 30extern "C" { 31#endif 32 33#include <fs/cuse/cuse_defs.h> 34 35struct cuse_dev; 36 37typedef int (cuse_open_t)(struct cuse_dev *, int fflags); 38typedef int (cuse_close_t)(struct cuse_dev *, int fflags); 39typedef int (cuse_read_t)(struct cuse_dev *, int fflags, void *user_ptr, int len); 40typedef int (cuse_write_t)(struct cuse_dev *, int fflags, const void *user_ptr, int len); 41typedef int (cuse_ioctl_t)(struct cuse_dev *, int fflags, unsigned long cmd, void *user_data); 42typedef int (cuse_poll_t)(struct cuse_dev *, int fflags, int events); 43 44struct cuse_methods { 45 cuse_open_t *cm_open; 46 cuse_close_t *cm_close; 47 cuse_read_t *cm_read; 48 cuse_write_t *cm_write; 49 cuse_ioctl_t *cm_ioctl; 50 cuse_poll_t *cm_poll; 51}; 52 53int cuse_init(void); 54int cuse_uninit(void); 55 56void *cuse_vmalloc(unsigned); 57int cuse_is_vmalloc_addr(void *); 58void cuse_vmfree(void *); 59unsigned long cuse_vmoffset(void *ptr); 60 61int cuse_alloc_unit_number_by_id(int *, int); 62int cuse_free_unit_number_by_id(int, int); 63int cuse_alloc_unit_number(int *); 64int cuse_free_unit_number(int); 65 66struct cuse_dev *cuse_dev_create(const struct cuse_methods *, void *, void *, uid_t, gid_t, int, const char *,...); 67void cuse_dev_destroy(struct cuse_dev *); 68 69void *cuse_dev_get_priv0(struct cuse_dev *); 70void *cuse_dev_get_priv1(struct cuse_dev *); 71 72void cuse_dev_set_priv0(struct cuse_dev *, void *); 73void cuse_dev_set_priv1(struct cuse_dev *, void *); 74 75void cuse_set_local(int); 76int cuse_get_local(void); 77 78int cuse_wait_and_process(void); 79 80void cuse_dev_set_per_file_handle(struct cuse_dev *, void *); 81void *cuse_dev_get_per_file_handle(struct cuse_dev *); 82 83int cuse_copy_out(const void *src, void *user_dst, int len); 84int cuse_copy_in(const void *user_src, void *dst, int len); 85int cuse_got_peer_signal(void); 86void cuse_poll_wakeup(void); 87 88struct cuse_dev *cuse_dev_get_current(int *); 89 90extern int cuse_debug_level; 91 92#ifdef __cplusplus 93} 94#endif 95 96#endif /* _CUSE_H_ */ 97