Skip to content
Permalink
Browse files

(loopback) Add support for case insensitive file systems

When called with option "-o case_insensitive" the mounted loopback
volume will be marked as cese insensitive. This switch should only be
used if the backing storage is indeed case insensitve.
  • Loading branch information...
bfleischer committed Mar 7, 2014
1 parent 0467302 commit d9a598638a14f27ba6050aaeee4cae96580a3341
Showing with 36 additions and 1 deletion.
  1. +36 −1 filesystems-c/loopback/loopback.c
@@ -25,6 +25,7 @@

#include <fuse.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -50,6 +51,12 @@ typedef unsigned long u_long;
#define A_KAUTH_FILESEC_XATTR A_PREFIX ".apple.system.Security"
#define XATTR_APPLE_PREFIX "com.apple."

struct loopback {
int case_insensitive;
};

static struct loopback loopback;

static int
loopback_getattr(const char *path, struct stat *stbuf)
{
@@ -736,12 +743,24 @@ loopback_fallocate(const char *path, int mode, off_t offset, off_t length,

#endif /* FUSE_VERSION >= 29 */

static int
loopback_setvolname(const char *name)
{
return 0;
}

void *
loopback_init(struct fuse_conn_info *conn)
{
FUSE_ENABLE_SETVOLNAME(conn);
FUSE_ENABLE_XTIMES(conn);

#ifdef FUSE_ENABLE_CASE_INSENSITIVE
if (loopback.case_insensitive) {
FUSE_ENABLE_CASE_INSENSITIVE(conn);
}
#endif

return NULL;
}

@@ -787,12 +806,28 @@ static struct fuse_operations loopback_oper = {
#if FUSE_VERSION >= 29
.fallocate = loopback_fallocate,
#endif
.setvolname = loopback_setvolname,
};

static const struct fuse_opt loopback_opts[] = {
{ "case_insensitive", offsetof(struct loopback, case_insensitive), 1 },
FUSE_OPT_END
};

int
main(int argc, char *argv[])
{
int res = 0;
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);

loopback.case_insensitive = 0;
if (fuse_opt_parse(&args, &loopback, loopback_opts, NULL) == -1) {
exit(1);
}

umask(0);
res = fuse_main(args.argc, args.argv, &loopback_oper, NULL);

return fuse_main(argc, argv, &loopback_oper, NULL);
fuse_opt_free_args(&args);
return res;
}

0 comments on commit d9a5986

Please sign in to comment.
You can’t perform that action at this time.