From aba67e365f0dfb0b2574ee931ac778c13034fe44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Mon, 25 Nov 2013 16:14:59 +0100 Subject: [PATCH] libports: add fuse-exfat Fixes #942. --- libports/lib/import/import-libexfat.mk | 1 + libports/lib/mk/libc_fuse_exfat.mk | 12 +++++ libports/lib/mk/libexfat.mk | 16 ++++++ libports/ports/exfat.inc | 2 + libports/ports/exfat.mk | 35 ++++++++++++ libports/run/libc_fuse_exfat.run | 5 ++ libports/src/lib/exfat/init.cc | 53 +++++++++++++++++++ libports/src/lib/exfat/main.c.patch | 26 +++++++++ libports/src/test/libc_fuse_exfat/target.mk | 5 ++ libports/src/test/libports/libexfat/target.mk | 5 ++ 10 files changed, 160 insertions(+) create mode 100644 libports/lib/import/import-libexfat.mk create mode 100644 libports/lib/mk/libc_fuse_exfat.mk create mode 100644 libports/lib/mk/libexfat.mk create mode 100644 libports/ports/exfat.inc create mode 100644 libports/ports/exfat.mk create mode 100644 libports/run/libc_fuse_exfat.run create mode 100644 libports/src/lib/exfat/init.cc create mode 100644 libports/src/lib/exfat/main.c.patch create mode 100644 libports/src/test/libc_fuse_exfat/target.mk create mode 100644 libports/src/test/libports/libexfat/target.mk diff --git a/libports/lib/import/import-libexfat.mk b/libports/lib/import/import-libexfat.mk new file mode 100644 index 000000000..b7e46c2ae --- /dev/null +++ b/libports/lib/import/import-libexfat.mk @@ -0,0 +1 @@ +REP_INC_DIR += include/exfat diff --git a/libports/lib/mk/libc_fuse_exfat.mk b/libports/lib/mk/libc_fuse_exfat.mk new file mode 100644 index 000000000..08cd5f46f --- /dev/null +++ b/libports/lib/mk/libc_fuse_exfat.mk @@ -0,0 +1,12 @@ +include $(REP_DIR)/ports/exfat.inc +EXFAT_DIR = $(REP_DIR)/contrib/$(EXFAT) + +SRC_C = $(notdir $(EXFAT_DIR)/fuse/main.c) +SRC_CC = init.cc + +LIBS = libc libc_block libc_fuse libfuse libexfat + +vpath %.c $(EXFAT_DIR)/fuse +vpath %.cc $(REP_DIR)/src/lib/exfat + +SHARED_LIB = yes diff --git a/libports/lib/mk/libexfat.mk b/libports/lib/mk/libexfat.mk new file mode 100644 index 000000000..faca7e614 --- /dev/null +++ b/libports/lib/mk/libexfat.mk @@ -0,0 +1,16 @@ +include $(REP_DIR)/ports/exfat.inc +EXFAT_DIR = $(REP_DIR)/contrib/$(EXFAT) + +#FILTER_OUT = win32_io.c +#SRC_C = $(filter-out $(FILTER_OUT),$(notdir $(wildcard $(EXFAT_DIR)/libexfat/*.c))) + +SRC_C = $(notdir $(wildcard $(EXFAT_DIR)/libexfat/*.c)) + +INC_DIR += $(REP_DIR)/include/exfat \ + $(EXFAT_DIR)/libexfat + +#CC_OPT += -DHAVE_CONFIG_H -DRECORD_LOCKING_NOT_IMPLEMENTED + +LIBS += libc + +vpath %.c $(EXFAT_DIR)/libexfat diff --git a/libports/ports/exfat.inc b/libports/ports/exfat.inc new file mode 100644 index 000000000..8514ad6f8 --- /dev/null +++ b/libports/ports/exfat.inc @@ -0,0 +1,2 @@ +EXFAT_VERSION = 1.0.1 +EXFAT = fuse-exfat-$(EXFAT_VERSION) diff --git a/libports/ports/exfat.mk b/libports/ports/exfat.mk new file mode 100644 index 000000000..0a98db25a --- /dev/null +++ b/libports/ports/exfat.mk @@ -0,0 +1,35 @@ +include ports/exfat.inc + +EXFAT_TGZ = $(EXFAT).tar.gz +EXFAT_BASE_URL = https://exfat.googlecode.com/files +EXFAT_URL = $(EXFAT_BASE_URL)/$(EXFAT_TGZ) + +# +# Interface to top-level prepare Makefile +# +PORTS += exfat + +prepare-exfat: $(CONTRIB_DIR)/$(EXFAT) include/exfat + +# +# Port-specific local rules +# +$(DOWNLOAD_DIR)/$(EXFAT_TGZ): + $(VERBOSE)wget -c -P $(DOWNLOAD_DIR) $(EXFAT_URL) && touch $@ + +$(CONTRIB_DIR)/$(EXFAT): $(DOWNLOAD_DIR)/$(EXFAT_TGZ) + $(VERBOSE)tar xfz $< -C $(CONTRIB_DIR) && touch $@ + $(VERBOSE)patch -N -p0 < src/lib/exfat/main.c.patch + +# +# Install exfat headers +# + +include/exfat: + $(VERBOSE)mkdir -p $@ + $(VERBOSE)for i in `find $(CONTRIB_DIR)/$(EXFAT)/libexfat -name *.h`; do \ + ln -fs ../../$$i $@; done + +clean-exfat: + $(VERBOSE)rm -rf include/exfat + $(VERBOSE)rm -rf $(CONTRIB_DIR)/$(EXFAT) diff --git a/libports/run/libc_fuse_exfat.run b/libports/run/libc_fuse_exfat.run new file mode 100644 index 000000000..95fd5fba6 --- /dev/null +++ b/libports/run/libc_fuse_exfat.run @@ -0,0 +1,5 @@ +set mkfs_cmd mkfs.exfat +set mkfs_opts "" +set filesystem fuse_exfat + +source ${genode_dir}/libports/run/libc_filesystem_test.inc diff --git a/libports/src/lib/exfat/init.cc b/libports/src/lib/exfat/init.cc new file mode 100644 index 000000000..aa0330661 --- /dev/null +++ b/libports/src/lib/exfat/init.cc @@ -0,0 +1,53 @@ +/* + * \brief libc_fuse_exfat + * \author Josef Soentgen + * \date 2013-11-11 + */ + +/* + * Copyright (C) 2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +#include + +extern "C" { + +#include + +extern struct fuse_operations fuse_exfat_ops; + +struct fuse_chan *fc; +struct fuse *fh; + +struct exfat ef; + +} + +void Fuse::init_fs(void) +{ + PLOG("libc_fuse_exfat: try to mount /dev/blkdev..."); + + int err = exfat_mount(&ef, "/dev/blkdev", ""); + if (err) { + PERR("libc_fuse_exfat: could not mount /dev/blkdev"); + return; + } + + fh = fuse_new(fc, NULL, &fuse_exfat_ops, sizeof (struct fuse_operations), NULL); + if (fh == 0) { + PERR("libc_fuse_exfat: fuse_new() failed"); + return; + } +} + +void Fuse::deinit_fs(void) +{ + PLOG("libc_fuse_exfat: umount /dev/blkdev..."); + exfat_unmount(&ef); +} diff --git a/libports/src/lib/exfat/main.c.patch b/libports/src/lib/exfat/main.c.patch new file mode 100644 index 000000000..d7a1afa4c --- /dev/null +++ b/libports/src/lib/exfat/main.c.patch @@ -0,0 +1,26 @@ +Make fuse_operation struct globally accessible and comment-out +main() function. +--- contrib/fuse-exfat-1.0.1/fuse/main.c.orig 2013-11-11 14:34:42.668119109 +0100 ++++ contrib/fuse-exfat-1.0.1/fuse/main.c 2013-11-11 14:36:25.728122089 +0100 +@@ -296,7 +296,7 @@ + exit(1); + } + +-static struct fuse_operations fuse_exfat_ops = ++struct fuse_operations fuse_exfat_ops = + { + .getattr = fuse_exfat_getattr, + .truncate = fuse_exfat_truncate, +@@ -403,6 +403,7 @@ + return options; + } + ++#if 0 + int main(int argc, char* argv[]) + { + struct fuse_args mount_args = FUSE_ARGS_INIT(0, NULL); +@@ -550,3 +551,4 @@ + fuse_destroy(fh); + return 0; + } ++#endif diff --git a/libports/src/test/libc_fuse_exfat/target.mk b/libports/src/test/libc_fuse_exfat/target.mk new file mode 100644 index 000000000..28406100d --- /dev/null +++ b/libports/src/test/libc_fuse_exfat/target.mk @@ -0,0 +1,5 @@ +TARGET = test-libc_fuse_exfat +LIBS = libc libc_log libc_fuse_exfat +SRC_CC = main.cc + +vpath %.cc $(PRG_DIR)/../libc_ffat/ diff --git a/libports/src/test/libports/libexfat/target.mk b/libports/src/test/libports/libexfat/target.mk new file mode 100644 index 000000000..15f023090 --- /dev/null +++ b/libports/src/test/libports/libexfat/target.mk @@ -0,0 +1,5 @@ +TARGET = test-libexfat +LIBS = libc libexfat +SRC_CC = main.cc + +vpath main.cc $(PRG_DIR)/..