OpenWrt Forum Archive

Topic: ntfs-3g is working on Wl-500g Premium kernel 2.4

The content of this topic has been archived on 27 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Item contains outdated info. Solution is found!!! Please read thread responses below!

I have compiled ntfs-3g for wl-500 Premium running kernel 2.4. It works with my 130 MB USB flash quite stable.

BusyBox v1.11.2 (2008-10-21 21:06:27 EEST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
|       |.-----.-----.-----.|  |  |  |.----.|  |_
|   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
|_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
KAMIKAZE (bleeding edge, r12957) -------------------
  * 10 oz Vodka       Shake well with ice and strain
  * 10 oz Triple sec  mixture into 10 shot glasses.
  * 10 oz lime juice  Salute!
---------------------------------------------------
root@OpenWrt:~# mount
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro)
none on /dev type devfs (rw)
proc on /proc type proc (rw)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw)
/dev/mtdblock/4 on /jffs type jffs2 (rw)
mini_fo:/jffs on / type mini_fo (rw)
none on /proc/bus/usb type usbfs (rw)
/dev/scsi/host0/bus0/target0/lun0/part1 on /mnt type fuse (rw,user_id=0,group_id=0,allow_other)

root@OpenWrt:~# ps
  PID USER       VSZ STAT COMMAND
    1 root      1912 S    init
    2 root         0 SW   [keventd]
    3 root         0 SWN  [ksoftirqd_CPU0]
    4 root         0 SW   [kswapd]
    5 root         0 SW   [bdflush]
    6 root         0 SW   [kupdated]
    9 root         0 SW   [mtdblockd]
   56 root         0 SWN  [jffs2_gcd_mtd4]
   68 root      1912 S    init
   89 root      1928 S    syslogd -C16
   91 root      1908 S    klogd
  242 root      1924 S    udhcpc -t 0 -i eth0.1 -b -p /var/run/eth0.1.pid -R
  258 root         0 SW   [khubd]
  401 root         0 SW   [usb-storage-0]
  403 root         0 SW   [scsi_eh_0]
  562 root      1868 S    /usr/sbin/dropbear -p 22
  565 root      1912 S    /usr/sbin/httpd -p 80 -h /www -r OpenWrt
  614 root      2388 S    ntfs-3g /dev/discs/disc0/part1 /mnt/
  698 root      1928 S    /usr/sbin/dropbear -p 22
  699 root      1916 S    -ash
  702 root      1928 S    /usr/sbin/dropbear -p 22
  703 root      1920 S    -ash
  706 root      1912 R    ps

However when I try to mount my 160 GB external USB hard drive, happens pretty much the same as described here: http://www.nslu2-linux.org/wiki/HowTo/BuildNTFS3G

The ntfs-3g user-space executable  locks up (or locks any process that attempts to access it) until reboot.

At first that happened also with my USB flash. Then I noticed that I have to wait some seconds before start to do something with mounted partition. I do not know how much time I should wait for USB HDD to work:)

It seems that mips or arm platforms even with kernel 2.6 doesn’t support ntfs-3g without patching the kernel: http://forum.ntfs-3g.org/viewtopic.php?t=115 Could anyone confirm that? Is there anyone who is using ntfs-3g with kernel 2.6 on mips or arm platform?

How did I compile my ntfs-3g package? First, I patched the kernel. Patch is here: http://www.abcsolutions.lv/openwrt/016- … mips.patch Put it in "trunk/target/linux/brcm-2.4/patches"

Second. ntfs-3g doesn't require the FUSE user space package anymore, but still needs FUSE kenel module. I added a new patch to FUSE package (http://www.abcsolutions.lv/openwrt/fuse … _BUG.patch). At http://www.abcsolutions.lv/openwrt/ you will find my FUSE kernel 2.4 package and ntfs-3g package. My FUSE package might conflict  with the original fuse package for kernel 2.6. Remove the original one.

Copy my packages in "trunk/packages" , type

make menuconfig

