exfat icon indicating copy to clipboard operation
exfat copied to clipboard

ERROR: exFAT file system is not found.

Open protectivedad opened this issue 5 years ago • 25 comments

I compiled fuse-exfat and exfat-utils 1.3.0 for a ARM router. Mounting or using any exfat-utils on a known working exfat system by either image file, flash drive or harddrive gives: ERROR: exFAT file system is not found.

This interesting thing is if I take an NTFS drive and use the exfat-utils mkexfatfs it creates an exfat file system that can be read by my windows machine, but on the router it gives the error: ERROR: exFAT file system is not found.

So, mkexfatfs seems to work, but exfat programs that tries to read the file/or image fail. I created a 1G image file using:

/ # dd bs=1M count=1024 if=/dev/null of=exfat.img
/ # /data/bin/mkexfatfs /mnt/disk1_2/exfat.img
mkexfatfs 1.3.0
Creating... done.
Flushing... done.
/ # mount.exfat -d /mnt/disk1_2/exfat.img /mnt/disk2_1/
FUSE exfat 1.3.0
ERROR: exFAT file system is not found.
/ # hexdump -n 100 /mnt/disk1_2/exfat.img
0000000 76eb 4590 4658 5441 2020 0020 0000 0000
0000010 0000 0000 0000 0000 0000 0000 0000 0000
*
0000040 0000 0000 0000 0000 0000 0020 0000 0000
0000050 0080 0000 0100 0000 0180 0000 7ffa 0000
0000060 0004 0000
0000064
 ```

The -d debug flag doesn't seem to do anything or at least there is no change in the output when I use it.

protectivedad avatar Dec 04 '18 03:12 protectivedad

What libc does this router use?

Could you strace the mount command?

relan avatar Dec 04 '18 06:12 relan

There's no strace or any tracing on the box. It is using uClibc. I can see about compiling something to trace it, if you can point me to the source download. Thanks.

protectivedad avatar Dec 04 '18 11:12 protectivedad

strace source code is here: https://github.com/strace/strace

relan avatar Dec 04 '18 12:12 relan

Here is the log: strace.img.log here is one for a drive usb: strace.sdb1.log

protectivedad avatar Dec 04 '18 14:12 protectivedad

lseek(3, 20140648, SEEK_SET)            = 20140648
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 512) = 512

This lseek looks weird. Could you give me a link to the source code of uClibc version used in your router? uClibc is LGPL, so the vendor should provide sources.

How did you compile fuse-exfat? Did you use autotools or some other build system? Looks like there's a problem with LFS (large file support) because lseek is called instead of lseek64.

relan avatar Dec 04 '18 18:12 relan

I forked and am using https://github.com/andrew867/Actiontec-R3000-33.162L.16-BellAliant for the sources. I added a directory in the build with the attached Makefile I created to download and compile your sources. Makefile.txt

protectivedad avatar Dec 04 '18 18:12 protectivedad

I'm not sure if this helps, but I also recompile the latest ntfs-3g drivers to use the external libfuse. Here is a strace of the command: ntfs-3g /dev/sda2 /mnt/disk1_2 -o use_ino,direct_io,big_writes strace.ntfs-3g.log

protectivedad avatar Dec 04 '18 18:12 protectivedad

The abovementioned repo does not include libc source code.

I've checked upstream uClibc sources and to me it looks like a misconfiguration: fuse-exfat uses pread/pwrite and both uClibc and Linux kernel should support them, but for some reason uClibc on your router erroneously translates those calls to lseek+read/write (should be pread64/pwrite64 instead).

relan avatar Dec 11 '18 08:12 relan

You are right. By substituting lseek64, pread64, and pwrite64 in io.c the tools work. When I get a chance I will look further into why ntfs-3g is able to handle this without a problem, but your fuse-exfat has issues. Or do you know why?

protectivedad avatar Dec 11 '18 14:12 protectivedad

I can only guess that some defines are missing in the Makefile.

relan avatar Dec 11 '18 14:12 relan

The configure for ntfs-3g defines _GNU_SOURCE which eventually defines, in the toolchain headers features.h, __USE_UNIX98 which creates:

#define pread pread64
#define pwrite pwrite64

etc. I'm not sure if this is something that you want to include or not, but that is the solution. Another way to do the same thing which is done in the mtd-utils is:

#define _XOPEN_SOURCE 500 /* For pread/pwrite */

You can correct me if I'm wrong, but from my reading of man pages I think the _XOPEN_SOURCE is supposed to be defined in order to use the pread/pwrite functions.

protectivedad avatar Dec 12 '18 01:12 protectivedad

Hi, I am having the same issue while trying to mount a fuse-exfat formatted microsd card (created on the target machine)

The card mounts fine and is writable on other devices (both Linux and android arm devices)

I compiled fuse-exfat 1.3.0 on a Nokia N810 internet tablet (arm device) with autotools.

libc version:

(Nokia-N810-43-7) ~ $ ldd --version ldd (GNU libc) 2.5 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Roland McGrath and Ulrich Drepper.

Source: http://repository.maemo.org/pool/diablo/free/g/glibc/glibc_2.5.0-1osso10.tar.gz

strace log:

https://termbin.com/oby1

PhilT001 avatar Mar 03 '19 14:03 PhilT001

Looks like _llseek is broken:

_llseek(3, 0, [15929966592], SEEK_END) = 0
_llseek(3, 0, [0], SEEK_SET) = 0
pread(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 512, 766222165606400) = 512
write(2, "ERROR: "..., 7ERROR: ) = 7
write(2, "exFAT file system is not found"..., 30exFAT file system is not found) = 30

What version of autotools did you use and what version of kernel does your tablet run?

relan avatar Mar 04 '19 04:03 relan

autoconf (GNU Autoconf) 2.69 automake (GNU automake) 1.15 libtool (GNU libtool) 2.4.6

Kernel is 2.6.21-omap1

PhilT001 avatar Mar 04 '19 18:03 PhilT001

@PhilT001, could you try the following patch?

diff --git a/libexfat/io.c b/libexfat/io.c
index bc92c7c..81ef727 100644
--- a/libexfat/io.c
+++ b/libexfat/io.c
@@ -226,9 +226,24 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode)
 					"you can fix this with fdisk(8)");
 	}
 	else
+#elif defined(__linux__)
+	if (!S_ISREG(stbuf.st_mode))
+	{
+		uint64_t size;
+
+		if (ioctl(dev->fd, BLKGETSIZE64, &size) == -1)
+		{
+			close(dev->fd);
+			free(dev);
+			exfat_error("failed to get block device size");
+			return NULL;
+		}
+		dev->size = size;
+	}
+	else
 #endif
 	{
-		/* works for Linux, FreeBSD, Solaris */
+		/* works for FreeBSD, Solaris */
 		dev->size = exfat_seek(dev, 0, SEEK_END);
 		if (dev->size <= 0)
 		{

relan avatar Mar 10 '19 18:03 relan

Thanks for your help so far.

Can you advise me as to how to apply this patch? I have limited experience applying patch files and I just getting errors with this.

PhilT001 avatar Mar 10 '19 20:03 PhilT001

Sorry, I failed to copy-paste the patch properly. Here it is in compressed form.

relan avatar Mar 11 '19 17:03 relan

Unfortunately it still fails.

strace log:

https://termbin.com/apmh

PhilT001 avatar Mar 11 '19 18:03 PhilT001

Could you share libexfat/config.h? Looks like something's wrong with Large File Support (pread is used instead of pread64).

relan avatar Mar 13 '19 18:03 relan

OK, no problem.

https://termbin.com/8b89

PhilT001 avatar Mar 13 '19 21:03 PhilT001

config.h is OK.

I looked through glibc-2.5 code and it seems that missing _XOPEN_SOURCE can cause ABI issues with LFS. Please try this patch:

diff --git a/libexfat/exfat.h b/libexfat/exfat.h
index 2342be4..77ea5db 100644
--- a/libexfat/exfat.h
+++ b/libexfat/exfat.h
@@ -24,6 +24,7 @@
 #ifndef EXFAT_H_INCLUDED
 #define EXFAT_H_INCLUDED

+#define _XOPEN_SOURCE 500
 #ifndef ANDROID
 /* Android.bp is used instead of autotools when targeting Android */
 #include "config.h"

relan avatar Mar 14 '19 17:03 relan

Success!

Your latest patch produces the following:

(Nokia-N810-43-7) DEBIAN $ sudo mount.exfat /dev/sda1 ~/mnt/fuse-exfat FUSE exfat 1.3.0

Thank you for your time and help with this.

PhilT001 avatar Mar 15 '19 19:03 PhilT001

This did not work for me as well

Black-Spade avatar Jul 03 '19 14:07 Black-Spade

This did not work for me as well

What exactly doesn't work for you?

relan avatar Jul 03 '19 16:07 relan

Hello, i have the same question, strace log file is as below strace.sdb.log

Hphuang-hub avatar Dec 17 '21 10:12 Hphuang-hub

Fixed in v1.4.0.

relan avatar Mar 02 '23 20:03 relan