Code Monkey home page Code Monkey logo

Comments (11)

relan avatar relan commented on May 30, 2024

This means that fuse-exfat failed to find the EXFAT magic in the first sector. Please run mkexfatfs /dev/sdb1, dump the first 512 bytes of /dev/sdb1 (using dd) and attach this dump here.

from exfat.

xunmengdeganjue avatar xunmengdeganjue commented on May 30, 2024

Hi relan,Thanks for your help,I can't attach the dump file here directly,so i used the UE to show it as following picture:
exfat_512 dump
Thanks again!

from exfat.

relan avatar relan commented on May 30, 2024

Looks like a valid boot sector. Please run and post here the output of those two commands:

dumpexfat /dev/sdb1

and

dumpexfat -s /dev/sdb1

dumpexfat is a part of the exfat-utils package.

from exfat.

xunmengdeganjue avatar xunmengdeganjue commented on May 30, 2024

The output of the "dumpexfat /dev/sda1" as bellow:
dumpexfat 1.2.2
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 18 30 14 40
04 0A BE BE 94 08 04 40 00 00 00 00 18 0A BE BE
00 00 00 00 68 86 00 00 98 82 00 00 E0 33 14 40
24 0A BE BE 94 08 04 40 00 80 2A 40 38 0A BE BE
00 00 00 00 D8 F7 03 40 18 F3 03 40 A0 32 14 40
44 0A BE BE 94 08 04 40 00 50 29 40 58 0A BE BE
00 00 00 00 B8 F1 2A 40 B8 A4 2A 40 00 00 00 00
64 0A BE BE EC D5 01 00 00 00 00 00 15 00 00 00
18 30 14 40 18 30 14 40 7C DF 04 40 18 85 00 00
84 0A BE BE D8 23 04 40 58 0A BE BE 00 00 00 00
00 00 00 00 58 31 14 40 01 00 00 00 7C 0A BE BE
BC 0A BE BE 01 00 00 00 13 00 00 00 BC 7E 2D 40
B2 E8 2E 40 BC 0A BE BE 00 00 00 00 E4 9A 2D 40
B2 E8 2E 40 00 15 00 00 05 00 00 00 B2 1C 00 00
3B 8A 00 00 00 03 1C 7F 08 00 00 00 08 00 00 00
03 00 00 00 16 00 00 00 08 00 00 00 08 00 00 00
03 00 00 00 00 00 00 00 00 00 00 00 A0 32 14 40
0A 00 00 00 68 92 2F 40 01 00 00 00 CC 3F 01 00
F1 0F 00 00 20 02 2D 40 68 92 2F 40 2C FE 2C 40
CD 3F 01 00 01 00 00 00 D0 3F 01 00 00 00 00 00
00 00 00 00 50 18 2D 40 58 31 14 40 54 30 14 40
D4 0C BE BE 00 00 00 00 05 00 00 00 00 00 00 00
30 E8 2E 40 29 E8 2E 40 29 E8 2E 40 37 0C BE BE
CC 3F 01 00 FF FF FF FF 00 00 00 00 73 00 00 00
00 00 00 00 20 00 00 00 00 00 00 00 01 00 00 00
13 00 00 00 00 00 01 00 03 00 00 00 08 00 00 00
08 00 00 00 08 00 00 00 08 00 00 00 08 00 00 00
08 00 00 00 08 00 00 00 08 00 00 00 B0 0C BE BE
D0 3F 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ERROR: failed to read boot sector.

And the result of the "dumpexfat -s /dev/sda1" is

dumpexfat 1.2.2
Volume serial number 0x6ba2d30d
FS version 1.0
Sector size 512
Cluster size 32768
Sectors count 15328256
Clusters count 239472
First sector 0
FAT first sector 128
FAT sectors count 1920
First cluster sector 2048
Root directory cluster 4
Volume state 0x0000
FATs count 1
Drive number 0x80
Allocated space 0%

In addition,When I try to add some Debug information into the source code,I fund that in the file io.c of the folder libexfat,the exfat_pread() may have something wrong while running on the openwrt system.Every time while this function is running the parameter offset's value is been set to be "1" but the value is set to be 0 when the function is called in the exfat_mount(). In the exfat_pread(), If I set the offset to be 0 while the exfat_pread() call the pread(),the problem of this issue will disappear,but I will gain a new problem "ERROR: invalid VBR checksum 0x459076eb (expected 0x989c1857)." .

from exfat.

relan avatar relan commented on May 30, 2024

I fund that in the file io.c of the folder libexfat,the exfat_pread() may have something wrong while running on the openwrt system.Every time while this function is running the parameter offset's value is been set to be "1" but the value is set to be 0 when the function is called in the exfat_mount().

