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