1*41ce3b17Snaddy.\" $OpenBSD: fuse_new.3,v 1.7 2022/03/31 17:27:17 naddy Exp $ 28e7147f2Shelg.\" 38e7147f2Shelg.\" Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> 48e7147f2Shelg.\" Copyright (c) 2018 Helg Bredow <helg@openbsd.org> 58e7147f2Shelg.\" 68e7147f2Shelg.\" Permission to use, copy, modify, and distribute this software for any 78e7147f2Shelg.\" purpose with or without fee is hereby granted, provided that the above 88e7147f2Shelg.\" copyright notice and this permission notice appear in all copies. 98e7147f2Shelg.\" 108e7147f2Shelg.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 118e7147f2Shelg.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 128e7147f2Shelg.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 138e7147f2Shelg.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 148e7147f2Shelg.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 158e7147f2Shelg.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 168e7147f2Shelg.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 178e7147f2Shelg.\" 18*41ce3b17Snaddy.Dd $Mdocdate: March 31 2022 $ 198e7147f2Shelg.Dt FUSE_NEW 3 208e7147f2Shelg.Os 218e7147f2Shelg.Sh NAME 228e7147f2Shelg.Nm fuse_new 23c5d247d8Sjsg.Nd FUSE implementation routine to initialise the FUSE connection 248e7147f2Shelg.Sh SYNOPSIS 258e7147f2Shelg.In fuse.h 268e7147f2Shelg.Ft struct fuse * 278e7147f2Shelg.Fn fuse_new "struct fuse_chan *fc" "struct fuse_args *args" \ 288e7147f2Shelg "const struct fuse_operations *ops" "unused size_t size" \ 298e7147f2Shelg "void *userdata" 308e7147f2Shelg.Sh DESCRIPTION 318e7147f2ShelgInitialises the FUSE library on the channel returned by 328e7147f2Shelg.Xr fuse_mount 3 . 338e7147f2Shelg.Pp 348e7147f2ShelgFUSE operations work in the same way as their UNIX file system 35477ebe4aSjmccounterparts. 36477ebe4aSjmcA major exception is that these routines return 378e7147f2Shelga negated errno value (-errno) on failure. 388e7147f2Shelg.Pp 39477ebe4aSjmcAll operations are optional but a functional file system will want to 408e7147f2Shelgimplement at least statfs, readdir, open, read and getattr. 410d644658ShelgFUSE will return ENOSYS if any operation other than flush, fsync or 420d644658Shelgfsyncdir is not implemented. 430d644658Shelg.Pp 440d644658ShelgThe first parameter to each of these operations (except for init and 450d644658Shelgterminate) is a NULL terminated string representing the full path to 460d644658Shelgthe file or directory, relative to the root of this file system, that 470d644658Shelgis being operated on. 48477ebe4aSjmc.Bd -literal 498e7147f2Shelgstruct fuse_operations { 508e7147f2Shelg int (*getattr)(const char *, struct stat *); 518e7147f2Shelg int (*readlink)(const char *, char *, size_t); 528e7147f2Shelg int (*getdir)(const char *, fuse_dirh_t, fuse_dirfil_t); 538e7147f2Shelg int (*mknod)(const char *, mode_t, dev_t); 548e7147f2Shelg int (*mkdir)(const char *, mode_t); 558e7147f2Shelg int (*unlink)(const char *); 568e7147f2Shelg int (*rmdir)(const char *); 578e7147f2Shelg int (*symlink)(const char *, const char *); 588e7147f2Shelg int (*rename)(const char *, const char *); 598e7147f2Shelg int (*link)(const char *, const char *); 608e7147f2Shelg int (*chmod)(const char *, mode_t); 618e7147f2Shelg int (*chown)(const char *, uid_t, gid_t); 628e7147f2Shelg int (*truncate)(const char *, off_t); 638e7147f2Shelg int (*utime)(const char *, struct utimbuf *); 648e7147f2Shelg int (*open)(const char *, struct fuse_file_info *); 658e7147f2Shelg int (*read)(const char *, char *, size_t, off_t, 668e7147f2Shelg struct fuse_file_info *); 678e7147f2Shelg int (*write)(const char *, const char *, size_t, off_t, 688e7147f2Shelg struct fuse_file_info *); 698e7147f2Shelg int (*statfs)(const char *, struct statvfs *); 708e7147f2Shelg int (*flush)(const char *, struct fuse_file_info *); 718e7147f2Shelg int (*release)(const char *, struct fuse_file_info *); 728e7147f2Shelg int (*fsync)(const char *, int, struct fuse_file_info *); 738e7147f2Shelg int (*setxattr)(const char *, const char *, const char *, 748e7147f2Shelg size_t int); 758e7147f2Shelg int (*getxattr)(const char *, const char *, char *, size_t); 768e7147f2Shelg int (*listxattr)(const char *, char *, size_t); 778e7147f2Shelg int (*removexattr)(const char *, const char *); 788e7147f2Shelg int (*opendir)(const char *, struct fuse_file_info *); 798e7147f2Shelg int (*readdir)(const char *, void *, fuse_fill_dir_t, off_t, 808e7147f2Shelg struct fuse_file_info *); 818e7147f2Shelg int (*releasedir)(const char *, struct fuse_file_info *); 828e7147f2Shelg int (*fsyncdir)(const char *, int, struct fuse_file_info *); 838e7147f2Shelg void *(*init)(struct fuse_conn_info *); 848e7147f2Shelg void (*destroy)(void *); 858e7147f2Shelg int (*access)(const char *, int); 868e7147f2Shelg int (*create)(const char *, mode_t, struct fuse_file_info *); 878e7147f2Shelg int (*ftruncate)(const char *, off_t, struct fuse_file_info *); 888e7147f2Shelg int (*fgetattr)(const char *, struct stat *, struct 898e7147f2Shelg fuse_file_info *); 908e7147f2Shelg int (*lock)(const char *, struct fuse_file_info *, int, 918e7147f2Shelg struct flock *); 928e7147f2Shelg int (*utimens)(const char *, const struct timespec *); 938e7147f2Shelg int (*bmap)(const char *, size_t , uint64_t *); 948e7147f2Shelg}; 958e7147f2Shelg.Ed 968e7147f2Shelg.Pp 97477ebe4aSjmcThe order of calls is: 98477ebe4aSjmc.Bd -literal -offset indent 998e7147f2Shelginit 100477ebe4aSjmc\&... 1018e7147f2Shelgopendir 1028e7147f2Shelgreaddir 1038e7147f2Shelgreleasedir 1048e7147f2Shelgopen 1058e7147f2Shelgread 1068e7147f2Shelgwrite 107477ebe4aSjmc\&... 1088e7147f2Shelgflush 1098e7147f2Shelgrelease 110477ebe4aSjmc\&... 1118e7147f2Shelgdestroy 112477ebe4aSjmc.Ed 113477ebe4aSjmc.Bl -tag -width "releasedir" 1148e7147f2Shelg.It access 115477ebe4aSjmcNot implemented. 116477ebe4aSjmc.Ox 117477ebe4aSjmcalways behaves as if the default_permissions mount option was specified. 118477ebe4aSjmcSee 1198e7147f2Shelg.Xr fuse_mount 3 . 1208e7147f2Shelg.It chmod 1218e7147f2ShelgCalled when file access permissions are changed. 1228e7147f2Shelg.It chown 1238e7147f2ShelgCalled when either the file owner or group is changed. 1248e7147f2Shelg.It create 125477ebe4aSjmcNot implemented on 126477ebe4aSjmc.Ox . 127477ebe4aSjmcFile systems must implement mknod instead. 1288e7147f2ShelgIn the reference implementation this is an atomic operation that both 129477ebe4aSjmccreates and opens the file. 130477ebe4aSjmcThere is no equivalent in the 131477ebe4aSjmc.Ox 132477ebe4aSjmcVFS. 1330d644658Shelg.It flush 1340d644658ShelgCalled when the file is closed by the 1350d644658Shelg.Xr close 2 1360d644658Shelgsystem call. 1370d644658ShelgThis is the only way for a file system to return an error on close. 1380d644658Shelg.It fsync 1390d644658ShelgOptional function that implements 1400d644658Shelg.Xr fsync 2 1410d644658Shelgand 1420d644658Shelg.Xr fdatasync 2 . 1430d644658ShelgThe datasync parameter specifies whether the operation is as a result 1440d644658Shelgof a call to 1450d644658Shelg.Xr fdatasync 2 1460d644658Shelgand is currently always 0 (false). 1470d644658Shelgffi.fh_id will contain the file handle returned by the file system when 1480d644658Shelgthe file was opened. 1490d644658Shelg.It fsyncdir 1500d644658ShelgNot implemented. 1518e7147f2Shelg.It getattr 1528e7147f2ShelgCorresponds to the 1538e7147f2Shelg.Xr stat 2 154477ebe4aSjmcsystem call. 155477ebe4aSjmcFlags and extended attributes are ignored. 156477ebe4aSjmcThis operation is mandatory. 1578e7147f2Shelg.It getxattr 1588e7147f2ShelgNot implemented. 1598e7147f2Shelg.It getdir 160477ebe4aSjmcDeprecated. 161477ebe4aSjmcFile system should implement readdir instead. 1628e7147f2Shelg.It mknod 1638e7147f2ShelgCalled on 1648e7147f2Shelg.Xr open 2 1658e7147f2Shelgand 1668e7147f2Shelg.Xr mknod 2 1678e7147f2Shelgto create regular files, pipes and device special files. 1688e7147f2Shelg.It open 1698e7147f2ShelgCalled on 1708e7147f2Shelg.Xr open 2 . 171477ebe4aSjmcDue to the difference between FUSE and the 172477ebe4aSjmc.Ox 173477ebe4aSjmcVFS, 174477ebe4aSjmcopen will only be called once for each file 175477ebe4aSjmcfor every different combination of flags provided to 1768e7147f2Shelg.Xr open 2 . 1778e7147f2ShelgThe O_CREAT and O_TRUNC flags are never passed from the kernel to open, 1788e7147f2Shelgthe mknod and truncate operations are invoked before open instead. 1798e7147f2Shelg.It opendir 1808e7147f2ShelgCalled when a directory is opened for reading. 1818e7147f2Shelg.It release 182477ebe4aSjmcCalled when there are no more references to the file. 1838e7147f2Shelg.It releasedir 184477ebe4aSjmcCalled when there are no more references to the directory. 1858e7147f2Shelg.It setattr 1868e7147f2ShelgEquivalent to 1878e7147f2Shelg.Xr chown 2 1888e7147f2Shelgand 1898e7147f2Shelg.Xr chmod 2 190477ebe4aSjmcsystem calls. 191477ebe4aSjmcSetting file flags is not supported. 1928e7147f2Shelg.It setxattr 1938e7147f2ShelgNot implemented. 1948e7147f2Shelg.El 1958e7147f2Shelg.Pp 1968e7147f2ShelgOptions supported by args are: 197477ebe4aSjmc.Bl -tag -width "readdir_ino" 1988e7147f2Shelg.It debug, -d 1998e7147f2ShelgPrint debug information to stdout. 2008e7147f2Shelg.It gid=%u 201477ebe4aSjmcThe GID that will be reported as the group for all files by getattr. 2028e7147f2Shelg.It hard_remove 2038e7147f2ShelgImmediately delete a file even if it's currently open by a process. 2048e7147f2ShelgOtherwise FUSE will temporarily rename the file and only delete it when 205477ebe4aSjmcit is no longer referenced. 206477ebe4aSjmcThis is to avoid the file system having to deal with this situation. 207477ebe4aSjmcThis is always set on 208477ebe4aSjmc.Ox . 2098e7147f2Shelg.It readdir_ino 2108e7147f2ShelgSimilar to use_ino but the file system's inode number is only reported 211477ebe4aSjmcfor readdir. 212477ebe4aSjmcThis is always set on 2130d644658Shelg.Ox 2140d644658Shelgbecause it's required by 2150d644658Shelg.Xr getcwd 3 . 2168e7147f2Shelg.It uid=%u 217477ebe4aSjmcThe UID that will be reported as the owner for all files by getattr. 2188e7147f2Shelg.It umask=%o 2198e7147f2ShelgThe file mode mask applied to the permission for all files by getattr. 2208e7147f2Shelg.It use_ino 2218e7147f2ShelgBy default, FUSE will return an internal inode number for getattr and 2228e7147f2Shelgreaddir and this will be different every time the file system is 223477ebe4aSjmcmounted. 224*41ce3b17SnaddyIf this is set, the file system's own inode number will be 225477ebe4aSjmcreported instead. 226477ebe4aSjmcUseful only for file system that have inode numbers. 2278e7147f2Shelg.El 2288e7147f2Shelg.Sh SEE ALSO 2291094f1ecShelg.Xr fuse_get_context 3 , 2308e7147f2Shelg.Xr fuse_main 3 , 231477ebe4aSjmc.Xr fuse_mount 3 2328e7147f2Shelg.Sh STANDARDS 2338e7147f2ShelgThe 2348e7147f2Shelg.Fn fuse_new 2358e7147f2Shelgfunction conforms to FUSE 2.6. 2368e7147f2Shelg.Sh HISTORY 2378e7147f2ShelgThe 2388e7147f2Shelg.Fn fuse_new 2398e7147f2Shelgfunction first appeared in 2408e7147f2Shelg.Ox 5.4 . 2418e7147f2Shelg.Sh AUTHORS 2428e7147f2Shelg.An Sylvestre Gallon Aq Mt ccna.syl@gmail.com 2438e7147f2Shelg.An Helg Bredow Aq Mt helg@openbsd.org 244