and select FUSE kernel module and ntfs-3g packages. Then build the image.

After mounting NTFS partition, wait some seconds before start to do something with mounted partition. Notice that you wont see filenames with non-Ascii characters. For solution, please please look at http://ntfs-3g.org/support.html#locale .

I'm posting this info to rise discussion how to solve issue with large disks. Could it be FUSE or ntfs-3g issue? ntfs-3g page has info that:

FUSE kernel driver included in Linux kernels before version 2.6.9 are unsafe and prone to data loss.

(Last edited by MoD on 23 Oct 2008, 12:46)

My 160 GB HDD is working too.

I am glad to hear it worked. I am trying this again (I had my own patches which were basically same thing except I defined EXPORT_SYMTAB in c-r4k.c, your way probably more proper) but it didn't seem to do the trick (I'm using with owfs & hello sample program). Will try again.

Misha

I still do not understand why it sometimes locks up. I'm mounting in directory /mnt

If I create subdirectory (for example /mnt/usb ) and mount there, then ntfs-3g user-space executable locks up always.

(Last edited by MoD on 23 Oct 2008, 07:46)

It looks like I have found a solution! I can mount ntfs in subdirectories. Now I have running samba server with RW shared 160 GB HDD ntfs partition.

fuse's dev.c must be patched more (look at http://forum.openwrt.org/viewtopic.php?id=8874). function static inline int fuse_copy_do must look like:

static inline int fuse_copy_do(struct fuse_copy_state *cs, void **val,
                   unsigned *size)
{
    unsigned ncpy = min(*size, cs->len);
    if (val) {
        //patch from mailing list ,it is very important ,otherwise,can' mount , or ls mount point will hang
        flush_cache_all();

        if (cs->write)
            memcpy(cs->buf, *val, ncpy);
        else
            memcpy(*val, cs->buf, ncpy);
        *val += ncpy;
    }
    *size -= ncpy;
    cs->len -= ncpy;
    cs->buf += ncpy;
    return ncpy;
}

The FUSE package patch file http://www.abcsolutions.lv/openwrt/fuse … _BUG.patch is updated.

Actually I should test if it is needed to patch the kernel at all.

(Last edited by MoD on 23 Oct 2008, 12:43)

MoD wrote:

It looks like I have found a solution! I can mount ntfs in subdirectories. Now I have running samba server with RW shared 160 GB HDD ntfs partition.

fuse's dev.c must be patched more (look at http://forum.openwrt.org/viewtopic.php?id=8874). function static inline int fuse_copy_do must look like:

static inline int fuse_copy_do(struct fuse_copy_state *cs, void **val,
                   unsigned *size)
{
    unsigned ncpy = min(*size, cs->len);
    if (val) {
        //patch from mailing list ,it is very important ,otherwise,can' mount , or ls mount point will hang
        flush_cache_all();

        if (cs->write)
            memcpy(cs->buf, *val, ncpy);
        else
            memcpy(*val, cs->buf, ncpy);
        *val += ncpy;
    }
    *size -= ncpy;
    cs->len -= ncpy;
    cs->buf += ncpy;
    return ncpy;
}

The FUSE package patch file http://www.abcsolutions.lv/openwrt/fuse … _BUG.patch is updated.

Actually I should test if it is needed to patch the kernel at all.

For me, on trunk, this patch isn't enough on trunk, only on 7.09. If you look here these are the fuse packages they work absolutely fine on 7.09 (fuse 2.4.2), but not on trunk still hang. They already had this patch.

http://home.mag.cx/openwrt/source/mk/kamikaze/

Then again last time I tried with both patches still had problems

Misha

Misha

You know hold it test the kernel anyway. I just got at least the hello example to work with these packages:
src owfs http://home.mag.cx/openwrt/kamikaze-svn-asus/packages/

No kernel patch. Will have to see...

Misha

EDIT: works ok in debug mode, hangs otherwise...

(Last edited by misha680 on 23 Oct 2008, 14:17)

misha680 wrote:

