aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Pärtel <martin.partel@gmail.com>2023-11-27 23:35:41 +0200
committerGitHub <noreply@github.com>2023-11-27 23:35:41 +0200
commit2b5f2e24527f04f4255161965ae4099192714b73 (patch)
treeb8edd8485dfcd64c68b12da4221a356acd54a0fa /src
parent47f4cac457c3583548c0d7dba402568a1e0871b8 (diff)
parent95936b647c0283cc6ebd2b685cc5b72889cda8bd (diff)
downloadbindfs-2b5f2e24527f04f4255161965ae4099192714b73.tar.gz
Merge pull request #150 from hartwork/macos-ci
Cover macOS in CI + make CI use the right compiler + fix more compile warnings
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/bindfs.c32
-rw-r--r--src/permchain.c2
-rw-r--r--src/permchain.h2
-rw-r--r--src/rate_limiter.c4
-rw-r--r--src/rate_limiter.h6
-rw-r--r--src/userinfo.c22
-rw-r--r--src/userinfo.h2
-rw-r--r--src/usermap.c2
-rw-r--r--src/usermap.h2
10 files changed, 40 insertions, 36 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index da443a1..1fd6ef9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,7 +12,7 @@ bindfs_LDADD = ${fuse_LIBS} ${fuse3_LIBS} ${fuse_t_LIBS} ${my_LDFLAGS}
man_MANS = bindfs.1
if BUILD_OS_IS_DARWIN
-bindfs_BUNDLEDIR = /Library/Filesystems/bindfs.fs
+bindfs_BUNDLEDIR = $(DESTDIR)/Library/Filesystems/bindfs.fs
bindfs_BUNDLEBINDIR = "${bindfs_BUNDLEDIR}/Contents/Resources"
install-exec-hook:
diff --git a/src/bindfs.c b/src/bindfs.c
index 5f52395..c21cdb5 100644
--- a/src/bindfs.c
+++ b/src/bindfs.c
@@ -225,7 +225,7 @@ static bool bindfs_init_failed = false;
/* PROTOTYPES */
-static int is_mirroring_enabled();
+static int is_mirroring_enabled(void);
/* Checks whether the uid is to be the mirrored owner of all files. */
static int is_mirrored_user(uid_t uid);
@@ -257,7 +257,7 @@ static size_t round_up_buffer_size_for_direct_io(size_t size);
#ifdef HAVE_FUSE_3
static void *bindfs_init(struct fuse_conn_info *conn, struct fuse_config *cfg);
#else
-static void *bindfs_init();
+static void *bindfs_init(struct fuse_conn_info *conn);
#endif
static void bindfs_destroy(void *private_data);
#ifdef HAVE_FUSE_3
@@ -316,9 +316,11 @@ static int bindfs_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi);
static int bindfs_write(const char *path, const char *buf, size_t size,
off_t offset, struct fuse_file_info *fi);
+#if defined(HAVE_FUSE_29) || defined(HAVE_FUSE_3)
static int bindfs_lock(const char *path, struct fuse_file_info *fi, int cmd,
struct flock *lock);
static int bindfs_flock(const char *path, struct fuse_file_info *fi, int op);
+#endif
#ifdef HAVE_FUSE_3
static int bindfs_ioctl(const char *path, int cmd, void *arg,
struct fuse_file_info *fi, unsigned int flags,
@@ -343,14 +345,14 @@ static int process_option(void *data, const char *arg, int key,
struct fuse_args *outargs);
static int parse_mirrored_users(char* mirror);
static int parse_user_map(UserMap *map, UserMap *reverse_map, char *spec);
-static char *get_working_dir();
-static void maybe_stdout_stderr_to_file();
+static char *get_working_dir(void);
+static void maybe_stdout_stderr_to_file(void);
/* Sets up handling of SIGUSR1. */
-static void setup_signal_handling();
+static void setup_signal_handling(void);
static void signal_handler(int sig);
-static void atexit_func();
+static void atexit_func(void);
/*
Ignore some options (starting with -o)
@@ -362,7 +364,7 @@ are special ones interpreted by systemd in /etc/fstab
struct fuse_args filter_special_opts(struct fuse_args *args);
static bool keep_option(const char* opt);
-static int is_mirroring_enabled()
+static int is_mirroring_enabled(void)
{
return settings.num_mirrored_users + settings.num_mirrored_members > 0;
}
@@ -707,11 +709,11 @@ static size_t round_up_buffer_size_for_direct_io(size_t size)
#ifdef HAVE_FUSE_3
static void *bindfs_init(struct fuse_conn_info *conn, struct fuse_config *cfg)
#else
-static void *bindfs_init()
+static void *bindfs_init(struct fuse_conn_info *conn)
#endif
{
- #ifdef HAVE_FUSE_3
(void) conn;
+ #ifdef HAVE_FUSE_3
cfg->use_ino = 1;
// Disable caches so changes in base FS are visible immediately.
@@ -1454,6 +1456,7 @@ static int bindfs_write(const char *path, const char *buf, size_t size,
return res;
}
+#if defined(HAVE_FUSE_29) || defined(HAVE_FUSE_3)
/* This callback is only installed if lock forwarding is enabled. */
static int bindfs_lock(const char *path, struct fuse_file_info *fi, int cmd,
struct flock *lock)
@@ -1476,6 +1479,7 @@ static int bindfs_flock(const char *path, struct fuse_file_info *fi, int op)
}
return 0;
}
+#endif
#ifdef HAVE_FUSE_3
static int bindfs_ioctl(const char *path, int cmd, void *arg,
@@ -1674,7 +1678,7 @@ static int bindfs_listxattr(const char *path, char* list, size_t size)
}
curr += thislen;
len += thislen;
- } while (len < res);
+ } while (len < (size_t)res);
} else {
// TODO: https://github.com/osxfuse/fuse/blob/master/example/fusexmp_fh.c
// had this commented out bit here o_O
@@ -2304,7 +2308,7 @@ fail:
return 0;
}
-static void maybe_stdout_stderr_to_file()
+static void maybe_stdout_stderr_to_file(void)
{
/* TODO: make this a command line option. */
#if 0
@@ -2327,7 +2331,7 @@ static void maybe_stdout_stderr_to_file()
#endif
}
-static char *get_working_dir()
+static char *get_working_dir(void)
{
size_t buf_size = 4096;
char* buf = malloc(buf_size);
@@ -2338,7 +2342,7 @@ static char *get_working_dir()
return buf;
}
-static void setup_signal_handling()
+static void setup_signal_handling(void)
{
struct sigaction sa;
sa.sa_handler = signal_handler;
@@ -2354,7 +2358,7 @@ static void signal_handler(int sig)
invalidate_user_cache();
}
-static void atexit_func()
+static void atexit_func(void)
{
free(settings.mntsrc);
free(settings.mntdest);
diff --git a/src/permchain.c b/src/permchain.c
index d101aa1..1e6fd98 100644
--- a/src/permchain.c
+++ b/src/permchain.c
@@ -40,7 +40,7 @@ struct permchain {
struct permchain *next;
};
-struct permchain *permchain_create()
+struct permchain *permchain_create(void)
{
struct permchain *pc = malloc(sizeof(struct permchain));
pc->mask = 0000;
diff --git a/src/permchain.h b/src/permchain.h
index 0f268f0..aad66f2 100644
--- a/src/permchain.h
+++ b/src/permchain.h
@@ -36,7 +36,7 @@
struct permchain;
-struct permchain *permchain_create();
+struct permchain *permchain_create(void);
/* Parses chmod arguments like 0777, a=rX, og-rwx etc.
Multiple rules may be given, separated with commas or colons.
diff --git a/src/rate_limiter.c b/src/rate_limiter.c
index 68763c7..fff8f21 100644
--- a/src/rate_limiter.c
+++ b/src/rate_limiter.c
@@ -28,7 +28,7 @@
const double rate_limiter_idle_credit = -0.2;
-double gettimeofday_clock()
+double gettimeofday_clock(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
@@ -50,7 +50,7 @@ static void sleep_seconds(double s)
nanosleep(&ts, NULL);
}
-void rate_limiter_init(RateLimiter *limiter, double rate, double (*clock)())
+void rate_limiter_init(RateLimiter *limiter, double rate, double (*clock)(void))
{
limiter->rate = rate;
limiter->clock = clock;
diff --git a/src/rate_limiter.h b/src/rate_limiter.h
index 95c0069..4a4ad85 100644
--- a/src/rate_limiter.h
+++ b/src/rate_limiter.h
@@ -30,16 +30,16 @@ extern const double rate_limiter_idle_credit;
typedef struct RateLimiter {
double rate; /* bytes / second */
- double (*clock)();
+ double (*clock)(void);
double last_modified;
double accumulated_sleep_time;
pthread_mutex_t mutex;
} RateLimiter;
-double gettimeofday_clock();
+double gettimeofday_clock(void);
/* 0 on success, error number on error. */
-void rate_limiter_init(RateLimiter* limiter, double rate, double (*clock)());
+void rate_limiter_init(RateLimiter* limiter, double rate, double (*clock)(void));
/* Blocks until the rate limiter clears `size` units. */
void rate_limiter_wait(RateLimiter* limiter, size_t size);
/* Updates the rate limiter like `rate_limiter_wait` but does not actually
diff --git a/src/userinfo.c b/src/userinfo.c
index a3ac91c..68291c1 100644
--- a/src/userinfo.c
+++ b/src/userinfo.c
@@ -52,13 +52,13 @@ static struct memory_block cache_memory_block = MEMORY_BLOCK_INITIALIZER;
static volatile int cache_rebuild_requested = 1;
-static void rebuild_cache();
+static void rebuild_cache(void);
static struct uid_cache_entry *uid_cache_lookup(uid_t key);
static struct gid_cache_entry *gid_cache_lookup(gid_t key);
-static int rebuild_uid_cache();
-static int rebuild_gid_cache();
-static void clear_uid_cache();
-static void clear_gid_cache();
+static int rebuild_uid_cache(void);
+static int rebuild_gid_cache(void);
+static void clear_uid_cache(void);
+static void clear_gid_cache(void);
static int uid_cache_name_sortcmp(const void *key, const void *entry);
static int uid_cache_name_searchcmp(const void *key, const void *entry);
static int uid_cache_uid_sortcmp(const void *key, const void *entry);
@@ -66,7 +66,7 @@ static int uid_cache_uid_searchcmp(const void *key, const void *entry);
static int gid_cache_gid_sortcmp(const void *key, const void *entry);
static int gid_cache_gid_searchcmp(const void *key, const void *entry);
-static void rebuild_cache()
+static void rebuild_cache(void)
{
free_memory_block(&cache_memory_block);
init_memory_block(&cache_memory_block, 1024);
@@ -98,7 +98,7 @@ static struct gid_cache_entry *gid_cache_lookup(gid_t key)
);
}
-static int rebuild_uid_cache()
+static int rebuild_uid_cache(void)
{
/* We're holding the lock, so we have mutual exclusion on getpwent and getgrent too. */
struct passwd *pw;
@@ -144,7 +144,7 @@ error:
return 0;
}
-static int rebuild_gid_cache()
+static int rebuild_gid_cache(void)
{
/* We're holding the lock, so we have mutual exclusion on getpwent and getgrent too. */
struct group *gr;
@@ -205,12 +205,12 @@ error:
return 0;
}
-static void clear_uid_cache()
+static void clear_uid_cache(void)
{
uid_cache_size = 0;
}
-static void clear_gid_cache()
+static void clear_gid_cache(void)
{
gid_cache_size = 0;
}
@@ -361,7 +361,7 @@ done:
return ret;
}
-void invalidate_user_cache()
+void invalidate_user_cache(void)
{
cache_rebuild_requested = 1;
}
diff --git a/src/userinfo.h b/src/userinfo.h
index 4c0ca55..6886284 100644
--- a/src/userinfo.h
+++ b/src/userinfo.h
@@ -35,6 +35,6 @@ int user_uid(const char *username, uid_t *ret);
int group_gid(const char *groupname, gid_t *ret);
int user_belongs_to_group(uid_t uid, gid_t gid);
-void invalidate_user_cache(); /* safe to call from signal handler */
+void invalidate_user_cache(void); /* safe to call from signal handler */
#endif
diff --git a/src/usermap.c b/src/usermap.c
index eb7b61c..456bc74 100644
--- a/src/usermap.c
+++ b/src/usermap.c
@@ -14,7 +14,7 @@ struct UserMap {
int group_size;
};
-UserMap *usermap_create()
+UserMap *usermap_create(void)
{
UserMap* map = (UserMap*)malloc(sizeof(UserMap));
map->user_from = NULL;
diff --git a/src/usermap.h b/src/usermap.h
index 9c1387e..db2a9c3 100644
--- a/src/usermap.h
+++ b/src/usermap.h
@@ -37,7 +37,7 @@ typedef enum UsermapStatus {
usermap_status_duplicate_key = 1
} UsermapStatus;
-UserMap *usermap_create();
+UserMap *usermap_create(void);
void usermap_destroy(UserMap *map);
UsermapStatus usermap_add_uid(UserMap *map, uid_t from, uid_t to);