1 1.1 pho /* $NetBSD: fs.h,v 1.1 2022/01/22 08:09:40 pho Exp $ */ 2 1.1 pho 3 1.1 pho /* 4 1.1 pho * Copyright (c) 2021 The NetBSD Foundation, Inc. 5 1.1 pho * All rights reserved. 6 1.1 pho * 7 1.1 pho * Redistribution and use in source and binary forms, with or without 8 1.1 pho * modification, are permitted provided that the following conditions 9 1.1 pho * are met: 10 1.1 pho * 1. Redistributions of source code must retain the above copyright 11 1.1 pho * notice, this list of conditions and the following disclaimer. 12 1.1 pho * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 pho * notice, this list of conditions and the following disclaimer in the 14 1.1 pho * documentation and/or other materials provided with the distribution. 15 1.1 pho * 3. The name of the author may not be used to endorse or promote 16 1.1 pho * products derived from this software without specific prior written 17 1.1 pho * permission. 18 1.1 pho * 19 1.1 pho * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 20 1.1 pho * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 1.1 pho * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 1.1 pho * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 23 1.1 pho * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 1.1 pho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 25 1.1 pho * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 pho * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 1.1 pho * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 1.1 pho * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 1.1 pho * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 1.1 pho */ 31 1.1 pho #if !defined(_FUSE_FS_H_) 32 1.1 pho #define _FUSE_FS_H_ 33 1.1 pho 34 1.1 pho /* 35 1.1 pho * Filesystem Stacking API, appeared on FUSE 2.7 36 1.1 pho */ 37 1.1 pho 38 1.1 pho #if !defined(FUSE_H_) 39 1.1 pho # error Do not include this header directly. Include <fuse.h> instead. 40 1.1 pho #endif 41 1.1 pho 42 1.1 pho #ifdef __cplusplus 43 1.1 pho extern "C" { 44 1.1 pho #endif 45 1.1 pho 46 1.1 pho /* An opaque object representing a filesystem layer. */ 47 1.1 pho struct fuse_fs; 48 1.1 pho 49 1.1 pho /* Create a filesystem layer. api_version has to be the version of 50 1.1 pho * struct fuse_operations which is not necessarily the same as API 51 1.1 pho * version. Note that user code should always use fuse_fs_new() and 52 1.1 pho * should never call this internal function directly. */ 53 1.1 pho struct fuse_fs *__fuse_fs_new(const void* op, int op_version, void* user_data); 54 1.1 pho 55 1.1 pho /* These functions call the relevant filesystem operation, and return 56 1.1 pho * the result. If the operation is not defined, they return -ENOSYS, 57 1.1 pho * with the exception of fuse_fs_open, fuse_fs_release, 58 1.1 pho * fuse_fs_opendir, fuse_fs_releasedir, and fuse_fs_statfs, which return 0. */ 59 1.1 pho int fuse_fs_getattr_v27(struct fuse_fs *fs, const char *path, struct stat *buf); 60 1.1 pho int fuse_fs_getattr_v30(struct fuse_fs* fs, const char* path, struct stat* buf, struct fuse_file_info* fi); 61 1.1 pho int fuse_fs_fgetattr(struct fuse_fs* fs, const char* path, struct stat* buf, struct fuse_file_info* fi); 62 1.1 pho int fuse_fs_rename_v27(struct fuse_fs* fs, const char* oldpath, const char* newpath); 63 1.1 pho int fuse_fs_rename_v30(struct fuse_fs* fs, const char* oldpath, const char* newpath, unsigned int flags); 64 1.1 pho int fuse_fs_unlink(struct fuse_fs* fs, const char* path); 65 1.1 pho int fuse_fs_rmdir(struct fuse_fs* fs, const char* path); 66 1.1 pho int fuse_fs_symlink(struct fuse_fs* fs, const char* linkname, const char* path); 67 1.1 pho int fuse_fs_link(struct fuse_fs* fs, const char* oldpath, const char* newpath); 68 1.1 pho int fuse_fs_release(struct fuse_fs* fs, const char* path, struct fuse_file_info* fi); 69 1.1 pho int fuse_fs_open(struct fuse_fs* fs, const char* path, struct fuse_file_info* fi); 70 1.1 pho int fuse_fs_read(struct fuse_fs* fs, const char* path, char* buf, size_t size, off_t off, struct fuse_file_info* fi); 71 1.1 pho int fuse_fs_read_buf(struct fuse_fs* fs, const char* path, struct fuse_bufvec** bufp, size_t size, off_t off, struct fuse_file_info* fi); 72 1.1 pho int fuse_fs_write(struct fuse_fs* fs, const char* path, const char* buf, size_t size, off_t off, struct fuse_file_info* fi); 73 1.1 pho int fuse_fs_write_buf(struct fuse_fs* fs, const char* path, struct fuse_bufvec *buf, off_t off, struct fuse_file_info* fi); 74 1.1 pho int fuse_fs_fsync(struct fuse_fs* fs, const char* path, int datasync, struct fuse_file_info* fi); 75 1.1 pho int fuse_fs_flush(struct fuse_fs* fs, const char* path, struct fuse_file_info* fi); 76 1.1 pho int fuse_fs_statfs(struct fuse_fs* fs, const char* path, struct statvfs* buf); 77 1.1 pho int fuse_fs_opendir(struct fuse_fs* fs, const char* path, struct fuse_file_info* fi); 78 1.1 pho int fuse_fs_readdir_v27(struct fuse_fs* fs, const char* path, void* buf, fuse_fill_dir_t_v23 filler, off_t off, struct fuse_file_info* fi); 79 1.1 pho int fuse_fs_readdir_v30(struct fuse_fs* fs, const char* path, void* buf, fuse_fill_dir_t_v30 filler, off_t off, struct fuse_file_info* fi, enum fuse_readdir_flags flags); 80 1.1 pho int fuse_fs_fsyncdir(struct fuse_fs* fs, const char* path, int datasync, struct fuse_file_info* fi); 81 1.1 pho int fuse_fs_releasedir(struct fuse_fs* fs, const char* path, struct fuse_file_info* fi); 82 1.1 pho int fuse_fs_create(struct fuse_fs* fs, const char* path, mode_t mode, struct fuse_file_info* fi); 83 1.1 pho int fuse_fs_lock(struct fuse_fs* fs, const char* path, struct fuse_file_info* fi, int cmd, struct flock* lock); 84 1.1 pho int fuse_fs_flock(struct fuse_fs* fs, const char* path, struct fuse_file_info* fi, int op); 85 1.1 pho int fuse_fs_chmod_v27(struct fuse_fs *fs, const char *path, mode_t mode); 86 1.1 pho int fuse_fs_chmod_v30(struct fuse_fs* fs, const char* path, mode_t mode, struct fuse_file_info* fi); 87 1.1 pho int fuse_fs_chown_v27(struct fuse_fs *fs, const char *path, uid_t uid, gid_t gid); 88 1.1 pho int fuse_fs_chown_v30(struct fuse_fs* fs, const char* path, uid_t uid, gid_t gid, struct fuse_file_info* fi); 89 1.1 pho int fuse_fs_truncate_v27(struct fuse_fs *fs, const char *path, off_t size); 90 1.1 pho int fuse_fs_truncate_v30(struct fuse_fs* fs, const char* path, off_t size, struct fuse_file_info* fi); 91 1.1 pho int fuse_fs_ftruncate(struct fuse_fs* fs, const char* path, off_t size, struct fuse_file_info* fi); 92 1.1 pho int fuse_fs_utimens_v27(struct fuse_fs *fs, const char *path, const struct timespec tv[2]); 93 1.1 pho int fuse_fs_utimens_v30(struct fuse_fs* fs, const char* path, const struct timespec tv[2], struct fuse_file_info* fi); 94 1.1 pho int fuse_fs_access(struct fuse_fs* fs, const char* path, int mask); 95 1.1 pho int fuse_fs_readlink(struct fuse_fs* fs, const char* path, char* buf, size_t len); 96 1.1 pho int fuse_fs_mknod(struct fuse_fs* fs, const char* path, mode_t mode, dev_t rdev); 97 1.1 pho int fuse_fs_mkdir(struct fuse_fs* fs, const char* path, mode_t mode); 98 1.1 pho int fuse_fs_setxattr(struct fuse_fs* fs, const char* path, const char* name, const char* value, size_t size, int flags); 99 1.1 pho int fuse_fs_getxattr(struct fuse_fs* fs, const char* path, const char* name, char* value, size_t size); 100 1.1 pho int fuse_fs_listxattr(struct fuse_fs* fs, const char* path, char* list, size_t size); 101 1.1 pho int fuse_fs_removexattr(struct fuse_fs* fs, const char* path, const char* name); 102 1.1 pho int fuse_fs_bmap(struct fuse_fs* fs, const char* path, size_t blocksize, uint64_t *idx); 103 1.1 pho int fuse_fs_ioctl_v28(struct fuse_fs* fs, const char* path, int cmd, void* arg, struct fuse_file_info* fi, unsigned int flags, void* data); 104 1.1 pho int fuse_fs_ioctl_v35(struct fuse_fs* fs, const char* path, unsigned int cmd, void* arg, struct fuse_file_info* fi, unsigned int flags, void* data); 105 1.1 pho int fuse_fs_poll(struct fuse_fs* fs, const char* path, struct fuse_file_info* fi, struct fuse_pollhandle* ph, unsigned* reventsp); 106 1.1 pho int fuse_fs_fallocate(struct fuse_fs* fs, const char* path, int mode, off_t offset, off_t length, struct fuse_file_info* fi); 107 1.1 pho ssize_t fuse_fs_copy_file_range(struct fuse_fs* fs, 108 1.1 pho const char* path_in, struct fuse_file_info* fi_in, off_t off_in, 109 1.1 pho const char* path_out, struct fuse_file_info* fi_out, off_t off_out, 110 1.1 pho size_t len, int flags); 111 1.1 pho off_t fuse_fs_lseek(struct fuse_fs* fs, const char* path, off_t off, int whence, struct fuse_file_info* fi); 112 1.1 pho void fuse_fs_init_v27(struct fuse_fs* fs, struct fuse_conn_info* conn); 113 1.1 pho void fuse_fs_init_v30(struct fuse_fs* fs, struct fuse_conn_info* conn, struct fuse_config* cfg); 114 1.1 pho void fuse_fs_destroy(struct fuse_fs* fs); 115 1.1 pho 116 1.1 pho #ifdef __cplusplus 117 1.1 pho } 118 1.1 pho #endif 119 1.1 pho 120 1.1 pho #endif 121