Updating to fuse kernel version 7.19
This commit is contained in:
@ -1,13 +1,14 @@
|
||||
/* This file is taken from FUSE 2.5.3.
|
||||
From the two alternative licences the BSD licence has been chosen.
|
||||
#include and #ifdef directives have been removed.
|
||||
Modifications by Werner Baumann, 2009-04-14. */
|
||||
|
||||
|
||||
/* This file defines the kernel interface of FUSE */
|
||||
|
||||
/*
|
||||
Copyright (C) 2001-2006 Miklos Szeredi. All rights reserved.
|
||||
This file defines the kernel interface of FUSE
|
||||
Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU GPL.
|
||||
See the file COPYING.
|
||||
|
||||
This -- and only this -- header file may also be distributed under
|
||||
the terms of the BSD Licence as follows:
|
||||
|
||||
Copyright (C) 2001-2007 Miklos Szeredi. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -31,26 +32,98 @@
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file defines the kernel interface of FUSE
|
||||
*
|
||||
* Protocol changelog:
|
||||
*
|
||||
* 7.9:
|
||||
* - new fuse_getattr_in input argument of GETATTR
|
||||
* - add lk_flags in fuse_lk_in
|
||||
* - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in
|
||||
* - add blksize field to fuse_attr
|
||||
* - add file flags field to fuse_read_in and fuse_write_in
|
||||
*
|
||||
* 7.10
|
||||
* - add nonseekable open flag
|
||||
*
|
||||
* 7.11
|
||||
* - add IOCTL message
|
||||
* - add unsolicited notification support
|
||||
* - add POLL message and NOTIFY_POLL notification
|
||||
*
|
||||
* 7.12
|
||||
* - add umask flag to input argument of open, mknod and mkdir
|
||||
* - add notification messages for invalidation of inodes and
|
||||
* directory entries
|
||||
*
|
||||
* 7.13
|
||||
* - make max number of background requests and congestion threshold
|
||||
* tunables
|
||||
*
|
||||
* 7.14
|
||||
* - add splice support to fuse device
|
||||
*
|
||||
* 7.15
|
||||
* - add store notify
|
||||
* - add retrieve notify
|
||||
*
|
||||
* 7.16
|
||||
* - add BATCH_FORGET request
|
||||
* - FUSE_IOCTL_UNRESTRICTED shall now return with array of 'struct
|
||||
* fuse_ioctl_iovec' instead of ambiguous 'struct iovec'
|
||||
* - add FUSE_IOCTL_32BIT flag
|
||||
*
|
||||
* 7.17
|
||||
* - add FUSE_FLOCK_LOCKS and FUSE_RELEASE_FLOCK_UNLOCK
|
||||
*
|
||||
* 7.18
|
||||
* - add FUSE_IOCTL_DIR flag
|
||||
* - add FUSE_NOTIFY_DELETE
|
||||
*
|
||||
* 7.19
|
||||
* - add FUSE_FALLOCATE
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_FUSE_H
|
||||
#define _LINUX_FUSE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#define __u64 uint64_t
|
||||
#define __s64 int64_t
|
||||
#define __u32 uint32_t
|
||||
#define __s32 int32_t
|
||||
#define __u16 uint16_t
|
||||
|
||||
/*
|
||||
* Version negotiation:
|
||||
*
|
||||
* Both the kernel and userspace send the version they support in the
|
||||
* INIT request and reply respectively.
|
||||
*
|
||||
* If the major versions match then both shall use the smallest
|
||||
* of the two minor versions for communication.
|
||||
*
|
||||
* If the kernel supports a larger major version, then userspace shall
|
||||
* reply with the major version it supports, ignore the rest of the
|
||||
* INIT message and expect a new INIT message from the kernel with a
|
||||
* matching major version.
|
||||
*
|
||||
* If the library supports a larger major version, then it shall fall
|
||||
* back to the major protocol version sent by the kernel for
|
||||
* communication and reply with that major version (and an arbitrary
|
||||
* supported minor version).
|
||||
*/
|
||||
|
||||
/** Version number of this interface */
|
||||
#define FUSE_KERNEL_VERSION 7
|
||||
|
||||
/** Minor version number of this interface */
|
||||
#define FUSE_KERNEL_MINOR_VERSION 5
|
||||
#define FUSE_KERNEL_MINOR_VERSION 19
|
||||
|
||||
/** The node ID of the root inode */
|
||||
#define FUSE_ROOT_ID 1
|
||||
|
||||
/** The major number of the fuse character device */
|
||||
#define FUSE_MAJOR 10
|
||||
|
||||
/** The minor number of the fuse character device */
|
||||
#define FUSE_MINOR 229
|
||||
|
||||
/* Make sure all structures are padded to 64bit boundary, so 32bit
|
||||
userspace works under 64bit kernels */
|
||||
|
||||
@ -69,6 +142,8 @@ struct fuse_attr {
|
||||
__u32 uid;
|
||||
__u32 gid;
|
||||
__u32 rdev;
|
||||
__u32 blksize;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_kstatfs {
|
||||
@ -84,6 +159,16 @@ struct fuse_kstatfs {
|
||||
__u32 spare[6];
|
||||
};
|
||||
|
||||
struct fuse_file_lock {
|
||||
__u64 start;
|
||||
__u64 end;
|
||||
__u32 type;
|
||||
__u32 pid; /* tgid */
|
||||
};
|
||||
|
||||
/**
|
||||
* Bitmasks for fuse_setattr_in.valid
|
||||
*/
|
||||
#define FATTR_MODE (1 << 0)
|
||||
#define FATTR_UID (1 << 1)
|
||||
#define FATTR_GID (1 << 2)
|
||||
@ -91,15 +176,100 @@ struct fuse_kstatfs {
|
||||
#define FATTR_ATIME (1 << 4)
|
||||
#define FATTR_MTIME (1 << 5)
|
||||
#define FATTR_FH (1 << 6)
|
||||
#define FATTR_ATIME_NOW (1 << 7)
|
||||
#define FATTR_MTIME_NOW (1 << 8)
|
||||
#define FATTR_LOCKOWNER (1 << 9)
|
||||
|
||||
/**
|
||||
* Flags returned by the OPEN request
|
||||
*
|
||||
* FOPEN_DIRECT_IO: bypass page cache for this open file
|
||||
* FOPEN_KEEP_CACHE: don't invalidate the data cache on open
|
||||
* FOPEN_NONSEEKABLE: the file is not seekable
|
||||
*/
|
||||
#define FOPEN_DIRECT_IO (1 << 0)
|
||||
#define FOPEN_KEEP_CACHE (1 << 1)
|
||||
#define FOPEN_NONSEEKABLE (1 << 2)
|
||||
|
||||
/**
|
||||
* INIT request/reply flags
|
||||
*
|
||||
* FUSE_POSIX_LOCKS: remote locking for POSIX file locks
|
||||
* FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
|
||||
* FUSE_DONT_MASK: don't apply umask to file mode on create operations
|
||||
* FUSE_FLOCK_LOCKS: remote locking for BSD style file locks
|
||||
*/
|
||||
#define FUSE_ASYNC_READ (1 << 0)
|
||||
#define FUSE_POSIX_LOCKS (1 << 1)
|
||||
#define FUSE_FILE_OPS (1 << 2)
|
||||
#define FUSE_ATOMIC_O_TRUNC (1 << 3)
|
||||
#define FUSE_EXPORT_SUPPORT (1 << 4)
|
||||
#define FUSE_BIG_WRITES (1 << 5)
|
||||
#define FUSE_DONT_MASK (1 << 6)
|
||||
#define FUSE_FLOCK_LOCKS (1 << 10)
|
||||
|
||||
/**
|
||||
* CUSE INIT request/reply flags
|
||||
*
|
||||
* CUSE_UNRESTRICTED_IOCTL: use unrestricted ioctl
|
||||
*/
|
||||
#define CUSE_UNRESTRICTED_IOCTL (1 << 0)
|
||||
|
||||
/**
|
||||
* Release flags
|
||||
*/
|
||||
#define FUSE_RELEASE_FLUSH (1 << 0)
|
||||
#define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1)
|
||||
|
||||
/**
|
||||
* Getattr flags
|
||||
*/
|
||||
#define FUSE_GETATTR_FH (1 << 0)
|
||||
|
||||
/**
|
||||
* Lock flags
|
||||
*/
|
||||
#define FUSE_LK_FLOCK (1 << 0)
|
||||
|
||||
/**
|
||||
* WRITE flags
|
||||
*
|
||||
* FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed
|
||||
* FUSE_WRITE_LOCKOWNER: lock_owner field is valid
|
||||
*/
|
||||
#define FUSE_WRITE_CACHE (1 << 0)
|
||||
#define FUSE_WRITE_LOCKOWNER (1 << 1)
|
||||
|
||||
/**
|
||||
* Read flags
|
||||
*/
|
||||
#define FUSE_READ_LOCKOWNER (1 << 1)
|
||||
|
||||
/**
|
||||
* Ioctl flags
|
||||
*
|
||||
* FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
|
||||
* FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed
|
||||
* FUSE_IOCTL_RETRY: retry with new iovecs
|
||||
* FUSE_IOCTL_32BIT: 32bit ioctl
|
||||
* FUSE_IOCTL_DIR: is a directory
|
||||
*
|
||||
* FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
|
||||
*/
|
||||
#define FUSE_IOCTL_COMPAT (1 << 0)
|
||||
#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
|
||||
#define FUSE_IOCTL_RETRY (1 << 2)
|
||||
#define FUSE_IOCTL_32BIT (1 << 3)
|
||||
#define FUSE_IOCTL_DIR (1 << 4)
|
||||
|
||||
#define FUSE_IOCTL_MAX_IOV 256
|
||||
|
||||
/**
|
||||
* Poll flags
|
||||
*
|
||||
* FUSE_POLL_SCHEDULE_NOTIFY: request poll notify
|
||||
*/
|
||||
#define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
|
||||
|
||||
enum fuse_opcode {
|
||||
FUSE_LOOKUP = 1,
|
||||
@ -130,13 +300,38 @@ enum fuse_opcode {
|
||||
FUSE_READDIR = 28,
|
||||
FUSE_RELEASEDIR = 29,
|
||||
FUSE_FSYNCDIR = 30,
|
||||
FUSE_GETLK = 31,
|
||||
FUSE_SETLK = 32,
|
||||
FUSE_SETLKW = 33,
|
||||
FUSE_ACCESS = 34,
|
||||
FUSE_CREATE = 35
|
||||
FUSE_CREATE = 35,
|
||||
FUSE_INTERRUPT = 36,
|
||||
FUSE_BMAP = 37,
|
||||
FUSE_DESTROY = 38,
|
||||
FUSE_IOCTL = 39,
|
||||
FUSE_POLL = 40,
|
||||
FUSE_NOTIFY_REPLY = 41,
|
||||
FUSE_BATCH_FORGET = 42,
|
||||
FUSE_FALLOCATE = 43,
|
||||
|
||||
/* CUSE specific operations */
|
||||
CUSE_INIT = 4096,
|
||||
};
|
||||
|
||||
enum fuse_notify_code {
|
||||
FUSE_NOTIFY_POLL = 1,
|
||||
FUSE_NOTIFY_INVAL_INODE = 2,
|
||||
FUSE_NOTIFY_INVAL_ENTRY = 3,
|
||||
FUSE_NOTIFY_STORE = 4,
|
||||
FUSE_NOTIFY_RETRIEVE = 5,
|
||||
FUSE_NOTIFY_DELETE = 6,
|
||||
FUSE_NOTIFY_CODE_MAX,
|
||||
};
|
||||
|
||||
/* The read buffer is required to be at least 8k, but may be much larger */
|
||||
/* 2009-04-14, increased size of FUSE_MIN_READ_BUFFER, Werner Baumann */
|
||||
#define FUSE_MIN_READ_BUFFER 16384
|
||||
#define FUSE_MIN_READ_BUFFER 8192
|
||||
|
||||
#define FUSE_COMPAT_ENTRY_OUT_SIZE 120
|
||||
|
||||
struct fuse_entry_out {
|
||||
__u64 nodeid; /* Inode ID */
|
||||
@ -153,6 +348,24 @@ struct fuse_forget_in {
|
||||
__u64 nlookup;
|
||||
};
|
||||
|
||||
struct fuse_forget_one {
|
||||
__u64 nodeid;
|
||||
__u64 nlookup;
|
||||
};
|
||||
|
||||
struct fuse_batch_forget_in {
|
||||
__u32 count;
|
||||
__u32 dummy;
|
||||
};
|
||||
|
||||
struct fuse_getattr_in {
|
||||
__u32 getattr_flags;
|
||||
__u32 dummy;
|
||||
__u64 fh;
|
||||
};
|
||||
|
||||
#define FUSE_COMPAT_ATTR_OUT_SIZE 96
|
||||
|
||||
struct fuse_attr_out {
|
||||
__u64 attr_valid; /* Cache timeout for the attributes */
|
||||
__u32 attr_valid_nsec;
|
||||
@ -160,14 +373,18 @@ struct fuse_attr_out {
|
||||
struct fuse_attr attr;
|
||||
};
|
||||
|
||||
#define FUSE_COMPAT_MKNOD_IN_SIZE 8
|
||||
|
||||
struct fuse_mknod_in {
|
||||
__u32 mode;
|
||||
__u32 rdev;
|
||||
__u32 umask;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_mkdir_in {
|
||||
__u32 mode;
|
||||
__u32 padding;
|
||||
__u32 umask;
|
||||
};
|
||||
|
||||
struct fuse_rename_in {
|
||||
@ -183,7 +400,7 @@ struct fuse_setattr_in {
|
||||
__u32 padding;
|
||||
__u64 fh;
|
||||
__u64 size;
|
||||
__u64 unused1;
|
||||
__u64 lock_owner;
|
||||
__u64 atime;
|
||||
__u64 mtime;
|
||||
__u64 unused2;
|
||||
@ -198,8 +415,15 @@ struct fuse_setattr_in {
|
||||
};
|
||||
|
||||
struct fuse_open_in {
|
||||
__u32 flags;
|
||||
__u32 unused;
|
||||
};
|
||||
|
||||
struct fuse_create_in {
|
||||
__u32 flags;
|
||||
__u32 mode;
|
||||
__u32 umask;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_open_out {
|
||||
@ -211,27 +435,37 @@ struct fuse_open_out {
|
||||
struct fuse_release_in {
|
||||
__u64 fh;
|
||||
__u32 flags;
|
||||
__u32 padding;
|
||||
__u32 release_flags;
|
||||
__u64 lock_owner;
|
||||
};
|
||||
|
||||
struct fuse_flush_in {
|
||||
__u64 fh;
|
||||
__u32 flush_flags;
|
||||
__u32 unused;
|
||||
__u32 padding;
|
||||
__u64 lock_owner;
|
||||
};
|
||||
|
||||
struct fuse_read_in {
|
||||
__u64 fh;
|
||||
__u64 offset;
|
||||
__u32 size;
|
||||
__u32 read_flags;
|
||||
__u64 lock_owner;
|
||||
__u32 flags;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
#define FUSE_COMPAT_WRITE_IN_SIZE 24
|
||||
|
||||
struct fuse_write_in {
|
||||
__u64 fh;
|
||||
__u64 offset;
|
||||
__u32 size;
|
||||
__u32 write_flags;
|
||||
__u64 lock_owner;
|
||||
__u32 flags;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_write_out {
|
||||
@ -266,6 +500,18 @@ struct fuse_getxattr_out {
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_lk_in {
|
||||
__u64 fh;
|
||||
__u64 owner;
|
||||
struct fuse_file_lock lk;
|
||||
__u32 lk_flags;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_lk_out {
|
||||
struct fuse_file_lock lk;
|
||||
};
|
||||
|
||||
struct fuse_access_in {
|
||||
__u32 mask;
|
||||
__u32 padding;
|
||||
@ -274,15 +520,100 @@ struct fuse_access_in {
|
||||
struct fuse_init_in {
|
||||
__u32 major;
|
||||
__u32 minor;
|
||||
__u32 max_readahead;
|
||||
__u32 flags;
|
||||
};
|
||||
|
||||
struct fuse_init_out {
|
||||
__u32 major;
|
||||
__u32 minor;
|
||||
__u32 unused[3];
|
||||
__u32 max_readahead;
|
||||
__u32 flags;
|
||||
__u16 max_background;
|
||||
__u16 congestion_threshold;
|
||||
__u32 max_write;
|
||||
};
|
||||
|
||||
#define CUSE_INIT_INFO_MAX 4096
|
||||
|
||||
struct cuse_init_in {
|
||||
__u32 major;
|
||||
__u32 minor;
|
||||
__u32 unused;
|
||||
__u32 flags;
|
||||
};
|
||||
|
||||
struct cuse_init_out {
|
||||
__u32 major;
|
||||
__u32 minor;
|
||||
__u32 unused;
|
||||
__u32 flags;
|
||||
__u32 max_read;
|
||||
__u32 max_write;
|
||||
__u32 dev_major; /* chardev major */
|
||||
__u32 dev_minor; /* chardev minor */
|
||||
__u32 spare[10];
|
||||
};
|
||||
|
||||
struct fuse_interrupt_in {
|
||||
__u64 unique;
|
||||
};
|
||||
|
||||
struct fuse_bmap_in {
|
||||
__u64 block;
|
||||
__u32 blocksize;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_bmap_out {
|
||||
__u64 block;
|
||||
};
|
||||
|
||||
struct fuse_ioctl_in {
|
||||
__u64 fh;
|
||||
__u32 flags;
|
||||
__u32 cmd;
|
||||
__u64 arg;
|
||||
__u32 in_size;
|
||||
__u32 out_size;
|
||||
};
|
||||
|
||||
struct fuse_ioctl_iovec {
|
||||
__u64 base;
|
||||
__u64 len;
|
||||
};
|
||||
|
||||
struct fuse_ioctl_out {
|
||||
__s32 result;
|
||||
__u32 flags;
|
||||
__u32 in_iovs;
|
||||
__u32 out_iovs;
|
||||
};
|
||||
|
||||
struct fuse_poll_in {
|
||||
__u64 fh;
|
||||
__u64 kh;
|
||||
__u32 flags;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_poll_out {
|
||||
__u32 revents;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_notify_poll_wakeup_out {
|
||||
__u64 kh;
|
||||
};
|
||||
|
||||
struct fuse_fallocate_in {
|
||||
__u64 fh;
|
||||
__u64 offset;
|
||||
__u64 length;
|
||||
__u32 mode;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_in_header {
|
||||
__u32 len;
|
||||
__u32 opcode;
|
||||
@ -305,10 +636,56 @@ struct fuse_dirent {
|
||||
__u64 off;
|
||||
__u32 namelen;
|
||||
__u32 type;
|
||||
char name[0];
|
||||
char name[];
|
||||
};
|
||||
|
||||
#define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
|
||||
#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
|
||||
#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
|
||||
#define FUSE_DIRENT_SIZE(d) \
|
||||
FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
|
||||
|
||||
struct fuse_notify_inval_inode_out {
|
||||
__u64 ino;
|
||||
__s64 off;
|
||||
__s64 len;
|
||||
};
|
||||
|
||||
struct fuse_notify_inval_entry_out {
|
||||
__u64 parent;
|
||||
__u32 namelen;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_notify_delete_out {
|
||||
__u64 parent;
|
||||
__u64 child;
|
||||
__u32 namelen;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_notify_store_out {
|
||||
__u64 nodeid;
|
||||
__u64 offset;
|
||||
__u32 size;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
struct fuse_notify_retrieve_out {
|
||||
__u64 notify_unique;
|
||||
__u64 nodeid;
|
||||
__u64 offset;
|
||||
__u32 size;
|
||||
__u32 padding;
|
||||
};
|
||||
|
||||
/* Matches the size of fuse_write_in */
|
||||
struct fuse_notify_retrieve_in {
|
||||
__u64 dummy1;
|
||||
__u64 offset;
|
||||
__u32 size;
|
||||
__u32 dummy2;
|
||||
__u64 dummy3;
|
||||
__u64 dummy4;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_FUSE_H */
|
||||
|
@ -55,6 +55,9 @@
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include "xalloc.h"
|
||||
#include "xvasprintf.h"
|
||||
@ -74,6 +77,17 @@
|
||||
#endif
|
||||
|
||||
|
||||
/* Constants from Linux headers */
|
||||
/*==============================*/
|
||||
|
||||
#ifndef MISC_MAJOR
|
||||
#define MISC_MAJOR 10
|
||||
#endif
|
||||
#ifndef FUSE_MINOR
|
||||
#define FUSE_MINOR 229
|
||||
#endif
|
||||
|
||||
|
||||
/* Data Types */
|
||||
/*============*/
|
||||
|
||||
@ -92,6 +106,9 @@ struct create_out {
|
||||
kernel file system. */
|
||||
#define FUSE_DEV_NAME "fuse"
|
||||
|
||||
/* Minimum minor version of fuse. */
|
||||
#define FUSE_MIN_MINOR 13
|
||||
|
||||
|
||||
/* Private global variables */
|
||||
/*==========================*/
|
||||
@ -102,6 +119,14 @@ static int fuse_device;
|
||||
/* Buffer used for communication with the kernel module (in and out). */
|
||||
static size_t buf_size;
|
||||
static char *buf;
|
||||
/* Header of incomming calls. */
|
||||
static struct fuse_in_header *ih;
|
||||
/* Header of outgoing replies. */
|
||||
static struct fuse_out_header *oh;
|
||||
/* Start of upcall specific structure. */
|
||||
static char *upcall;
|
||||
/* Start of upcall specific reply structure. */
|
||||
static char *reply;
|
||||
|
||||
/* Time to wait for upcalls before calling dav_tidy_cache(). */
|
||||
static time_t idle_time;
|
||||
@ -161,6 +186,10 @@ fuse_stat(void);
|
||||
static uint32_t
|
||||
fuse_write(void);
|
||||
|
||||
static uint32_t
|
||||
not_implemented(const char *msg);
|
||||
|
||||
|
||||
/* Auxiliary functions. */
|
||||
|
||||
static off_t
|
||||
@ -183,12 +212,17 @@ dav_init_kernel_interface(const char *url, const char *mpoint,
|
||||
"Initializing kernel interface");
|
||||
|
||||
buf_size = args->buf_size * 1024;
|
||||
if (buf_size < (FUSE_MIN_READ_BUFFER + 4096))
|
||||
buf_size = FUSE_MIN_READ_BUFFER + 4096;
|
||||
if (buf_size < (FUSE_MIN_READ_BUFFER + 1024))
|
||||
buf_size = FUSE_MIN_READ_BUFFER + 1024;
|
||||
buf = malloc(buf_size);
|
||||
if (!buf)
|
||||
error(EXIT_FAILURE, errno, _("can't allocate message buffer"));
|
||||
|
||||
ih = (struct fuse_in_header *) buf;
|
||||
oh = (struct fuse_out_header *) buf;
|
||||
upcall = buf + sizeof(struct fuse_in_header);
|
||||
reply = buf + sizeof(struct fuse_out_header);
|
||||
|
||||
idle_time = args->delay_upload;
|
||||
|
||||
char *path = xasprintf("%s/%s", DAV_DEV_DIR, FUSE_DEV_NAME);
|
||||
@ -198,7 +232,7 @@ dav_init_kernel_interface(const char *url, const char *mpoint,
|
||||
fuse_device = open(path, O_RDWR | O_NONBLOCK);
|
||||
}
|
||||
if (fuse_device <= 0) {
|
||||
if (mknod(path, S_IFCHR, makedev(FUSE_MAJOR, FUSE_MINOR)) == 0) {
|
||||
if (mknod(path, S_IFCHR, makedev(MISC_MAJOR, FUSE_MINOR)) == 0) {
|
||||
if (chown(path, 0, 0) == 0 && chmod(path, S_IRUSR | S_IWUSR) == 0) {
|
||||
fuse_device = open(path, O_RDWR | O_NONBLOCK);
|
||||
} else {
|
||||
@ -214,7 +248,7 @@ dav_init_kernel_interface(const char *url, const char *mpoint,
|
||||
char *mdata = xasprintf("fd=%i,rootmode=%o,user_id=%i,group_id=%i,"
|
||||
"allow_other,max_read=%lu", fuse_device,
|
||||
args->dir_mode, args->fsuid, args->fsgid,
|
||||
(unsigned long int) (buf_size - 4096));
|
||||
(unsigned long int) (buf_size - 1024));
|
||||
|
||||
if (mount(url, mpoint, "fuse", args->mopts, mdata) != 0)
|
||||
error(EXIT_FAILURE, errno, _("mounting failed"));
|
||||
@ -273,8 +307,6 @@ dav_run_msgloop(volatile int *keep_on_running)
|
||||
break;
|
||||
}
|
||||
|
||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
if (ih->nodeid == 1)
|
||||
ih->nodeid = root;
|
||||
|
||||
@ -286,7 +318,6 @@ dav_run_msgloop(volatile int *keep_on_running)
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
"FUSE_FORGET: no reply");
|
||||
oh->error = 0;
|
||||
oh->len = 0;
|
||||
break;
|
||||
case FUSE_GETATTR:
|
||||
@ -296,16 +327,10 @@ dav_run_msgloop(volatile int *keep_on_running)
|
||||
oh->len = fuse_setattr();
|
||||
break;
|
||||
case FUSE_READLINK:
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_READLINK:");
|
||||
oh->error = -ENOSYS;
|
||||
oh->len = sizeof(struct fuse_out_header);
|
||||
oh->len = not_implemented("FUSE_READLINK:");
|
||||
break;
|
||||
case FUSE_SYMLINK:
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_SYMLINK:");
|
||||
oh->error = -ENOSYS;
|
||||
oh->len = sizeof(struct fuse_out_header);
|
||||
oh->len = not_implemented("FUSE_SYMLINK:");
|
||||
break;
|
||||
case FUSE_MKNOD:
|
||||
oh->len = fuse_mknod();
|
||||
@ -315,28 +340,30 @@ dav_run_msgloop(volatile int *keep_on_running)
|
||||
break;
|
||||
case FUSE_UNLINK:
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_UNLINK:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " p 0x%llx, %s",
|
||||
(unsigned long long) ih->nodeid,
|
||||
(char *) (buf + sizeof(struct fuse_in_header)));
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
"FUSE_UNLINK %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
}
|
||||
oh->error = dav_remove((dav_node *) ((size_t) ih->nodeid),
|
||||
(char *) (buf + sizeof(struct fuse_in_header)),
|
||||
ih->uid);
|
||||
oh->error = dav_remove((dav_node *) ((size_t) ih->nodeid), upcall,
|
||||
ih->uid);
|
||||
if (oh->error)
|
||||
oh->error *= -1;
|
||||
oh->len = sizeof(struct fuse_out_header);
|
||||
break;
|
||||
case FUSE_RMDIR:
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_RMDIR:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " p 0x%llx, %s",
|
||||
(unsigned long long) ih->nodeid,
|
||||
(char *) (buf + sizeof(struct fuse_in_header)));
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
"FUSE_RMDIR %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
}
|
||||
oh->error = dav_rmdir((dav_node *) ((size_t) ih->nodeid),
|
||||
(char *) (buf + sizeof(struct fuse_in_header)),
|
||||
ih->uid);
|
||||
oh->error = dav_rmdir((dav_node *) ((size_t) ih->nodeid), upcall,
|
||||
ih->uid);
|
||||
if (oh->error)
|
||||
oh->error *= -1;
|
||||
oh->len = sizeof(struct fuse_out_header);
|
||||
@ -345,10 +372,7 @@ dav_run_msgloop(volatile int *keep_on_running)
|
||||
oh->len = fuse_rename();
|
||||
break;
|
||||
case FUSE_LINK:
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_LINK:");
|
||||
oh->error = -ENOSYS;
|
||||
oh->len = sizeof(struct fuse_out_header);
|
||||
oh->len = not_implemented("FUSE_LINK:");
|
||||
break;
|
||||
case FUSE_OPEN:
|
||||
oh->len = fuse_open();
|
||||
@ -368,9 +392,12 @@ dav_run_msgloop(volatile int *keep_on_running)
|
||||
break;
|
||||
case FUSE_FSYNC:
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_FSYNC:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n 0x%llx",
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
"FUSE_FSYNC %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
}
|
||||
oh->error = dav_sync((dav_node *) ((size_t) ih->nodeid));
|
||||
if (oh->error)
|
||||
@ -378,28 +405,16 @@ dav_run_msgloop(volatile int *keep_on_running)
|
||||
oh->len = sizeof(struct fuse_out_header);
|
||||
break;
|
||||
case FUSE_SETXATTR:
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_SETXATTR:");
|
||||
oh->error = -ENOSYS;
|
||||
oh->len = sizeof(struct fuse_out_header);
|
||||
oh->len = not_implemented("FUSE_SETXATTR:");
|
||||
break;
|
||||
case FUSE_GETXATTR:
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_GETXATTR:");
|
||||
oh->error = -ENOSYS;
|
||||
oh->len = sizeof(struct fuse_out_header);
|
||||
oh->len = not_implemented("FUSE_GETXATTR:");
|
||||
break;
|
||||
case FUSE_LISTXATTR:
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_LISTXATTR:");
|
||||
oh->error = -ENOSYS;
|
||||
oh->len = sizeof(struct fuse_out_header);
|
||||
oh->len = not_implemented("FUSE_LISTXATTR:");
|
||||
break;
|
||||
case FUSE_REMOVEXATTR:
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_REMOVEXATTR:");
|
||||
oh->error = -ENOSYS;
|
||||
oh->len = sizeof(struct fuse_out_header);
|
||||
oh->len = not_implemented("FUSE_REMOVEXATTR:");
|
||||
break;
|
||||
case FUSE_FLUSH:
|
||||
if (debug)
|
||||
@ -421,10 +436,16 @@ dav_run_msgloop(volatile int *keep_on_running)
|
||||
oh->len = fuse_release();
|
||||
break;
|
||||
case FUSE_FSYNCDIR:
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_FSYNCDIR:");
|
||||
oh->error = -ENOSYS;
|
||||
oh->len = sizeof(struct fuse_out_header);
|
||||
oh->len = not_implemented("FUSE_FSYNCDIR:");
|
||||
break;
|
||||
case FUSE_GETLK:
|
||||
oh->len = not_implemented("FUSE_GETLK:");
|
||||
break;
|
||||
case FUSE_SETLK:
|
||||
oh->len = not_implemented("FUSE_SETLK:");
|
||||
break;
|
||||
case FUSE_SETLKW:
|
||||
oh->len = not_implemented("FUSE_SETLKW:");
|
||||
break;
|
||||
case FUSE_ACCESS:
|
||||
oh->len = fuse_access();
|
||||
@ -432,6 +453,30 @@ dav_run_msgloop(volatile int *keep_on_running)
|
||||
case FUSE_CREATE:
|
||||
oh->len = fuse_create();
|
||||
break;
|
||||
case FUSE_INTERRUPT:
|
||||
oh->len = not_implemented("FUSE_INTERRUPT:");
|
||||
break;
|
||||
case FUSE_BMAP:
|
||||
oh->len = not_implemented("FUSE_BMAP:");
|
||||
break;
|
||||
case FUSE_DESTROY:
|
||||
oh->len = not_implemented("FUSE_DESTROY:");
|
||||
break;
|
||||
case FUSE_IOCTL:
|
||||
oh->len = not_implemented("FUSE_IOCTL:");
|
||||
break;
|
||||
case FUSE_POLL:
|
||||
oh->len = not_implemented("FUSE_POLL:");
|
||||
break;
|
||||
case FUSE_NOTIFY_REPLY:
|
||||
oh->len = not_implemented("FUSE_NOTIFY_REPLY:");
|
||||
break;
|
||||
case FUSE_BATCH_FORGET:
|
||||
oh->len = not_implemented("FUSE_BATCH_FORGET:");
|
||||
break;
|
||||
case FUSE_FALLOCATE:
|
||||
oh->len = not_implemented("FUSE_FALLOCATE:");
|
||||
break;
|
||||
default:
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
@ -478,15 +523,16 @@ dav_run_msgloop(volatile int *keep_on_running)
|
||||
static uint32_t
|
||||
fuse_access(void)
|
||||
{
|
||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
||||
struct fuse_access_in *in = (struct fuse_access_in *)
|
||||
(buf + sizeof(struct fuse_in_header));
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_access_in *in = (struct fuse_access_in *) upcall;
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_ACCESS:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n 0x%llx, f 0%o",
|
||||
(unsigned long long) ih->nodeid, in->mask);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " uid %i", ih->uid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_ACCESS %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " m=0x%x",
|
||||
in->mask);
|
||||
}
|
||||
|
||||
oh->error = dav_access((dav_node *) ((size_t) ih->nodeid), ih->uid,
|
||||
@ -502,18 +548,18 @@ fuse_access(void)
|
||||
static uint32_t
|
||||
fuse_create(void)
|
||||
{
|
||||
struct fuse_in_header *ih= (struct fuse_in_header *) buf;
|
||||
struct fuse_open_in *in = (struct fuse_open_in *)
|
||||
(buf + sizeof(struct fuse_in_header));
|
||||
char *name = buf + sizeof(struct fuse_in_header)
|
||||
+ sizeof(struct fuse_open_in);
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct create_out *out = (struct create_out *)
|
||||
(buf + sizeof(struct fuse_out_header));
|
||||
struct fuse_create_in *in = (struct fuse_create_in *) upcall;
|
||||
char *name = upcall + sizeof(struct fuse_create_in);
|
||||
struct create_out *out = (struct create_out *) reply;
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_CREATE:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n 0x%llx, f 0%o",
|
||||
(unsigned long long) ih->nodeid, in->flags);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_CREATE %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " f=0x%x m=0%o um=0%o",
|
||||
in->flags, in->mode, in->umask);
|
||||
}
|
||||
|
||||
int created = 0;
|
||||
@ -570,6 +616,7 @@ fuse_create(void)
|
||||
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " fd %i", fd);
|
||||
|
||||
return sizeof(struct fuse_out_header) + sizeof(struct create_out);
|
||||
}
|
||||
|
||||
@ -577,14 +624,17 @@ fuse_create(void)
|
||||
static uint32_t
|
||||
fuse_getattr(void)
|
||||
{
|
||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_attr_out *out = (struct fuse_attr_out *)
|
||||
(buf + sizeof(struct fuse_out_header));
|
||||
struct fuse_getattr_in *in = (struct fuse_getattr_in *) upcall;
|
||||
struct fuse_attr_out *out = (struct fuse_attr_out *) reply;
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_GETATTR:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n 0x%llx",
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_GETATTR %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " f=0x%x fh=%llu",
|
||||
in->getattr_flags, in->fh);
|
||||
}
|
||||
|
||||
oh->error = dav_getattr((dav_node *) ((size_t) ih->nodeid), ih->uid);
|
||||
@ -606,16 +656,33 @@ fuse_getattr(void)
|
||||
static uint32_t
|
||||
fuse_init(void)
|
||||
{
|
||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
||||
struct fuse_init_in *in = (struct fuse_init_in *)
|
||||
(buf + sizeof(struct fuse_in_header));
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_init_out *out = (struct fuse_init_out *)
|
||||
(buf + sizeof(struct fuse_out_header));
|
||||
struct fuse_init_in *in = (struct fuse_init_in *) upcall;
|
||||
struct fuse_init_out *out = (struct fuse_init_out *) reply;
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_INIT:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " version %i.%i",
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_INIT %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " verson=%u.%u",
|
||||
in->major, in->minor);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " ra=%u f=0x%x",
|
||||
in->max_readahead, in->flags);
|
||||
}
|
||||
|
||||
if (in->major < FUSE_KERNEL_VERSION
|
||||
|| (in->major == FUSE_KERNEL_VERSION && in->minor < FUSE_MIN_MINOR)) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
"FATAL: Kernel-version too old.");
|
||||
oh->error = -ENOSYS;
|
||||
return sizeof(struct fuse_out_header);
|
||||
}
|
||||
|
||||
if (in->major > FUSE_KERNEL_VERSION) {
|
||||
oh->error = 0;
|
||||
out->major = FUSE_KERNEL_VERSION;
|
||||
return sizeof(struct fuse_out_header);
|
||||
}
|
||||
|
||||
dav_node *node;
|
||||
@ -630,12 +697,16 @@ fuse_init(void)
|
||||
|
||||
root = (size_t) node;
|
||||
out->major = FUSE_KERNEL_VERSION;
|
||||
out->minor = FUSE_KERNEL_MINOR_VERSION;
|
||||
out->unused[0] = 0;
|
||||
out->unused[1] = 0;
|
||||
out->unused[2] = 0;
|
||||
out->max_write = buf_size - sizeof(struct fuse_in_header)
|
||||
- sizeof(struct fuse_write_in) - 4095;
|
||||
if (in->minor > FUSE_KERNEL_MINOR_VERSION) {
|
||||
out->minor = FUSE_KERNEL_MINOR_VERSION;
|
||||
} else {
|
||||
out->minor = in->minor;
|
||||
}
|
||||
out->max_readahead = 0;
|
||||
out->flags = 0;
|
||||
out->max_background = 0;
|
||||
out->congestion_threshold = 0;
|
||||
out->max_write = buf_size - 1024;
|
||||
|
||||
return sizeof(struct fuse_out_header) + sizeof(struct fuse_init_out);
|
||||
}
|
||||
@ -644,15 +715,16 @@ fuse_init(void)
|
||||
static uint32_t
|
||||
fuse_lookup(void)
|
||||
{
|
||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
||||
char * name = (char *) (buf + sizeof(struct fuse_in_header));
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_entry_out *out = (struct fuse_entry_out *)
|
||||
(buf + sizeof(struct fuse_out_header));
|
||||
char * name = upcall;
|
||||
struct fuse_entry_out *out = (struct fuse_entry_out *) reply;
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_LOOKUP:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " p 0x%llx, %s",
|
||||
(unsigned long long) ih->nodeid, name);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_LOOKUP %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " %s", name);
|
||||
}
|
||||
|
||||
dav_node *node = NULL;
|
||||
@ -666,7 +738,7 @@ fuse_lookup(void)
|
||||
return sizeof(struct fuse_out_header);
|
||||
}
|
||||
|
||||
out->nodeid = (size_t) node;
|
||||
out->nodeid = (uint64_t) ((size_t) node);
|
||||
out->generation = out->nodeid;
|
||||
out->entry_valid = 1;
|
||||
out->attr_valid = 1;
|
||||
@ -681,18 +753,18 @@ fuse_lookup(void)
|
||||
static uint32_t
|
||||
fuse_mkdir(void)
|
||||
{
|
||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
||||
struct fuse_mkdir_in *in = (struct fuse_mkdir_in *)
|
||||
(buf + sizeof(struct fuse_in_header));
|
||||
char *name = (char *) (buf + sizeof(struct fuse_in_header)
|
||||
+ sizeof(struct fuse_mkdir_in));
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_entry_out *out = (struct fuse_entry_out *)
|
||||
(buf + sizeof(struct fuse_out_header));
|
||||
struct fuse_mkdir_in *in = (struct fuse_mkdir_in *) upcall;
|
||||
char *name = upcall + sizeof(struct fuse_mkdir_in);
|
||||
struct fuse_entry_out *out = (struct fuse_entry_out *) reply;
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_MKDIR:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " p 0x%llx, %s",
|
||||
(unsigned long long) ih->nodeid, name);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_MKDIR %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " m=0%o um=0%o %s",
|
||||
in->mode, in->umask, name);
|
||||
}
|
||||
|
||||
dav_node *node = NULL;
|
||||
@ -721,18 +793,18 @@ fuse_mkdir(void)
|
||||
static uint32_t
|
||||
fuse_mknod(void)
|
||||
{
|
||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
||||
struct fuse_mknod_in *in = (struct fuse_mknod_in *)
|
||||
(buf + sizeof(struct fuse_in_header));
|
||||
char *name = (char *) (buf + sizeof(struct fuse_in_header)
|
||||
+ sizeof(struct fuse_mknod_in));
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_entry_out *out = (struct fuse_entry_out *)
|
||||
(buf + sizeof(struct fuse_out_header));
|
||||
struct fuse_mknod_in *in = (struct fuse_mknod_in *) upcall;
|
||||
char *name = upcall + sizeof(struct fuse_mknod_in);
|
||||
struct fuse_entry_out *out = (struct fuse_entry_out *) reply;
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_MKNOD:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " p 0x%llx, m 0%o",
|
||||
(unsigned long long) ih->nodeid, in->mode);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_MKNOD %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " m=0%o r=%u um=0%o",
|
||||
in->mode, in->rdev, in->umask);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " %s", name);
|
||||
}
|
||||
|
||||
@ -767,20 +839,24 @@ fuse_mknod(void)
|
||||
static uint32_t
|
||||
fuse_open(void)
|
||||
{
|
||||
struct fuse_in_header *ih= (struct fuse_in_header *) buf;
|
||||
struct fuse_open_in *in = (struct fuse_open_in *)
|
||||
(buf + sizeof(struct fuse_in_header));
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_open_out *out = (struct fuse_open_out *)
|
||||
(buf + sizeof(struct fuse_out_header));
|
||||
struct fuse_open_in *in = (struct fuse_open_in *) upcall;
|
||||
struct fuse_open_out *out = (struct fuse_open_out *) reply;
|
||||
|
||||
if (debug) {
|
||||
if (ih->opcode == FUSE_OPENDIR) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_OPENDIR:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
"FUSE_OPENDIR %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
} else {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_OPEN:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
"FUSE_OPEN %llu: n=0x%llx",
|
||||
(unsigned long long) ih-> unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
}
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n 0x%llx, f 0%o",
|
||||
(unsigned long long) ih->nodeid, in->flags);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " f=0x%x", in->flags);
|
||||
}
|
||||
|
||||
int fd = 0;
|
||||
@ -800,6 +876,7 @@ fuse_open(void)
|
||||
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " fd %i", fd);
|
||||
|
||||
return sizeof(struct fuse_out_header) + sizeof(struct fuse_open_out);
|
||||
}
|
||||
|
||||
@ -807,21 +884,27 @@ fuse_open(void)
|
||||
static uint32_t
|
||||
fuse_read(void)
|
||||
{
|
||||
struct fuse_in_header *ih= (struct fuse_in_header *) buf;
|
||||
struct fuse_read_in *in = (struct fuse_read_in *)
|
||||
(buf + sizeof(struct fuse_in_header));
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_read_in *in = (struct fuse_read_in *) upcall;
|
||||
|
||||
if (debug) {
|
||||
if (ih->opcode == FUSE_READDIR) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_READDIR:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
"FUSE_READDIR %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
} else {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_READ:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
"FUSE_READ %llu: n=0x%llx",
|
||||
(unsigned long long) ih-> unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
}
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n 0x%llx, fd %llu",
|
||||
(unsigned long long) ih->nodeid, (unsigned long long) in->fh);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " pid %i", ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " size %u, off %llu",
|
||||
in->size, (unsigned long long) in->offset);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " fh=%llu, off=%llu, sz=%u",
|
||||
(unsigned long long) in->fh, (unsigned long long) in->offset,
|
||||
in->size);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " rf=0x%x, f=0x%x",
|
||||
in->read_flags, in->flags);
|
||||
}
|
||||
|
||||
if (in->size > (buf_size - sizeof(struct fuse_out_header))) {
|
||||
@ -831,8 +914,7 @@ fuse_read(void)
|
||||
|
||||
ssize_t len;
|
||||
oh->error = dav_read(&len, (dav_node *) ((size_t) ih->nodeid),
|
||||
in->fh, buf + sizeof(struct fuse_out_header),
|
||||
in->size, in->offset);
|
||||
in->fh, reply, in->size, in->offset);
|
||||
|
||||
if (oh->error)
|
||||
oh->error *= -1;
|
||||
@ -844,20 +926,24 @@ fuse_read(void)
|
||||
static uint32_t
|
||||
fuse_release(void)
|
||||
{
|
||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
||||
struct fuse_release_in *in = (struct fuse_release_in *)
|
||||
(buf + sizeof(struct fuse_in_header));
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_release_in *in = (struct fuse_release_in *) upcall;
|
||||
|
||||
if (debug) {
|
||||
if (ih->opcode == FUSE_RELEASEDIR) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_RELEASEDIR:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
"FUSE_RELEASEDIR %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
} else {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_RELEASE:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG),
|
||||
"FUSE_RELEASE %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
}
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n 0x%llx, f 0%o",
|
||||
(unsigned long long) ih->nodeid, in->flags);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " pid %i, fd %llu",
|
||||
ih->pid, (unsigned long long) in->fh);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " fh=%llu, f=0x%x, rf=0x%x",
|
||||
(unsigned long long) in->fh, in->flags, in->release_flags);
|
||||
}
|
||||
|
||||
oh->error = dav_close((dav_node *) ((size_t) ih->nodeid), in->fh,
|
||||
@ -873,18 +959,18 @@ fuse_release(void)
|
||||
static uint32_t
|
||||
fuse_rename(void)
|
||||
{
|
||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
||||
struct fuse_rename_in *in = (struct fuse_rename_in *)
|
||||
(buf + sizeof(struct fuse_in_header));
|
||||
char *old = (char *) (buf + sizeof(struct fuse_in_header)
|
||||
+ sizeof(struct fuse_rename_in));
|
||||
struct fuse_rename_in *in = (struct fuse_rename_in *) upcall;
|
||||
char *old = upcall + sizeof(struct fuse_rename_in);
|
||||
char *new = old + strlen(old) + 1;
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_RENAME:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " sp 0x%llx, %s",
|
||||
(unsigned long long) ih->nodeid, old);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " dp 0x%llx, %s",
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_RENAME %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " %s", old);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n=0x%llx %s",
|
||||
(unsigned long long) in->newdir, new);
|
||||
}
|
||||
|
||||
@ -903,22 +989,21 @@ fuse_rename(void)
|
||||
static uint32_t
|
||||
fuse_setattr(void)
|
||||
{
|
||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
||||
struct fuse_setattr_in *in = (struct fuse_setattr_in *)
|
||||
(buf + sizeof(struct fuse_in_header));
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_attr_out *out = (struct fuse_attr_out *)
|
||||
(buf + sizeof(struct fuse_out_header));
|
||||
struct fuse_setattr_in *in = (struct fuse_setattr_in *) upcall;
|
||||
struct fuse_attr_out *out = (struct fuse_attr_out *) reply;
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_SETATTR:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n 0x%llx, m 0%o",
|
||||
(unsigned long long) ih->nodeid, in->mode);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " uid %i, gid %i",
|
||||
in->uid, in->gid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " sz %llu, at %llu,",
|
||||
(unsigned long long) in->size, (unsigned long long) in->atime);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " mt %llu",
|
||||
(unsigned long long) in->mtime);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_SETATTR %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " v=0x%x sz=%llu",
|
||||
in->valid, (unsigned long long) in->size);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " at=%llu mt=%llu",
|
||||
(unsigned long long) in->atime, (unsigned long long) in->mtime);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " m=0%o uid=%u gid=%u",
|
||||
in->mode, in->uid, in->gid);
|
||||
}
|
||||
|
||||
oh->error = dav_setattr((dav_node *) ((size_t) ih->nodeid), ih->uid,
|
||||
@ -946,11 +1031,15 @@ fuse_setattr(void)
|
||||
static uint32_t
|
||||
fuse_stat(void)
|
||||
{
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_statfs_out *out = (struct fuse_statfs_out *)
|
||||
(buf + sizeof(struct fuse_out_header));
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_STATFS:");
|
||||
struct fuse_statfs_out *out = (struct fuse_statfs_out *) reply;
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_STATFS %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
}
|
||||
|
||||
dav_stat *st = dav_statfs();
|
||||
if (!st) {
|
||||
@ -988,20 +1077,20 @@ fuse_stat(void)
|
||||
static uint32_t
|
||||
fuse_write(void)
|
||||
{
|
||||
struct fuse_in_header *ih= (struct fuse_in_header *) buf;
|
||||
struct fuse_write_in *in = (struct fuse_write_in *)
|
||||
(buf + sizeof(struct fuse_in_header));
|
||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
||||
struct fuse_write_out *out = (struct fuse_write_out *)
|
||||
(buf + sizeof(struct fuse_out_header));
|
||||
struct fuse_write_in *in = (struct fuse_write_in *) upcall;
|
||||
struct fuse_write_out *out = (struct fuse_write_out *) reply;
|
||||
|
||||
if (debug) {
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_WRITE:");
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n 0x%llx, fd %llu",
|
||||
(unsigned long long) ih->nodeid, (unsigned long long) in->fh);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " pid %i, flags 0%o",
|
||||
ih->pid, in->write_flags);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " size %u, off %llu",
|
||||
in->size, (unsigned long long) in->offset);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_WRITE %llu: n=0x%llx",
|
||||
(unsigned long long) ih->unique,
|
||||
(unsigned long long) ih->nodeid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " u=%u g=%u p=%u",
|
||||
ih->uid, ih->gid, ih->pid);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " fh=%llu, off=%llu, sz=%u",
|
||||
(unsigned long long) in->fh, (unsigned long long) in->offset,
|
||||
in->size);
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " wf=0x%x, f=0x%x",
|
||||
in->write_flags, in->flags);
|
||||
}
|
||||
|
||||
if (in->size > (buf_size - sizeof(struct fuse_in_header)
|
||||
@ -1012,8 +1101,7 @@ fuse_write(void)
|
||||
|
||||
size_t size;
|
||||
oh->error = dav_write(&size, (dav_node *) ((size_t) ih->nodeid),
|
||||
in->fh, buf + sizeof(struct fuse_in_header)
|
||||
+ sizeof(struct fuse_write_in),
|
||||
in->fh, upcall + sizeof(struct fuse_write_in),
|
||||
in->size, in->offset);
|
||||
|
||||
if (oh->error) {
|
||||
@ -1027,6 +1115,17 @@ fuse_write(void)
|
||||
return sizeof(struct fuse_out_header) + sizeof(struct fuse_write_out);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
not_implemented(const char *msg)
|
||||
{
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "%s", msg);
|
||||
|
||||
oh->error = -ENOSYS;
|
||||
|
||||
return sizeof(struct fuse_out_header);
|
||||
}
|
||||
|
||||
|
||||
/* Auxiliary functions. */
|
||||
|
||||
@ -1101,4 +1200,7 @@ set_attr(struct fuse_attr *attr, const dav_node *node)
|
||||
attr->uid = node->uid;
|
||||
attr->gid = node->gid;
|
||||
attr->rdev = 0;
|
||||
/* TODO: set blocksize */
|
||||
attr->blksize = 0;
|
||||
attr->padding = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user