For me, on trunk, this patch isn't enough on trunk, only on 7.09. If you look here these are the fuse packages they work absolutely fine on 7.09 (fuse 2.4.2), but not on trunk still hang. They already had this patch.

http://home.mag.cx/openwrt/source/mk/kamikaze/

Then again last time I tried with both patches still had problems

Misha

The patch http://www.abcsolutions.lv/openwrt/fuse … _BUG.patch is against my fuse package version 2.5.3, see http://www.abcsolutions.lv/openwrt/fuse-2.5.3/ and it depends from http://www.abcsolutions.lv/openwrt/016- … mips.patch

(Last edited by MoD on 23 Oct 2008, 15:18)

MoD wrote:
misha680 wrote:

For me, on trunk, this patch isn't enough on trunk, only on 7.09. If you look here these are the fuse packages they work absolutely fine on 7.09 (fuse 2.4.2), but not on trunk still hang. They already had this patch.

http://home.mag.cx/openwrt/source/mk/kamikaze/

Then again last time I tried with both patches still had problems

Misha

The patch http://www.abcsolutions.lv/openwrt/fuse … _BUG.patch is against my fuse package version 2.5.3, see http://www.abcsolutions.lv/openwrt/fuse-2.5.3/ and it depends from http://www.abcsolutions.lv/openwrt/016- … mips.patch

Thanks saw them yesterday. They are basically same as mine with minor differences (you have more #defines in FUSE patch and your kernel patch with Makefile mods looks more proper than my define). I will try again with new kernel later.

Misha

Still having some problems. Seems to work in debug mode, but not otherwise (e.g. hello -d a).

Ok, here is my kernel patch that I am using:

--- linux-2.4.35.4.orig/arch/mips/mm/c-r4k.c    2008-10-16 07:57:25.000000000 -0500
+++ linux-2.4.35.4/arch/mips/mm/c-r4k.c    2008-10-16 07:59:00.000000000 -0500
@@ -13,6 +13,7 @@
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/bitops.h>
+#define EXPORT_SYMTAB
 
 #ifdef CONFIG_BCM4710
 #include "../bcm947xx/include/typedefs.h"
@@ -325,8 +326,8 @@
         r4k_blast_scache();
 }
 
-static void r4k_flush_cache_page(struct vm_area_struct *vma,
-                    unsigned long page)
+void r4k_flush_cache_page(struct vm_area_struct *vma,
+                unsigned long page)
 {
     int exec = vma->vm_flags & VM_EXEC;
     struct mm_struct *mm = vma->vm_mm;
@@ -385,6 +386,7 @@
             r4k_blast_icache_page_indexed(page);
     }
 }