This sounds extremely strange.

  1. Did you make any changes to the code? If so, can I have a look at them?
  2. Which OpenWRT version do you use?
  3. Is it 32- or 64-bit version?
  4. Which hardware architecture do you use?
  5. Do you use uClibc or musl?

Their wiki says you can run OpenWRT in qemu. I'll try to reproduce this issue.

from exfat.

xunmengdeganjue avatar xunmengdeganjue commented on May 30, 2024

There is no any change of the code.
My OpenWRT is not the official one. It's 32 bit,and the hardware architecture is ARM-v7 and the Linux version 3.4.103.I'm useing uClibc.

from exfat.

xunmengdeganjue avatar xunmengdeganjue commented on May 30, 2024

Hi Relan
I have tried the code in the ubuntu,and the exfat work rightly.And I found that all of the off_t data is changed to "1" while every time call the exfat_pread() func,so I'm wondring that the "off_t" type is not work rightly on my openwrt system,if so what can i do to fix it ,can you give me some guidance.Thans a lot!

from exfat.

relan avatar relan commented on May 30, 2024

The off_t type must be 64-bit. In glibc-based systems you need to define _FILE_OFFSET_BITS=64 when target platform is 32-bit. I don't know how Large File Support works in uClibc yet.

from exfat.

xunmengdeganjue avatar xunmengdeganjue commented on May 30, 2024

Ok ,thank your advice.I can try compile it with the other c libraries.
Today I changed the code,I redefined the exfat_pread() from the orignal exfat_pread(struct exfat_dev* dev, void* buffer, size_t size,off_t offset) to exfat_pread(struct exfat_dev* dev, void* buffer, size_t size,int offset), then the exfat-USB-storage can be mounted into my platform,but when I write some data to the usb-storage the system will throw out some error information,such as "Transport endpoint is not connected" and "mkdir: can't create directory 'hello': Input/output error" and so on.I have worked on this problem with many days,and the desire of the porting-succeed
is more and more stronger.
Thank you!

from exfat.

xunmengdeganjue avatar xunmengdeganjue commented on May 30, 2024

Oh ,I solved this problem,I upgrade the code version to1.2.4 from the samsung's source site. And it's compiled as a kernel module into the openwrt.By now I have not compared the difference between the two code.

from exfat.

relan avatar relan commented on May 30, 2024

I've debugged this issue a bit. The problem starts here (uClibc 0.9.33.2):

#ifndef __NR_pread
ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
{
    return __fake_pread_write(fd, buf, count, offset, 0);
}
weak_alias(__libc_pread,pread)

# ifdef __UCLIBC_HAS_LFS__
ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
{
    return __fake_pread_write64(fd, buf, count, offset, 0);
}
weak_alias(__libc_pread64,pread64)
# endif /* __UCLIBC_HAS_LFS__  */
#endif /* ! __NR_pread */

uClibc thinks there is no pread syscall and emulates it using lseek + read. This bug was fixed long ago (commit) but since then there were no stable releases.

Here is strace output of the emulated pread. It returns zeros resulting in exFAT file system is not found error:

lseek(3, 0, SEEK_CUR)                   = 0
lseek(3, 24183328, SEEK_SET)            = 24183328
read(3, "", 512)                        = 0

Note the second lseek. In this particular sample it seeks to 24183328 (should be 0) but this number changes across runs, so it looks like an ABI issue to me. Anyway, pread and pwrite are terribly broken in uClibc. Here is a workaround for this bug:

diff --git a/libexfat/io.c b/libexfat/io.c
index 3d7aaad..97de58c 100644
--- a/libexfat/io.c
+++ b/libexfat/io.c
@@ -332,7 +332,10 @@ ssize_t exfat_pread(struct exfat_dev* dev, void* buffer, size_t size,
 #ifdef USE_UBLIO
    return ublio_pread(dev->ufh, buffer, size, offset);
 #else
-   return pread(dev->fd, buffer, size, offset);
+   off_t pos = lseek(dev->fd, offset, SEEK_SET);
+   if (pos == (off_t) -1)
+       return -1;
+   return read(dev->fd, buffer, size);
 #endif
 }

@@ -342,7 +345,10 @@ ssize_t exfat_pwrite(struct exfat_dev* dev, const void* buffer, size_t size,
 #ifdef USE_UBLIO
    return ublio_pwrite(dev->ufh, buffer, size, offset);
 #else
-   return pwrite(dev->fd, buffer, size, offset);
+   off_t pos = lseek(dev->fd, offset, SEEK_SET);
+   if (pos == (off_t) -1)
+       return -1;
+   return write(dev->fd, buffer, size);
 #endif
 }

Considering that the next OpenWRT version will use musl I'd prefer not to add any hacks for uClibc-based systems.

from exfat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.