libports: add fuse-ext2

Fixes #942.
This commit is contained in:
Josef Söntgen 2013-11-14 16:35:15 +01:00 committed by Norman Feske
parent aba67e365f
commit 607036718c
16 changed files with 632 additions and 0 deletions

View File

@ -0,0 +1 @@
REP_INC_DIR += include/fuse-ext2

View File

@ -0,0 +1,20 @@
include $(REP_DIR)/ports/fuse-ext2.inc
FUSE_EXT2_DIR = $(REP_DIR)/contrib/$(FUSE_EXT2)/fuse-ext2
FILTER_OUT = fuse-ext2.probe.c fuse-ext2.wait.c
SRC_C = $(filter-out $(FILTER_OUT), $(notdir $(wildcard $(FUSE_EXT2_DIR)/*.c)))
SRC_CC = init.cc
LIBS = libc libc_block libc_fuse libfuse libext2fs
CC_OPT = -DHAVE_CONFIG_H -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
CC_CXX_OPT +=-fpermissive
INC_DIR += $(REP_DIR)/src/lib/fuse-ext2 \
$(FUSE_EXT2_DIR)
vpath %.c $(FUSE_EXT2_DIR)
vpath %.cc $(REP_DIR)/src/lib/fuse-ext2
SHARED_LIB = yes

View File

@ -0,0 +1,20 @@
include $(REP_DIR)/ports/fuse-ext2.inc
FUSE_EXT2_DIR = $(REP_DIR)/contrib/$(FUSE_EXT2)
E2FSPROGS_DIR = $(FUSE_EXT2_DIR)/e2fsprogs-1.41.12.newgit
EXT2FS_DIR = $(E2FSPROGS_DIR)/ext2fs
ET_DIR = $(E2FSPROGS_DIR)/et
FILTER_OUT = bmove.c dosio.c irel_ma.c nt_io.c tdbtool.c
SRC_C = $(filter-out $(FILTER_OUT), $(notdir $(wildcard $(EXT2FS_DIR)/*.c)))
SRC_C += $(notdir $(wildcard $(ET_DIR)/*.c))
INC_DIR += $(REP_DIR)/include/fuse-ext2 \
$(REP_DIR)/src/lib/fuse-ext2 \
$(ET_DIR)
CC_OPT += -DHAVE_CONFIG_H -D__BSD_VISIBLE
LIBS += libc
vpath %.c $(EXT2FS_DIR)
vpath %.c $(ET_DIR)

View File

@ -0,0 +1,4 @@
FUSE_EXT2_REV := 220
FUSE_EXT2_VERSION := svn-$(FUSE_EXT2_REV)
FUSE_EXT2 := fuse-ext2-$(FUSE_EXT2_VERSION)

View File

@ -0,0 +1,36 @@
include ports/fuse-ext2.inc
FUSE_EXT2_SVN_URL = http://svn.code.sf.net/p/fuse-ext2/code/branch/renzo
EXT2_DIR = e2fsprogs-1.41.12.newgit/
#
# Interface to top-level prepare Makefile
#
PORTS += $(FUSE_EXT2)
prepare-fuse-ext2: $(CONTRIB_DIR)/$(FUSE_EXT2) include/fuse-ext2
#
# Port-specific local rules
#
$(CONTRIB_DIR)/$(FUSE_EXT2):
$(ECHO) "checking out 'fuse-ext2 rev. $(FUSE_EXT2_REV)' to '$@'"
$(VERBOSE)svn export $(FUSE_EXT2_SVN_URL)@$(FUSE_EXT2_REV) $@
$(VERBOSE)for i in src/lib/fuse-ext2/patches/*.patch; do \
patch -N -p0 < $$i; done || true
#
# Install fuse-ext2 headers
#
#
include/fuse-ext2:
$(VERBOSE)mkdir -p $@/{e2p,et,ext2fs}
$(VERBOSE)for j in e2p et ext2fs; do \
for i in `find $(CONTRIB_DIR)/$(FUSE_EXT2)/$(EXT2_DIR)/$$j -name *.h`; do \
ln -fs ../../../$$i $@/$$j; \
done; done
clean-fuse-ext2:
$(VERBOSE)rm -rf include/fuse-ext2
$(VERBOSE)rm -rf $(CONTRIB_DIR)/$(FUSE_EXT2)

View File

@ -0,0 +1,5 @@
set mkfs_cmd mkfs.ext2
set mkfs_opts "-F"
set filesystem fuse_ext2
source ${genode_dir}/libports/run/libc_filesystem_test.inc

View File

@ -0,0 +1,373 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if the `closedir' function returns void instead of `int'. */
/* #undef CLOSEDIR_VOID */
/* Define to 1 if you want 'debug' support. */
#define ENABLE_DEBUG 1
/* Define to 1 if you want 'swapfs' support. */
#define ENABLE_SWAPFS 1
/* Version of FUSE interface */
#define FUSE_USE_VERSION 26
/* Define to 1 if your system has a working `chown' function. */
/* #undef HAVE_CHOWN */
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#define HAVE_DIRENT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
/* #undef HAVE_DOPRNT */
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the `ftruncate' function. */
#define HAVE_FTRUNCATE 1
/* Define to 1 if you have the `getdtablesize' function. */
/* #undef HAVE_GETDTABLESIZE */
/* Define to 1 if you have the `getmntent' function. */
#define HAVE_GETMNTENT 1
/* Define to 1 if you have the `getmntinfo' function. */
/* #undef HAVE_GETMNTINFO */
/* Define to 1 if you have the <getopt.h> header file. */
#define HAVE_GETOPT_H 1
/* Define to 1 if you have the `getpagesize' function. */
#define HAVE_GETPAGESIZE 1
/* Define to 1 if you have the `hasmntopt' function. */
/* #undef HAVE_HASMNTOPT */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `ext2fs' library (-lext2fs). */
#define HAVE_LIBEXT2FS 1
/* Define to 1 if you have the <linux/fd.h> header file. */
/* #undef HAVE_LINUX_FD_H */
/* Define to 1 if you have the `llseek' function. */
/* #undef HAVE_LLSEEK */
/* Define to 1 if you have the `llseek' prototype. */
/* #undef HAVE_LLSEEK_PROTOTYPE */
/* Define to 1 if you have the `lseek64' function. */
/* #undef HAVE_LSEEK64 */
/* Define to 1 if you have the `lseek64' prototype. */
#define HAVE_LSEEK64_PROTOTYPE 1
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#define HAVE_MALLOC 1
/* Define to 1 if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have a working `mmap' system call. */
/* #undef HAVE_MMAP */
/* Define to 1 if you have the <mntent.h> header file. */
/* #undef HAVE_MNTENT_H */
/* Define to 1 if you have the `munmap' function. */
/* #undef HAVE_MUNMAP */
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */
/* Define to 1 if you have the <netinet/in.h> header file. */
#define HAVE_NETINET_IN_H 1
/* Define to 1 if you have the <net/if_dl.h> header file. */
/* #undef HAVE_NET_IF_DL_H */
/* Define to 1 if you have the <net/if.h> header file. */
#define HAVE_NET_IF_H 1
/* Define to 1 if you have the <paths.h> header file. */
#define HAVE_PATHS_H 1
/* Define to 1 if you have the `random' function. */
#define HAVE_RANDOM 1
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
and to 0 otherwise. */
#define HAVE_REALLOC 1
/* Define to 1 if you have the `select' function. */
#define HAVE_SELECT 1
/* Define to 1 if you have the `srand' function. */
#define HAVE_SRAND 1
/* Define to 1 if you have the `srandom' function. */
#define HAVE_SRANDOM 1
/* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */
/* #undef HAVE_STAT_EMPTY_STRING_BUG */
/* Define to 1 if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strcasecmp' function. */
#define HAVE_STRCASECMP 1
/* Define to 1 if you have the `strchr' function. */
#define HAVE_STRCHR 1
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strrchr' function. */
#define HAVE_STRRCHR 1
/* Define to 1 if you have the `strtol' function. */
#define HAVE_STRTOL 1
/* Define to 1 if you have the `strtoul' function. */
#define HAVE_STRTOUL 1
/* Define to 1 if you have the `strtoull' function. */
#define HAVE_STRTOULL 1
/* Define to 1 if `st_blksize' is a member of `struct stat'. */
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
/* Define to 1 if `st_blocks' is a member of `struct stat'. */
#define HAVE_STRUCT_STAT_ST_BLOCKS 1
/* Define to 1 if `st_rdev' is a member of `struct stat'. */
#define HAVE_STRUCT_STAT_ST_RDEV 1
/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use
`HAVE_STRUCT_STAT_ST_BLOCKS' instead. */
#define HAVE_ST_BLOCKS 1
/* Define to 1 if you have the `sysconf' function. */
#define HAVE_SYSCONF 1
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_DIR_H */
/* Define to 1 if you have the <sys/disklabel.h> header file. */
/* #undef HAVE_SYS_DISKLABEL_H */
/* Define to 1 if you have the <sys/disk.h> header file. */
/* #undef HAVE_SYS_DISK_H */
/* Define to 1 if you have the <sys/file.h> header file. */
#define HAVE_SYS_FILE_H 1
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/mkdev.h> header file. */
/* #undef HAVE_SYS_MKDEV_H */
/* Define to 1 if you have the <sys/mman.h> header file. */
#define HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the <sys/mount.h> header file. */
#define HAVE_SYS_MOUNT_H 1
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_NDIR_H */
/* Define to 1 if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define to 1 if you have the <sys/prctl.h> header file. */
#define HAVE_SYS_PRCTL_H 1
/* Define to 1 if you have the <sys/queue.h> header file. */
#define HAVE_SYS_QUEUE_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H 1
/* Define to 1 if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
/* Define to 1 if you have the <sys/sockio.h> header file. */
/* #undef HAVE_SYS_SOCKIO_H */
/* Define to 1 if you have the <sys/statvfs.h> header file. */
#define HAVE_SYS_STATVFS_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/syscall.h> header file. */
#define HAVE_SYS_SYSCALL_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/un.h> header file. */
#define HAVE_SYS_UN_H 1
/* Define to 1 if you have the `ssize_t' prototype. */
#define HAVE_TYPE_SSIZE_T 1
/* Define to 1 if you have the `uname' function. */
#define HAVE_UNAME 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the `utime' function. */
#define HAVE_UTIME 1
/* Define to 1 if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1
/* Define to 1 if `utime(file, NULL)' sets file's timestamp to the present. */
#define HAVE_UTIME_NULL 1
/* Define to 1 if you have the `vprintf' function. */
#define HAVE_VPRINTF 1
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
/* #undef LT_OBJDIR */
/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
*/
/* #undef MAJOR_IN_MKDEV */
/* Define to 1 if `major', `minor', and `makedev' are declared in
<sysmacros.h>. */
/* #undef MAJOR_IN_SYSMACROS */
/* Name of package */
#define PACKAGE "fuse-ext2"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME "fuse-ext2"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "fuse-ext2 0.0.7.1"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "fuse-ext2"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.0.7.1"
/* Define to the type of arg 1 for `select'. */
#define SELECT_TYPE_ARG1 int
/* Define to the type of args 2, 3 and 4 for `select'. */
#define SELECT_TYPE_ARG234 (fd_set *)
/* Define to the type of arg 5 for `select'. */
#define SELECT_TYPE_ARG5 (struct timeval *)
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Version number of package */
#define VERSION "0.0.7.1"
/* File Offset size */
#define _FILE_OFFSET_BITS 64
/* Large files support */
#define _LARGE_FILE_SOURCE /**/
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef gid_t */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to rpl_malloc if the replacement function should be used. */
/* #undef malloc */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef mode_t */
/* Define to `long int' if <sys/types.h> does not define. */
/* #undef off_t */
/* Define to rpl_realloc if the replacement function should be used. */
/* #undef realloc */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef ssize_t */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef uid_t */

View File

@ -0,0 +1,78 @@
/*
* \brief libc_fuse_ext2
* \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 <base/printf.h>
#include <util/string.h>
#include <fuse.h>
#include <fuse_private.h>
/* libc includes */
#include <stdlib.h>
extern "C" {
#include <fuse-ext2.h>
#include <ext2fs/ext2fs.h>
extern struct fuse_operations ext2fs_ops;
struct fuse_chan *fc;
struct fuse *fh;
static ext2_filsys e2fs;
static struct extfs_data extfs_data;
}
void Fuse::init_fs(void)
{
PLOG("libc_fuse_ext2: try to mount /dev/blkdev...");
int err = ext2fs_open("/dev/blkdev", EXT2_FLAG_RW, 0, 0, unix_io_manager, &e2fs);
if (err) {
PERR("libc_fuse_ext2: could not mount /dev/blkdev, error: %d", err);
return;
}
errcode_t rc = ext2fs_read_bitmaps(e2fs);
if (rc) {
PERR("libc_fuse_ext2: error while reading bitmaps");
ext2fs_close(e2fs);
return;
}
extfs_data.debug = 0;
extfs_data.silent = 0;
extfs_data.force = 0;
extfs_data.readonly = 0;
extfs_data.last_flush = 0;
extfs_data.mnt_point = "/";
extfs_data.options = "";
extfs_data.device = "/dev/blkdev";
extfs_data.volname = "ext2_volume";
extfs_data.e2fs = e2fs;
fh = fuse_new(fc, NULL, &ext2fs_ops, sizeof (ext2fs_ops), &extfs_data);
if (fh == 0) {
PERR("libc_fuse_ext2: fuse_new() failed");
return;
}
}
void Fuse::deinit_fs(void)
{
PLOG("libc_fuse_ext2: unmount /dev/blkdev...");
ext2fs_close(e2fs);
}

View File

@ -0,0 +1,11 @@
--- contrib/fuse-ext2-svn-220/e2fsprogs-1.41.12.newgit/ext2fs/bitops.h.orig 2013-11-14 15:25:38.621795983 +0100
+++ contrib/fuse-ext2-svn-220/e2fsprogs-1.41.12.newgit/ext2fs/bitops.h 2013-11-14 15:24:24.069798186 +0100
@@ -98,7 +98,7 @@
extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
- ino_t inode, int num);
+ ext2_ino_t inode, int num);
extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,

View File

@ -0,0 +1,22 @@
--- contrib/fuse-ext2-svn-220/e2fsprogs-1.41.12.newgit/ext2fs/closefs.c.orig 2013-11-22 17:12:24.152903960 +0100
+++ contrib/fuse-ext2-svn-220/e2fsprogs-1.41.12.newgit/ext2fs/closefs.c 2013-11-22 17:12:52.936905227 +0100
@@ -32,19 +32,6 @@
}
}
-int ext2fs_bg_has_super(ext2_filsys fs, int group_block)
-{
- if (!(fs->super->s_feature_ro_compat &
- EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))
- return 1;
-
- if (test_root(group_block, 3) || (test_root(group_block, 5)) ||
- test_root(group_block, 7))
- return 1;
-
- return 0;
-}
-
/*
* ext2fs_super_and_bgd_loc2()
* @fs: ext2 fs pointer

View File

@ -0,0 +1,15 @@
--- contrib/fuse-ext2-svn-220/e2fsprogs-1.41.12.newgit/ext2fs/ext2fs.h.orig 2013-11-22 17:06:23.728888099 +0100
+++ contrib/fuse-ext2-svn-220/e2fsprogs-1.41.12.newgit/ext2fs/ext2fs.h 2013-11-22 17:03:53.028881471 +0100
@@ -49,9 +49,12 @@
#include <sys/types.h>
#endif
+typedef unsigned int dev_t;
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#if EXT2_FLAT_INCLUDES
#include "e2_types.h"

View File

@ -0,0 +1,11 @@
--- contrib/fuse-ext2-svn-220/fuse-ext2/fuse-ext2.c.orig 2013-11-22 17:13:24.484906614 +0100
+++ contrib/fuse-ext2-svn-220/fuse-ext2/fuse-ext2.c 2013-11-22 17:13:35.520907100 +0100
@@ -278,7 +278,7 @@
goto exit;
}
-static const struct fuse_operations ext2fs_ops = {
+const struct fuse_operations ext2fs_ops = {
.getattr = op_getattr,
.readlink = op_readlink,
.mknod = op_mknod,

View File

@ -0,0 +1,11 @@
--- contrib/fuse-ext2-svn-220/fuse-ext2/op_access.c.orig 2013-11-22 17:10:24.636898700 +0100
+++ contrib/fuse-ext2-svn-220/fuse-ext2/op_access.c 2013-11-22 17:10:34.728899142 +0100
@@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <unistd.h>
+
#include "fuse-ext2.h"
int op_access (const char *path, int mask)

View File

@ -0,0 +1,15 @@
--- contrib/fuse-ext2-svn-220/fuse-ext2/op_statfs.c.orig 2013-11-25 15:51:51.752182307 +0100
+++ contrib/fuse-ext2-svn-220/fuse-ext2/op_statfs.c 2013-11-25 15:51:45.592104883 +0100
@@ -41,10 +41,12 @@
static int ext2_bg_has_super (ext2_filsys e2fs, int group)
{
+ /*
if (EXT2_HAS_RO_COMPAT_FEATURE(e2fs->super, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
!ext2_group_spare(group)) {
return 0;
}
+ */
return 1;
}

View File

@ -0,0 +1,5 @@
TARGET = test-libc_fuse_ext2
LIBS = libc libc_log libc_fuse_ext2
SRC_CC = main.cc
vpath %.cc $(PRG_DIR)/../libc_ffat

View File

@ -0,0 +1,5 @@
TARGET = test-libext2fs
LIBS = libc libext2fs
SRC_CC = main.cc
vpath main.cc $(PRG_DIR)/..