+EXPORT_SYMBOL(r4k_flush_cache_page);
 
 static void r4k_flush_data_cache_page(unsigned long addr)
 {

My two fuse patches (to 2.5.3):

--- fuse-2.4.2/kernel/dev.c.org    2005-11-22 22:30:59.000000000 +0100
+++ fuse-2.4.2/kernel/dev.c    2007-01-09 16:32:20.000000000 +0100
@@ -517,6 +517,7 @@
 {
     unsigned ncpy = min(*size, cs->len);
     if (val) {
+        flush_cache_all();
         if (cs->write)
             memcpy(cs->buf, *val, ncpy);
         else
--- fuse-2.5.3.orig/kernel/dev.c    2006-02-02 11:04:52.000000000 -0600
+++ fuse-2.5.3/kernel/dev.c    2008-10-16 00:13:35.000000000 -0500
@@ -511,6 +511,7 @@
 static int fuse_copy_fill(struct fuse_copy_state *cs)
 {
     unsigned long offset;
+    struct vm_area_struct *vma;
     int err;
 
     unlock_request(cs->req);
@@ -524,13 +525,14 @@
     }
     down_read(&current->mm->mmap_sem);
     err = get_user_pages(current, current->mm, cs->addr, 1, cs->write, 0,
-                 &cs->pg, NULL);
+                 &cs->pg, &vma);
     up_read(&current->mm->mmap_sem);
     if (err < 0)
         return err;
     BUG_ON(err != 1);
     offset = cs->addr % PAGE_SIZE;
     cs->mapaddr = kmap_atomic(cs->pg, KM_USER0);
+    r4k_flush_cache_page(vma, cs->addr);
     cs->buf = cs->mapaddr + offset;
     cs->len = min(PAGE_SIZE - offset, cs->seglen);
     cs->seglen -= cs->len;

and fuse Makefile:

# 
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 6807 2007-04-01 19:07:59Z nbd $

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=fuse-2-4
PKG_VERSION:=2.5.3
PKG_RELEASE:=3

PKG_SOURCE:=fuse-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/fuse
PKG_MD5SUM:=6e3d9a580c45ddf4a06558c135c158c2
PKG_BUILD_DIR:=$(BUILD_DIR)/fuse-$(PKG_VERSION)

include $(INCLUDE_DIR)/package.mk

define Package/fuse-2-4/Default
  TITLE:=FUSE
  DEPENDS:=
  URL:=http://fuse.sourceforge.net/
endef

define Package/fuse-2-4/Description
    FUSE (Filesystem in UserSpacE)
endef

define Package/fuse-utils-2-4
  $(call Package/fuse-2-4/Default)
  SECTION:=utils
  CATEGORY:=Utilities
  DEPENDS:=+libfuse-2-4 +kmod-fuse-2-4
  TITLE+= (utilities)
endef

define Package/fuse-utils-2-4/description
    This package contains the FUSE utilities.
endef

define KernelPackage/fuse-2-4
  SUBMENU:=Filesystems
  $(call Package/fuse-2-4/Default)
  DEPENDS:=
  TITLE+= (kernel module)
  FILES:=$(PKG_INSTALL_DIR)/lib/modules/$(LINUX_VERSION)/kernel/fs/fuse/fuse.$(LINUX_KMOD_SUFFIX)
  VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
#  AUTOLOAD:=$(call AutoLoad,80,fuse)
endef

define KernelPackage/fuse-2-4/descriptione
    This package contains the FUSE kernel module.
endef

define Package/libfuse-2-4
  $(call Package/fuse-2-4/Default)
  SECTION:=libs
  CATEGORY:=Libraries
  DEPENDS:=
  TITLE+= (library)
endef

define Package/libfuse-2-4/description
    This package contains the FUSE shared library, needed by other programs.
endef

CONFIGURE_VARS += \
     kernsrcver="$(LINUX_VERSION)"

CONFIGURE_ARGS += \
    --enable-shared \
    --enable-static \
    --disable-rpath \
    --enable-kernel-module \
    --enable-lib \
    --enable-util \
    --disable-auto-modprobe \
    --with-kernel="$(LINUX_DIR)" \
    --disable-mtab

#    --disable-example \

define Build/Configure
    (cd $(PKG_BUILD_DIR); rm -f config.cache; \
        touch configure.in ; \
        touch aclocal.m4 ; \
        touch Makefile.in ; \
        touch include/config.h.in ; \
        touch configure ; \
    )
    $(call Build/Configure/Default)
endef

define Build/Compile
    $(MAKE) -C $(PKG_BUILD_DIR) \
        ARCH="$(LINUX_KARCH)" \
        CROSS_COMPILE="$(TARGET_CROSS)" \
        DESTDIR="$(PKG_INSTALL_DIR)" \
        AM_CFLAGS="$(TARGET_CFLAGS) -DDISABLE_COMPAT=1" \
        EXTRA_DIST="" \
        all install
endef

define Build/InstallDev
    mkdir -p $(STAGING_DIR)/usr/include
    $(CP)    $(PKG_INSTALL_DIR)/usr/include/fuse{,.h} $(STAGING_DIR)/usr/include/
    mkdir -p $(STAGING_DIR)/usr/lib
    $(CP)    $(PKG_INSTALL_DIR)/usr/lib/libfuse.{a,so*} $(STAGING_DIR)/usr/lib/
    mkdir -p $(STAGING_DIR)/usr/lib/pkgconfig
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/fuse.pc $(STAGING_DIR)/usr/lib/pkgconfig/
    $(SED) 's,-I$$$${includedir}/fuse,,g' $(STAGING_DIR)/usr/lib/pkgconfig/fuse.pc
    $(SED) 's,-L$$$${libdir},,g' $(STAGING_DIR)/usr/lib/pkgconfig/fuse.pc
endef

define Build/UninstallDev
    rm -rf    $(STAGING_DIR)/usr/include/fuse{,.h} \
        $(STAGING_DIR)/usr/lib/libfuse.{a,so*} \
        $(STAGING_DIR)/usr/lib/pkgconfig/fuse.pc
endef

define Package/fuse-utils-2-4/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(CP) $(PKG_INSTALL_DIR)/usr/bin/fusermount $(1)/usr/bin/
endef

define Package/libfuse-2-4/install
    $(INSTALL_DIR) $(1)/usr/lib
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/libfuse.so.* $(1)/usr/lib/
endef

$(eval $(call BuildPackage,fuse-utils-2-4))
$(eval $(call BuildPackage,libfuse-2-4))
$(eval $(call KernelPackage,fuse-2-4))

Oh yeah I'm on r13018.

Misha

uhhh hate to rain of you parade. but 2.6 works on the 500gp with wifi. so all this is kinda moot

Weedy wrote:

uhhh hate to rain of you parade. but 2.6 works on the 500gp with wifi. so all this is kinda moot

My understanding last time I checked was this was not exactly true... there are still kinks when transferring with a lot of bandwith no? Has this been fixed recently?

Thank you
Misha

p.s. also my understanding this is why 2.4 is staying in 8.08.

(Last edited by misha680 on 24 Oct 2008, 14:15)

I see that my kernel patch does not have #define EXPORT_SYMTAB but has also:

--- linux-2.4.35.4.orig/arch/mips/mm/Makefile    2007-11-17 19:23:15.000000000 +0200
+++ linux-2.4.35.4/arch/mips/mm/Makefile    2008-10-21 13:02:00.000000000 +0300
@@ -11,7 +11,7 @@
O_TARGET := mm.o

export-objs            := cache.o ioremap.o loadmmu.o remap.o \
-                   tlb-r4k.o tlb-sb1.o
+                   tlb-r4k.o tlb-sb1.o c-r4k.o
obj-y                += cache.o extable.o init.o ioremap.o fault.o \
                   loadmmu.o

(Last edited by MoD on 24 Oct 2008, 07:49)

MoD wrote:

I see that my kernel patch does not have #define EXPORT_SYMTAB but has also:

--- linux-2.4.35.4.orig/arch/mips/mm/Makefile    2007-11-17 19:23:15.000000000 +0200
+++ linux-2.4.35.4/arch/mips/mm/Makefile    2008-10-21 13:02:00.000000000 +0300
@@ -11,7 +11,7 @@
O_TARGET := mm.o

export-objs            := cache.o ioremap.o loadmmu.o remap.o \
-                   tlb-r4k.o tlb-sb1.o
+                   tlb-r4k.o tlb-sb1.o c-r4k.o
obj-y                += cache.o extable.o init.o ioremap.o fault.o \
                   loadmmu.o

Thanks. I saw that. I think mine is just a hack for yours the "proper" way. If I check /proc/ksyms r4k_flush_cache_page is there and if I don't have it in my kernel fuse complains and won't insmod whereas with it there it loads fine. Know any other difference between the two?

Thanks
Misha

EDIT: Will try just in case but I'm pretty much stumped here. I think itm ight be my newer trunk release. I'm on ASUS wl-500g Premium v1. I have to admit I have not tried ntfs-3g just the included hello program and ntfs-3g. I compile hello with this script:

#!/bin/bash
VERSION=2.5.3
#FUSE_DIR=linux-brcm-2.4/fuse-${VERSION}
FUSE_DIR=mipsel/fuse-${VERSION}
EXTRA_FLAGS=-DFUSE_USE_VERSION=25
#EXTRA_FLAGS=
PATH=/home/misha/src/openwrt/trunk/staging_dir/host/bin:/home/misha/src/openwrt/trunk/staging_dir/toolchain-mipsel_gcc4.1.2/bin:${PATH}
export PKG_CONFIG_PATH=/home/misha/src/openwrt/trunk/staging_dir/mipsel/usr/lib/pkgconfig:${PKG_CONFIG_PATH}
cd ~/src/openwrt/trunk/build_dir/${FUSE_DIR}/example
mipsel-linux-gcc -Wall `/home/misha/src/openwrt/trunk/staging_dir/host/bin/pkg-config fuse --cflags --libs` -I/home/misha/src/openwrt/trunk/staging_dir/mipsel/usr/include -L/home/misha/src/openwrt/trunk/staging_dir/mipsel/usr/lib ${EXTRA_FLAGS} $1.c -o $1 
scp $1 root@192.168.1.1:

and to run

./script hello

My openwrt is at /home/misha/src/openwrt/trunk so you would have to change (search -> replace) in script. Would you mind trying it out and letting me know if it works? Try both:

mkdir /tmp/a
./hello /tmp/a
ls /tmp/a

(hangs for me on ls)

and

./hello -d /tmp/a

(works for me)

if that doesn't work well.

Thanks
Misha

(Last edited by misha680 on 24 Oct 2008, 13:59)

does the hello uses libfuse or fuse-utils? Probably there is a problem with hello itself or libfuse or fuse-utils. ntfs-3g uses only fuse kernel module. my understandig is that for kernel 2.4 the fuse.o latest release is 2.5.3 (http://fuse.sourceforge.net/wiki/index.php/FAQ#What_version_of_FUSE_do_I_need_to_use_FUSE_with_Linux_2x2e.4x3f.).

libfuse and fuse-utils you can use from latest kernel 2.6 releases.

MoD wrote:

does the hello uses libfuse or fuse-utils? Probably there is a problem with hello itself or libfuse or fuse-utils. ntfs-3g uses only fuse kernel module. my understandig is that for kernel 2.4 the fuse.o latest release is 2.5.3 (http://fuse.sourceforge.net/wiki/index.php/FAQ#What_version_of_FUSE_do_I_need_to_use_FUSE_with_Linux_2x2e.4x3f.).

libfuse and fuse-utils you can use from latest kernel 2.6 releases.

Yes, neither works I've tried both (only in debug mode). hello uses libfuse which uses the fuse module I believe.

Worst case I can just run owfs with -o debug for fuse too. Not sure what the downside is. I have too much on that owfs (ac/heat control, temp sensors, etc)

Misha

misha680 wrote:

Yes, neither works I've tried both (only in debug mode). hello uses libfuse which uses the fuse module I believe.

Worst case I can just run owfs with -o debug for fuse too. Not sure what the downside is. I have too much on that owfs (ac/heat control, temp sensors, etc)

Misha

I think you should test if ntfs-3g works. If it does, then we can start a new thread to discuss fuse problems?! If you confirm that ntfs-3g works for you, I could release a patch that enables ntfs-3g with iconv support.

MoD wrote:
misha680 wrote:

Yes, neither works I've tried both (only in debug mode). hello uses libfuse which uses the fuse module I believe.

Worst case I can just run owfs with -o debug for fuse too. Not sure what the downside is. I have too much on that owfs (ac/heat control, temp sensors, etc)

Misha

I think you should test if ntfs-3g works. If it does, then we can start a new thread to discuss fuse problems?! If you confirm that ntfs-3g works for you, I could release a patch that enables ntfs-3g with iconv support.

Ok. Know a quick way to make a ntfs partition on a flash drive using preferrably OpenWRT? Thanks Misha

my congratulations:)! I have switched to Freecom Datatank 2. Now my wl-700ge is for testing only.

The discussion might have continued from here.