libports: add libc_fuse_ntfs-3g

Fixes #1058.
This commit is contained in:
Josef Söntgen 2013-11-11 16:00:33 +01:00 committed by Christian Helmuth
parent 7998fdaf3f
commit 829961b0ad
10 changed files with 618 additions and 0 deletions

View File

@ -0,0 +1 @@
REP_INC_DIR += include/ntfs-3g

View File

@ -0,0 +1,17 @@
include $(REP_DIR)/ports/ntfs-3g.inc
NTFS_3G_DIR = $(REP_DIR)/contrib/$(NTFS_3G)
SRC_C = ntfs-3g.c ntfs-3g_common.c
SRC_CC = init.cc
LIBS = libc libc_block libc_fuse libfuse libntfs-3g
CC_OPT = -DHAVE_TIMESPEC -DHAVE_CONFIG_H -DRECORD_LOCKING_NOT_IMPLEMENTED
INC_DIR += $(REP_DIR)/src/lib/ntfs-3g \
$(REP_DIR)/contrib/$(NTFS_3G)/src
vpath %.c $(NTFS_3G_DIR)/src
vpath %.cc $(REP_DIR)/src/lib/ntfs-3g
SHARED_LIB = yes

View File

@ -0,0 +1,14 @@
include $(REP_DIR)/ports/ntfs-3g.inc
NTFS_3G_DIR = $(REP_DIR)/contrib/$(NTFS_3G)
FILTER_OUT = win32_io.c
SRC_C = $(filter-out $(FILTER_OUT),$(notdir $(wildcard $(NTFS_3G_DIR)/libntfs-3g/*.c)))
INC_DIR += $(REP_DIR)/include/ntfs-3g \
$(REP_DIR)/src/lib/ntfs-3g
CC_OPT += -DHAVE_CONFIG_H -DRECORD_LOCKING_NOT_IMPLEMENTED -DDEBUG
LIBS += libc
vpath %.c $(NTFS_3G_DIR)/libntfs-3g

View File

@ -0,0 +1,2 @@
NTFS_3G_VERSION = 2013.1.13
NTFS_3G = ntfs-3g_ntfsprogs-$(NTFS_3G_VERSION)

36
libports/ports/ntfs-3g.mk Normal file
View File

@ -0,0 +1,36 @@
include ports/ntfs-3g.inc
NTFS_3G_TGZ = $(NTFS_3G).tgz
NTFS_3G_BASE_URL = http://tuxera.com/opensource
NTFS_3G_URL = $(NTFS_3G_BASE_URL)/$(NTFS_3G_TGZ)
#
# Interface to top-level prepare Makefile
#
PORTS += ntfs-3g
prepare-ntfs-3g: $(CONTRIB_DIR)/$(NTFS_3G) include/ntfs-3g
#
# Port-specific local rules
#
$(DOWNLOAD_DIR)/$(NTFS_3G_TGZ):
$(VERBOSE)wget -c -P $(DOWNLOAD_DIR) $(NTFS_3G_URL) && touch $@
$(CONTRIB_DIR)/$(NTFS_3G): $(DOWNLOAD_DIR)/$(NTFS_3G_TGZ)
$(VERBOSE)tar xfz $< -C $(CONTRIB_DIR) && touch $@
$(VERBOSE)for i in src/lib/ntfs-3g/*.patch; do \
patch -N -p0 < $$i; done || true
#
# Install ntfs-3g headers
#
include/ntfs-3g:
$(VERBOSE)mkdir -p $@
$(VERBOSE)for i in `find $(CONTRIB_DIR)/$(NTFS_3G)/include/ntfs-3g -name *.h`; do \
ln -fs ../../$$i $@; done
clean-ntfs-3g:
$(VERBOSE)rm -rf include/ntfs-3g
$(VERBOSE)rm -rf $(CONTRIB_DIR)/$(NTFS_3G)

View File

@ -0,0 +1,372 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define this to 1 if you want to enable support of encrypted files in
libntfs and utilities. */
/* #undef ENABLE_CRYPTO */
/* Define to 1 if debug should be enabled */
/* #undef ENABLE_DEBUG */
/* Define to 1 if the nfconv patch should be enabled */
/* #undef ENABLE_NFCONV */
/* Define this to 1 if you want to enable generation of DCE compliant UUIDs.
*/
/* #undef ENABLE_UUID */
/* Define to 1 if using internal fuse */
/* #undef FUSE_INTERNAL */
/* Define to 1 if you have the `atexit' function. */
#define HAVE_ATEXIT 1
/* Define to 1 if you have the `basename' function. */
#define HAVE_BASENAME 1
/* Define to 1 if you have the <byteswap.h> header file. */
/* #undef HAVE_BYTESWAP_H */
/* Define to 1 if you have the `clock_gettime' function. */
/* #undef HAVE_CLOCK_GETTIME */
/* Define to 1 if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1
/* Define to 1 if you have the `daemon' function. */
/* #undef HAVE_DAEMON */
/* 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 `dup2' function. */
#define HAVE_DUP2 1
/* Define to 1 if you have the <endian.h> header file. */
/* #undef HAVE_ENDIAN_H */
/* 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 `fdatasync' function. */
/* #undef HAVE_FDATASYNC */
/* Define to 1 if you have the <features.h> header file. */
/* #undef HAVE_FEATURES_H */
/* Define to 1 if you have the `ffs' function. */
#define HAVE_FFS 1
/* Define to 1 if you have the `fork' function. */
#define HAVE_FORK 1
/* Define to 1 if you have the `getmntent' function. */
/* #undef HAVE_GETMNTENT */
/* Define to 1 if you have the <getopt.h> header file. */
#define HAVE_GETOPT_H 1
/* Define to 1 if you have the `getopt_long' function. */
#define HAVE_GETOPT_LONG 1
/* Define to 1 if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 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 <libgen.h> header file. */
#define HAVE_LIBGEN_H 1
/* Define to 1 if you have the <libintl.h> header file. */
/* #undef HAVE_LIBINTL_H */
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 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 <linux/hdreg.h> header file. */
/* #undef HAVE_LINUX_HDREG_H */
/* Define to 1 if you have the <linux/major.h> header file. */
/* #undef HAVE_LINUX_MAJOR_H */
/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1
/* Define to 1 if you have the <machine/endian.h> header file. */
#define HAVE_MACHINE_ENDIAN_H 1
/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
#define HAVE_MBRTOWC 1
/* Define to 1 if you have the `mbsinit' function. */
#define HAVE_MBSINIT 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 the <mntent.h> header file. */
/* #undef HAVE_MNTENT_H */
/* Define to 1 if you have the <pwd.h> header file. */
#define HAVE_PWD_H 1
/* Define to 1 if you have the `realpath' function. */
#define HAVE_REALPATH 1
/* Define to 1 if you have the `regcomp' function. */
#define HAVE_REGCOMP 1
/* Define to 1 if you have the `setlocale' function. */
#define HAVE_SETLOCALE 1
/* Define to 1 if you have the `setxattr' function. */
/* #undef HAVE_SETXATTR */
/* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */
#define HAVE_STAT_EMPTY_STRING_BUG 1
/* Define to 1 if you have the <stdarg.h> header file. */
#define HAVE_STDARG_H 1
/* Define to 1 if stdbool.h conforms to C99. */
#define HAVE_STDBOOL_H 1
/* 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 <stdio.h> header file. */
#define HAVE_STDIO_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 `strftime' function. */
#define HAVE_STRFTIME 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 `strnlen' function. */
/* #undef HAVE_STRNLEN */
/* Define to 1 if you have the `strsep' function. */
#define HAVE_STRSEP 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 `st_atim' is member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_ATIM */
/* Define to 1 if `st_atimensec' is member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_ATIMENSEC */
/* Define to 1 if `st_atimespec' is member of `struct stat'. */
#define HAVE_STRUCT_STAT_ST_ATIMESPEC 1
/* Define to 1 if `st_blocks' is member of `struct stat'. */
#define HAVE_STRUCT_STAT_ST_BLOCKS 1
/* Define to 1 if `st_rdev' is 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 <syslog.h> header file. */
#define HAVE_SYSLOG_H 1
/* Define to 1 if you have the <sys/byteorder.h> header file. */
/* #undef HAVE_SYS_BYTEORDER_H */
/* Define to 1 if you have the <sys/disk.h> header file. */
#define HAVE_SYS_DISK_H 1
/* Define to 1 if you have the <sys/endian.h> header file. */
#define HAVE_SYS_ENDIAN_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/mount.h> header file. */
#define HAVE_SYS_MOUNT_H 1
/* 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/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/sysmacros.h> header file. */
/* #undef HAVE_SYS_SYSMACROS_H */
/* 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/vfs.h> header file. */
/* #undef HAVE_SYS_VFS_H */
/* Define to 1 if you have the <time.h> header file. */
#define HAVE_TIME_H 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 `utimensat' function. */
/* #undef HAVE_UTIMENSAT */
/* 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 you have the <wchar.h> header file. */
#define HAVE_WCHAR_H 1
/* Define to 1 if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */
/* Define to 1 if the system has the type `_Bool'. */
#define HAVE__BOOL 1
/* Don't update /etc/mtab */
/* #undef IGNORE_MTAB */
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* Don't use default IO ops */
/* #undef NO_NTFS_DEVICE_DEFAULT_IO_OPS */
/* Name of package */
#define PACKAGE "ntfs3g-genode"
/* 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 "ntfs-3g"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "ntfs3g-genode 2013.1.3"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "ntfs-3g"
/* Define to the version of this package. */
#define PACKAGE_VERSION "2013.1.13"
/* POSIX ACL support */
/* #undef POSIXACLS */
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "2013.1.13"
/* Define to 1 if this is a Windows OS */
/* #undef WINDOWS */
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
/* Define to 1 if your processor stores words with the least significant byte
first (like Intel and VAX, unlike Motorola and SPARC). */
#define WORDS_LITTLEENDIAN 1
/* system extended attributes mappings */
/* #undef XATTR_MAPPINGS */
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
/* Required define if using POSIX threads */
/* #undef _REENTRANT */
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* 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 `long int' if <sys/types.h> does not define. */
/* #undef off_t */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */

View File

@ -0,0 +1,112 @@
/*
* \brief libc_fuse_ntfs-3g
* \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 <device.h>
#include <security.h>
#include <ntfs-3g_common.h>
extern struct fuse_operations ntfs_3g_ops;
struct fuse_chan *fc;
struct fuse *fh;
extern ntfs_fuse_context_t **ntfs_fuse_ctx();
extern int ntfs_open(const char*);
extern void ntfs_close(void);
}
bool Fuse::init_fs(void)
{
ntfs_set_locale();
ntfs_log_set_handler(ntfs_log_handler_stderr);
ntfs_fuse_context_t **ctx = ntfs_fuse_ctx();
*ctx = reinterpret_cast<ntfs_fuse_context_t *>(malloc(sizeof (ntfs_fuse_context_t)));
if (!*ctx) {
PERR("out-of-memory");
return false;
}
Genode::memset(*ctx, 0, sizeof (ntfs_fuse_context_t));
(*ctx)->streams = NF_STREAMS_INTERFACE_NONE;
(*ctx)->atime = ATIME_RELATIVE;
(*ctx)->silent = TRUE;
(*ctx)->recover = TRUE;
/*
*ctx = (ntfs_fuse_context_t) {
.uid = 0,
.gid = 0,
.streams = NF_STREAMS_INTERFACE_NONE,
.atime = ATIME_RELATIVE,
.silent = TRUE,
.recover = TRUE
};
*/
PLOG("libc_fuse_ntfs-3g: try to mount /dev/blkdev...");
int err = ntfs_open("/dev/blkdev");
if (err) {
PERR("libc_fuse_ntfs-3g: could not mount /dev/blkdev");
return false;
}
fh = fuse_new(fc, NULL, &ntfs_3g_ops, sizeof (ntfs_3g_ops), NULL);
if (fh == 0) {
PERR("libc_fuse_exfat: fuse_new() failed");
ntfs_close();
return false;
}
(*ctx)->mounted = TRUE;
return true;
}
void Fuse::deinit_fs(void)
{
PLOG("libc_fuse_ntfs-3g: unmount /dev/blkdev...");
ntfs_close();
free(*ntfs_fuse_ctx());
}
void Fuse::sync_fs(void)
{
PLOG("libc_fuse_ntfs-3g: sync file system...");
ntfs_device_sync((*ntfs_fuse_ctx())->vol->dev);
}
bool Fuse::support_symlinks(void)
{
return true;
}

View File

@ -0,0 +1,54 @@
--- contrib/ntfs-3g_ntfsprogs-2013.1.13/src/ntfs-3g.c.orig 2013-12-10 16:16:48.000000000 +0100
+++ contrib/ntfs-3g_ntfsprogs-2013.1.13/src/ntfs-3g.c 2013-12-10 16:19:05.040371689 +0100
@@ -151,6 +151,11 @@
static ntfs_fuse_context_t *ctx;
static u32 ntfs_sequence;
+ntfs_fuse_context_t **ntfs_fuse_ctx()
+{
+ return &ctx;
+}
+
static const char *usage_msg =
"\n"
"%s %s %s %d - Third Generation NTFS Driver\n"
@@ -3266,7 +3271,7 @@
#endif
#endif /* HAVE_SETXATTR */
-static void ntfs_close(void)
+void ntfs_close(void)
{
struct SECURITY_CONTEXT security;
@@ -3305,7 +3310,7 @@
ntfs_close();
}
-static struct fuse_operations ntfs_3g_ops = {
+struct fuse_operations ntfs_3g_ops = {
#if defined(HAVE_UTIMENSAT) && (defined(FUSE_INTERNAL) || (FUSE_VERSION > 28))
/*
* Accept UTIME_NOW and UTIME_OMIT in utimens, when
@@ -3387,7 +3392,7 @@
return 0;
}
-static int ntfs_open(const char *device)
+int ntfs_open(const char *device)
{
unsigned long flags = 0;
@@ -3669,6 +3674,7 @@
ntfs_log_info("Mount options: %s\n", parsed_options);
}
+#if 0
int main(int argc, char *argv[])
{
char *parsed_options = NULL;
@@ -3931,3 +3937,4 @@
free(opts.device);
return err;
}
+#endif

View File

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

View File

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