Browse Source

libfuse cleanup: reindent

pull/809/head
Antonio SJ Musumeci 4 years ago
parent
commit
f9b831eb1a
  1. 109
      libfuse/include/fuse.h
  2. 8
      libfuse/include/fuse_common.h
  3. 3
      libfuse/include/fuse_common_compat.h
  4. 3
      libfuse/include/fuse_compat.h
  5. 10
      libfuse/include/fuse_dirents.h
  6. 18
      libfuse/include/fuse_lowlevel.h
  7. 6
      libfuse/include/fuse_lowlevel_compat.h
  8. 6
      libfuse/include/fuse_opt.h
  9. 10
      libfuse/include/fuse_timeouts.h
  10. 137
      libfuse/lib/fuse.c
  11. 16
      libfuse/lib/fuse_i.h
  12. 3
      libfuse/lib/fuse_mt.c
  13. 13
      libfuse/lib/fuse_opt.c
  14. 8
      libfuse/lib/fuse_session.c
  15. 1
      libfuse/lib/fuse_signals.c

109
libfuse/include/fuse.h

@ -70,7 +70,8 @@ struct fuse_cmd;
* See http://fuse.sourceforge.net/wiki/ for more information. There
* is also a snapshot of the relevant wiki pages in the doc/ folder.
*/
struct fuse_operations {
struct fuse_operations
{
/** Get file attributes.
*
* Similar to stat(). The 'st_dev' and 'st_blksize' fields are
@ -560,16 +561,14 @@ struct fuse_operations {
* Copy a range of data from one file to another
*
* Performs an optimized copy between two file descriptors without
* the
* additional cost of transferring data through the FUSE kernel
* module
* to user space (glibc) and then back into the FUSE filesystem
* the additional cost of transferring data through the FUSE kernel
* module to user space (glibc) and then back into the FUSE filesystem
* again.
*
* In case this method is not implemented, glibc falls back to
* reading
* data from the source and writing to the destination. Effectively
* doing an inefficient copy of the data.
* reading data from the source and writing to the
* destination. Effectively doing an inefficient copy of the
* data.
*/
ssize_t (*copy_file_range)(struct fuse_file_info *fi_in,
off_t offset_in,
@ -584,7 +583,8 @@ struct fuse_operations {
* The uid, gid and pid fields are not filled in case of a writepage
* operation.
*/
struct fuse_context {
struct fuse_context
{
/** Pointer to the fuse object */
struct fuse *fuse;
@ -682,17 +682,7 @@ int fuse_loop(struct fuse *f);
*/
void fuse_exit(struct fuse *f);
void fuse_config_set_entry_timeout(struct fuse *fuse_,
const double entry_timeout_);
void fuse_config_set_negative_entry_timeout(struct fuse *fuse_,
const double entry_timeout_);
void fuse_config_set_attr_timeout(struct fuse *fuse_,
const double attr_timeout_);
int fuse_config_num_threads(const struct fuse *fuse_);
double fuse_config_get_entry_timeout(const struct fuse *fuse_);
double fuse_config_get_negative_entry_timeout(const struct fuse *fuse_);
double fuse_config_get_attr_timeout(const struct fuse *fuse_);
/**
* FUSE event loop with multiple threads
@ -719,26 +709,6 @@ int fuse_loop_mt(struct fuse *f);
*/
struct fuse_context *fuse_get_context(void);
/**
* Get the current supplementary group IDs for the current request
*
* Similar to the getgroups(2) system call, except the return value is
* always the total number of group IDs, even if it is larger than the
* specified size.
*
* The current fuse kernel module in linux (as of 2.6.30) doesn't pass
* the group list to userspace, hence this function needs to parse
* "/proc/$TID/task/$TID/status" to get the group IDs.
*
* This feature may not be supported on all operating systems. In
* such a case this function will return -ENOSYS.
*
* @param size size of given array
* @param list array of group IDs to be filled in
* @return the total number of supplementary group IDs or -errno on failure
*/
int fuse_getgroups(int size, gid_t list[]);
/**
* Check if the current request has already been interrupted
*
@ -920,67 +890,6 @@ int fuse_notify_poll(struct fuse_pollhandle *ph);
struct fuse_fs *fuse_fs_new(const struct fuse_operations *op, size_t op_size,
void *user_data);
/**
* Filesystem module
*
* Filesystem modules are registered with the FUSE_REGISTER_MODULE()
* macro.
*
* If the "-omodules=modname:..." option is present, filesystem
* objects are created and pushed onto the stack with the 'factory'
* function.
*/
struct fuse_module {
/**
* Name of filesystem
*/
const char *name;
/**
* Factory for creating filesystem objects
*
* The function may use and remove options from 'args' that belong
* to this module.
*
* For now the 'fs' vector always contains exactly one filesystem.
* This is the filesystem which will be below the newly created
* filesystem in the stack.
*
* @param args the command line arguments
* @param fs NULL terminated filesystem object vector
* @return the new filesystem object
*/
struct fuse_fs *(*factory)(struct fuse_args *args,
struct fuse_fs *fs[]);
struct fuse_module *next;
struct fusemod_so *so;
int ctr;
};
/**
* Register a filesystem module
*
* This function is used by FUSE_REGISTER_MODULE and there's usually
* no need to call it directly
*/
void fuse_register_module(struct fuse_module *mod);
/**
* Register filesystem module
*
* For the parameters, see description of the fields in 'struct
* fuse_module'
*/
#define FUSE_REGISTER_MODULE(name_, factory_) \
static __attribute__((constructor)) void name_ ## _register(void) \
{ \
static struct fuse_module mod = \
{ #name_, factory_, NULL, NULL, 0 }; \
fuse_register_module(&mod); \
}
/* ----------------------------------------------------------- *
* Advanced API for event handling, don't worry about this... *
* ----------------------------------------------------------- */

8
libfuse/include/fuse_common.h

@ -16,6 +16,7 @@
#define _FUSE_COMMON_H_
#include "fuse_opt.h"
#include "fuse_timeouts.h"
#include <stdint.h>
#include <sys/types.h>
@ -40,13 +41,6 @@
extern "C" {
#endif
typedef struct fuse_timeouts_s fuse_timeouts_t;
struct fuse_timeouts_s
{
uint64_t entry;
uint64_t attr;
};
/**
* Information about open files
*

3
libfuse/include/fuse_common_compat.h

@ -9,7 +9,8 @@
/* these definitions provide source compatibility to prior versions.
Do not include this file directly! */
struct fuse_file_info_compat {
struct fuse_file_info_compat
{
int flags;
unsigned long fh;
int writepage;

3
libfuse/include/fuse_compat.h

@ -9,7 +9,8 @@
/* these definitions provide source compatibility to prior versions.
Do not include this file directly! */
struct fuse_operations_compat25 {
struct fuse_operations_compat25
{
int (*getattr) (const char *, struct stat *);
int (*readlink) (const char *, char *, size_t);
int (*mknod) (const char *, mode_t, dev_t);

10
libfuse/include/fuse_dirents.h

@ -18,9 +18,9 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "extern_c.h"
EXTERN_C_BEGIN
#include "kvec.h"
#include "fuse_dirent.h"
@ -79,6 +79,4 @@ void *fuse_dirents_find(fuse_dirents_t *d,
int fuse_dirents_convert_plus2normal(fuse_dirents_t *d);
#ifdef __cplusplus
}
#endif
EXTERN_C_END

18
libfuse/include/fuse_lowlevel.h

@ -66,7 +66,8 @@ struct fuse_session;
struct fuse_chan;
/** Directory entry parameters supplied to fuse_reply_entry() */
struct fuse_entry_param {
struct fuse_entry_param
{
/** Unique inode number
*
* In lookup, zero means negative entry (from version 2.5)
@ -105,7 +106,8 @@ struct fuse_entry_param {
};
/** Additional context associated with requests */
struct fuse_ctx {
struct fuse_ctx
{
/** User ID of the calling process */
uid_t uid;
@ -119,7 +121,8 @@ struct fuse_ctx {
mode_t umask;
};
struct fuse_forget_data {
struct fuse_forget_data
{
fuse_ino_t ino;
uint64_t nlookup;
};
@ -149,7 +152,8 @@ struct fuse_forget_data {
* fuse_reply_open() return -ENOENT means, that the release method for
* this file will not be called.
*/
struct fuse_lowlevel_ops {
struct fuse_lowlevel_ops
{
/**
* Initialize filesystem
*
@ -1536,7 +1540,8 @@ struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,
*
* This is used in session creation
*/
struct fuse_session_ops {
struct fuse_session_ops
{
/**
* Hook to process a request (mandatory)
*
@ -1718,7 +1723,8 @@ int fuse_session_loop_mt(struct fuse_session *se, const int threads);
*
* This is used in channel creation
*/
struct fuse_chan_ops {
struct fuse_chan_ops
{
/**
* Hook for receiving a raw request
*

6
libfuse/include/fuse_lowlevel_compat.h

@ -9,7 +9,8 @@
/* these definitions provide source compatibility to prior versions.
Do not include this file directly! */
struct fuse_lowlevel_ops_compat25 {
struct fuse_lowlevel_ops_compat25
{
void (*init) (void *userdata);
void (*destroy) (void *userdata);
void (*lookup) (fuse_req_t req, fuse_ino_t parent, const char *name);
@ -76,7 +77,8 @@ char *fuse_add_dirent(char *buf, const char *name, const struct stat *stbuf,
#include <sys/statfs.h>
struct fuse_lowlevel_ops_compat {
struct fuse_lowlevel_ops_compat
{
void (*init) (void *userdata);
void (*destroy) (void *userdata);
void (*lookup) (fuse_req_t req, fuse_ino_t parent, const char *name);

6
libfuse/include/fuse_opt.h

@ -73,7 +73,8 @@ extern "C" {
* If the format is "%s", memory is allocated for the string unlike
* with scanf().
*/
struct fuse_opt {
struct fuse_opt
{
/** Matching template and optional parameter formatting */
const char *templ;
@ -105,7 +106,8 @@ struct fuse_opt {
/**
* Argument list
*/
struct fuse_args {
struct fuse_args
{
/** Argument count */
int argc;

10
libfuse/include/fuse_timeouts.h

@ -0,0 +1,10 @@
#pragma once
#include <stdint.h>
typedef struct fuse_timeouts_s fuse_timeouts_t;
struct fuse_timeouts_s
{
uint64_t entry;
uint64_t attr;
};

137
libfuse/lib/fuse.c

@ -54,7 +54,8 @@
#define NODE_TABLE_MIN_SIZE 8192
struct fuse_config {
struct fuse_config
{
unsigned int uid;
unsigned int gid;
unsigned int umask;
@ -70,14 +71,16 @@ struct fuse_config {
int threads;
};
struct fuse_fs {
struct fuse_fs
{
struct fuse_operations op;
void *user_data;
int compat;
int debug;
};
struct lock_queue_element {
struct lock_queue_element
{
struct lock_queue_element *next;
pthread_cond_t cond;
fuse_ino_t nodeid1;
@ -94,7 +97,8 @@ struct lock_queue_element {
bool done : 1;
};
struct node_table {
struct node_table
{
struct node **array;
size_t use;
size_t size;
@ -108,12 +112,14 @@ struct node_table {
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
struct list_head {
struct list_head
{
struct list_head *next;
struct list_head *prev;
};
struct node_slab {
struct node_slab
{
struct list_head list; /* must be the first member */
struct list_head freelist;
int used;
@ -139,7 +145,8 @@ struct fuse
pthread_t prune_thread;
};
struct lock {
struct lock
{
int type;
off_t start;
off_t end;
@ -171,7 +178,8 @@ struct node
#define TREELOCK_WRITE -1
#define TREELOCK_WAIT_OFFSET INT_MIN
struct node_lru {
struct node_lru
{
struct node node;
struct list_head lru;
struct timespec forget_time;
@ -184,7 +192,8 @@ struct fuse_dh
fuse_dirents_t d;
};
struct fuse_context_i {
struct fuse_context_i
{
struct fuse_context ctx;
fuse_req_t req;
};
@ -193,18 +202,25 @@ static pthread_key_t fuse_context_key;
static pthread_mutex_t fuse_context_lock = PTHREAD_MUTEX_INITIALIZER;
static int fuse_context_ref;
static void init_list_head(struct list_head *list)
static
void
init_list_head(struct list_head *list)
{
list->next = list;
list->prev = list;
}
static int list_empty(const struct list_head *head)
static
int
list_empty(const struct list_head *head)
{
return head->next == head;
}
static void list_add(struct list_head *new, struct list_head *prev,
static
void
list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
next->prev = new;
@ -213,17 +229,28 @@ static void list_add(struct list_head *new, struct list_head *prev,
prev->next = new;
}
static inline void list_add_head(struct list_head *new, struct list_head *head)
static
inline
void
list_add_head(struct list_head *new,
struct list_head *head)
{
list_add(new, head, head->next);
}
static inline void list_add_tail(struct list_head *new, struct list_head *head)
static
inline
void
list_add_tail(struct list_head *new,
struct list_head *head)
{
list_add(new, head->prev, head);
}
static inline void list_del(struct list_head *entry)
static
inline
void
list_del(struct list_head *entry)
{
struct list_head *prev = entry->prev;
struct list_head *next = entry->next;
@ -232,17 +259,25 @@ static inline void list_del(struct list_head *entry)
prev->next = next;
}
static inline int lru_enabled(struct fuse *f)
static
inline
int
lru_enabled(struct fuse *f)
{
return f->conf.remember > 0;
}
static struct node_lru *node_lru(struct node *node)
static
struct
node_lru*
node_lru(struct node *node)
{
return (struct node_lru*)node;
}
static size_t get_node_size(struct fuse *f)
static
size_t
get_node_size(struct fuse *f)
{
if (lru_enabled(f))
return sizeof(struct node_lru);
@ -251,17 +286,23 @@ static size_t get_node_size(struct fuse *f)
}
#ifdef FUSE_NODE_SLAB
static struct node_slab *list_to_slab(struct list_head *head)
static
struct node_slab*
list_to_slab(struct list_head *head)
{
return (struct node_slab *) head;
}
static struct node_slab *node_to_slab(struct fuse *f, struct node *node)
static
struct node_slab*
node_to_slab(struct fuse *f, struct node *node)
{
return (struct node_slab *) (((uintptr_t) node) & ~((uintptr_t) f->pagesize - 1));
}
static int alloc_slab(struct fuse *f)
static
int
alloc_slab(struct fuse *f)
{
void *mem;
struct node_slab *slab;
@ -293,7 +334,9 @@ static int alloc_slab(struct fuse *f)
return 0;
}
static struct node *alloc_node(struct fuse *f)
static
struct node*
alloc_node(struct fuse *f)
{
struct node_slab *slab;
struct list_head *node;
@ -316,7 +359,10 @@ static struct node *alloc_node(struct fuse *f)
return (struct node *) node;
}
static void free_slab(struct fuse *f, struct node_slab *slab)
static
void
free_slab(struct fuse *f,
struct node_slab *slab)
{
int res;
@ -326,7 +372,10 @@ static void free_slab(struct fuse *f, struct node_slab *slab)
fprintf(stderr, "fuse warning: munmap(%p) failed\n", slab);
}
static void free_node_mem(struct fuse *f, struct node *node)
static
void
free_node_mem(struct fuse *f,
struct node *node)
{
struct node_slab *slab = node_to_slab(f, node);
struct list_head *n = (struct list_head *) node;
@ -343,19 +392,27 @@ static void free_node_mem(struct fuse *f, struct node *node)
}
}
#else
static struct node *alloc_node(struct fuse *f)
static
struct node*
alloc_node(struct fuse *f)
{
return (struct node *) calloc(1, get_node_size(f));
}
static void free_node_mem(struct fuse *f, struct node *node)
static
void
free_node_mem(struct fuse *f,
struct node *node)
{
(void) f;
free(node);
}
#endif
static size_t id_hash(struct fuse *f, fuse_ino_t ino)
static
size_t
id_hash(struct fuse *f,
fuse_ino_t ino)
{
uint64_t hash = ((uint32_t) ino * 2654435761U) % f->id_table.size;
uint64_t oldhash = hash % (f->id_table.size / 2);
@ -366,7 +423,10 @@ static size_t id_hash(struct fuse *f, fuse_ino_t ino)
return hash;
}
static struct node *get_node_nocheck(struct fuse *f, fuse_ino_t nodeid)
static
struct node*
get_node_nocheck(struct fuse *f,
fuse_ino_t nodeid)
{
size_t hash = id_hash(f, nodeid);
struct node *node;
@ -399,14 +459,19 @@ static void curr_time(struct timespec *now);
static double diff_timespec(const struct timespec *t1,
const struct timespec *t2);
static void remove_node_lru(struct node *node)
static
void
remove_node_lru(struct node *node)
{
struct node_lru *lnode = node_lru(node);
list_del(&lnode->lru);
init_list_head(&lnode->lru);
}
static void set_forget_time(struct fuse *f, struct node *node)
static
void
set_forget_time(struct fuse *f,
struct node *node)
{
struct node_lru *lnode = node_lru(node);
@ -429,7 +494,9 @@ free_node(struct fuse *f_,
free_node_mem(f_,node_);
}
static void node_table_reduce(struct node_table *t)
static
void
node_table_reduce(struct node_table *t)
{
size_t newsize = t->size / 2;
void *newarray;
@ -445,7 +512,9 @@ static void node_table_reduce(struct node_table *t)
t->split = t->size / 2;
}
static void remerge_id(struct fuse *f)
static
void
remerge_id(struct fuse *f)
{
struct node_table *t = &f->id_table;
int iter;
@ -471,7 +540,9 @@ static void remerge_id(struct fuse *f)
}
}
static void unhash_id(struct fuse *f, struct node *node)
static
void
unhash_id(struct fuse *f, struct node *node)
{
struct node **nodep = &f->id_table.array[id_hash(f, node->nodeid)];

16
libfuse/lib/fuse_i.h

@ -12,7 +12,8 @@
struct fuse_chan;
struct fuse_ll;
struct fuse_session {
struct fuse_session
{
struct fuse_session_ops op;
int (*receive_buf)(struct fuse_session *se, struct fuse_buf *buf,
@ -28,7 +29,8 @@ struct fuse_session {
struct fuse_chan *ch;
};
struct fuse_req {
struct fuse_req
{
struct fuse_ll *f;
uint64_t unique;
int ctr;
@ -50,7 +52,8 @@ struct fuse_req {
struct fuse_req *prev;
};
struct fuse_notify_req {
struct fuse_notify_req
{
uint64_t unique;
void (*reply)(struct fuse_notify_req *, fuse_req_t, fuse_ino_t,
const void *, const struct fuse_buf *);
@ -58,10 +61,10 @@ struct fuse_notify_req {
struct fuse_notify_req *prev;
};
struct fuse_ll {
struct fuse_ll
{
int debug;
int allow_root;
int atomic_o_trunc;
int no_remote_posix_lock;
int no_remote_flock;
int big_writes;
@ -87,7 +90,8 @@ struct fuse_ll {
struct fuse_notify_req notify_list;
};
struct fuse_cmd {
struct fuse_cmd
{
char *buf;
size_t buflen;
struct fuse_chan *ch;

3
libfuse/lib/fuse_mt.c

@ -16,7 +16,8 @@
#include <pthread.h>
#include <assert.h>
struct procdata {
struct procdata
{
struct fuse *f;
struct fuse_chan *prevch;
struct fuse_session *prevse;

13
libfuse/lib/fuse_opt.c

@ -14,7 +14,8 @@
#include <string.h>
#include <assert.h>
struct fuse_opt_context {
struct fuse_opt_context
{
void *data;
const struct fuse_opt *opt;
fuse_opt_proc_t proc;
@ -26,7 +27,8 @@ struct fuse_opt_context {
int nonopt;
};
void fuse_opt_free_args(struct fuse_args *args)
void
fuse_opt_free_args(struct fuse_args *args)
{
if (args) {
if (args->argv && args->allocated) {
@ -41,13 +43,16 @@ void fuse_opt_free_args(struct fuse_args *args)
}
}
static int alloc_failed(void)
static
int
alloc_failed(void)
{
fprintf(stderr, "fuse: memory allocation failed\n");
return -1;
}
int fuse_opt_add_arg(struct fuse_args *args, const char *arg)
int
fuse_opt_add_arg(struct fuse_args *args, const char *arg)
{
char **newargv;
char *newarg;

8
libfuse/lib/fuse_session.c

@ -17,17 +17,13 @@
#include <assert.h>
#include <errno.h>
struct fuse_chan {
struct fuse_chan
{
struct fuse_chan_ops op;
struct fuse_session *se;
int fd;
size_t bufsize;
void *data;
int compat;
};

1
libfuse/lib/fuse_signals.c

@ -69,4 +69,3 @@ void fuse_remove_signal_handlers(struct fuse_session *se)
set_one_signal_handler(SIGTERM, exit_handler, 1);
set_one_signal_handler(SIGPIPE, SIG_IGN, 1);
}
Loading…
Cancel
Save