Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zalman VE-200 cannot read images from the _ISO directory created by fuse-exfat #4

Closed
Thermionix opened this issue Sep 9, 2015 · 15 comments

Comments

@Thermionix
Copy link

I'm attempting to format a disk for use in a Zalman VE-200 (which loads ISOs from a folder on the first partition), the folder works when the disk is formatted to exFat using windows - but not with mkfs.exfat.

format.sh;

#!/bin/bash
set -e
DSK=/dev/sdb
sudo dd if=/dev/zero of=${DSK} bs=512 count=4000
sudo sgdisk --zap-all ${DSK} || /bin/true
sleep 1
echo "# partitioning ${DSK}"
sudo parted -s ${DSK} mklabel msdos
sudo parted -s ${DSK} mkpart primary ntfs 2048s 100%
sudo mkfs.exfat -n multipass -p 2048 ${DSK}1
sleep 1
sudo partprobe ${DSK}
sudo fdisk -l ${DSK}
sudo dumpexfat ${DSK}1

format output:

2048000 bytes (2.0 MB) copied, 0.37823 s, 5.4 MB/s
Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
# partitioning /dev/sdb
mkexfatfs 1.1.1
Creating... done.
Flushing... done.
File system created successfully.
Disk /dev/sdb: 59.6 GiB, 64023257088 bytes, 125045424 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x14075162

Device     Boot Start       End   Sectors  Size Id Type
/dev/sdb1        2048 125044735 125042688 59.6G  7 HPFS/NTFS/exFAT
dumpexfat 1.1.1
Volume label               multipass
Volume serial number      0x6ceeb113
FS version                       1.0
Sector size                      512
Cluster size                  131072
Sectors count              125042688
Free sectors               125037312
Clusters count                488432
Free clusters                 488427
First sector                    2048
FAT first sector                 128
FAT sectors count               3968
First cluster sector            4096
Root directory cluster             4
Volume state                  0x0000
FATs count                         1
Drive number                    0x80
Allocated space                   0%

dump from disk formatted by windows:

dumpexfat 1.1.1
Volume label                        
Volume serial number      0xa8788af7
FS version                       1.0
Sector size                      512
Cluster size                  131072
Sectors count              125042688
Free sectors               125035264
Clusters count                488424
Free clusters                 488419
First sector                    2048
FAT first sector                2048
FAT sectors count               3840
First cluster sector            6144
Root directory cluster             4
Volume state                  0x0002
FATs count                         1
Drive number                    0x80
Allocated space                   0%

The only difference of note between them seems to be FAT first sector - win : 2048 mkfs : 128

any hints on where to go from here?

@relan
Copy link
Owner

relan commented Sep 9, 2015

Could you try the following patch?

diff --git a/mkfs/fat.c b/mkfs/fat.c
index c70dc86..0e9e4b0 100644
--- a/mkfs/fat.c
+++ b/mkfs/fat.c
@@ -28,7 +28,7 @@

 static off_t fat_alignment(void)
 {
-       return (off_t) 128 * get_sector_size();
+       return (off_t) 2048 * get_sector_size();
 }

 static off_t fat_size(void)

This will make FAT begin at 1 MB offset.

Actually first cluster sector is also different and this may be important for Zalman's implementation of exFAT. Let's check it if the patch above does not help.

@Thermionix
Copy link
Author

Ok, now I'm reasonably confused.

I applied the patch and compiled, reformatted with and created the _ISO folder - still not detected by the firmware.

So, I re-ran the original script (128 first sector)
Unmounted, plugged the drive into windows, created the _ISO folder, unmounted, plugged into linux, mounted with fuse and copied in ISOs into the _ISO folder and it's now detected.

So seems to be related to folder creation under fuse.

I've now reproduced this;

Create _ISO folder at end of format.sh:

sudo mount ${DSK}1 /mnt
sudo mkdir /mnt/_ISO
sudo umount /mnt

Copy in some files to _ISO
_ISO not detected by firmware
Delete folder
Create _ISO folder on windows
Copy in clonezilla.iso to _ISO on linux
_ISO folder is detected by firmware

lin-created _ISO :
$ ls -la _ISO/
total 178560
drwx------ 1 thermionix users    131072 Sep  9 16:34 .
drwx------ 1 thermionix users    131072 Jan  1  1970 ..
-rwx------ 1 thermionix users 182452224 Aug  5 09:53 clonezilla-live-2.4.2-32-i686-pae.iso
-rwx------ 1 thermionix users        72 Aug 27 17:43 clonezilla-live-2.4.2-32-i686-pae.iso.md5

win-created _ISO :
$ ls -la
total 178560
drwx------ 1 thermionix users    131072 Sep  9 16:44 .
drwx------ 1 thermionix users    131072 Jan  1  1970 ..
-rwx------ 1 thermionix users 182452224 Aug  5 09:53 clonezilla-live-2.4.2-32-i686-pae.iso
-rwx------ 1 thermionix users        72 Aug 27 17:43 clonezilla-live-2.4.2-32-i686-pae.iso.md5

ls output is the same

anything further I can do to debug the folder diff?

@relan
Copy link
Owner

relan commented Sep 9, 2015

anything further I can do to debug the folder diff?

Yes, it would be useful to compare root directories with the _ISO subdirectory created by Windows and by fuse-exfat. Please dump both using this command:

hexdump -C /dev/sdX | grep -A 32 '^.....000  [08]3 '

@Thermionix
Copy link
Author

format.sh, create folder _ISO using fuse:
hex.lin.dump

00240000  83 09 6d 00 75 00 6c 00  74 00 69 00 70 00 61 00  |..m.u.l.t.i.p.a.|
00240010  73 00 73 00 00 00 00 00  00 00 00 00 00 00 00 00  |s.s.............|
00240020  81 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00240030  00 00 00 00 02 00 00 00  7e ee 00 00 00 00 00 00  |........~.......|
00240040  82 00 00 00 0d d3 19 e6  00 00 00 00 00 00 00 00  |................|
00240050  00 00 00 00 03 00 00 00  cc 16 00 00 00 00 00 00  |................|
00240060  05 02 f1 4d 30 00 00 00  6f bd 29 47 6f bd 29 47  |...M0...o.)Go.)G|
00240070  6f bd 29 47 00 00 00 00  00 00 00 00 00 00 00 00  |o.)G............|
00240080  40 03 00 0f 93 f2 00 00  00 00 02 00 00 00 00 00  |@...............|
00240090  00 00 00 00 05 00 00 00  00 00 02 00 00 00 00 00  |................|
002400a0  41 00 75 00 6e 00 74 00  69 00 74 00 6c 00 65 00  |A.u.n.t.i.t.l.e.|
002400b0  64 00 20 00 66 00 6f 00  6c 00 64 00 65 00 72 00  |d. .f.o.l.d.e.r.|
002400c0  85 02 fb 75 30 00 00 00  6f bd 29 47 6f bd 29 47  |...u0...o.)Go.)G|
002400d0  6f bd 29 47 00 00 00 00  00 00 00 00 00 00 00 00  |o.)G............|
002400e0  c0 03 00 04 34 e6 00 00  00 00 02 00 00 00 00 00  |....4...........|
002400f0  00 00 00 00 05 00 00 00  00 00 02 00 00 00 00 00  |................|
00240100  c1 00 5f 00 49 00 53 00  4f 00 00 00 00 00 00 00  |.._.I.S.O.......|
00240110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

format.sh, create folder _ISO using windows:
hex.win.dump

00240000  83 09 6d 00 75 00 6c 00  74 00 69 00 70 00 61 00  |..m.u.l.t.i.p.a.|
00240010  73 00 73 00 00 00 00 00  00 00 00 00 00 00 00 00  |s.s.............|
00240020  81 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00240030  00 00 00 00 02 00 00 00  7e ee 00 00 00 00 00 00  |........~.......|
00240040  82 00 00 00 0d d3 19 e6  00 00 00 00 00 00 00 00  |................|
00240050  00 00 00 00 03 00 00 00  cc 16 00 00 00 00 00 00  |................|
00240060  85 02 8f 17 10 00 00 00  48 be 29 47 48 be 29 47  |........H.)GH.)G|
00240070  48 be 29 47 b5 b5 a8 a8  a8 00 00 00 00 00 00 00  |H.)G............|
00240080  c0 03 00 04 34 e6 00 00  00 00 02 00 00 00 00 00  |....4...........|
00240090  00 00 00 00 05 00 00 00  00 00 02 00 00 00 00 00  |................|
002400a0  c1 00 5f 00 49 00 53 00  4f 00 00 00 00 00 00 00  |.._.I.S.O.......|
002400b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

@relan
Copy link
Owner

relan commented Sep 9, 2015

The only difference I see is the archive bit. Please try this patch:

diff --git a/libexfat/node.c b/libexfat/node.c
index 6e18c09..f3d10e0 100644
--- a/libexfat/node.c
+++ b/libexfat/node.c
@@ -973,7 +973,7 @@ int exfat_mkdir(struct exfat* ef, const char* path)
        int rc;
        struct exfat_node* node;

-       rc = create(ef, path, EXFAT_ATTRIB_ARCH | EXFAT_ATTRIB_DIR);
+       rc = create(ef, path, EXFAT_ATTRIB_DIR);
        if (rc != 0)
                return rc;
        rc = exfat_lookup(ef, &node, path);

@Thermionix
Copy link
Author

Yep, Thanks! that works

for prosterity hex.lin2.dump:

00240000  83 09 6d 00 75 00 6c 00  74 00 69 00 70 00 61 00  |..m.u.l.t.i.p.a.|
00240010  73 00 73 00 00 00 00 00  00 00 00 00 00 00 00 00  |s.s.............|
00240020  81 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00240030  00 00 00 00 02 00 00 00  7e ee 00 00 00 00 00 00  |........~.......|
00240040  82 00 00 00 0d d3 19 e6  00 00 00 00 00 00 00 00  |................|
00240050  00 00 00 00 03 00 00 00  cc 16 00 00 00 00 00 00  |................|
00240060  05 02 20 72 10 00 00 00  ad 4d 2a 47 ad 4d 2a 47  |.. r.....M*G.M*G|
00240070  ad 4d 2a 47 64 64 00 00  00 00 00 00 00 00 00 00  |.M*Gdd..........|
00240080  40 03 00 0f 93 f2 00 00  00 00 02 00 00 00 00 00  |@...............|
00240090  00 00 00 00 05 00 00 00  00 00 02 00 00 00 00 00  |................|
002400a0  41 00 75 00 6e 00 74 00  69 00 74 00 6c 00 65 00  |A.u.n.t.i.t.l.e.|
002400b0  64 00 20 00 66 00 6f 00  6c 00 64 00 65 00 72 00  |d. .f.o.l.d.e.r.|
002400c0  85 02 2a 9a 10 00 00 00  ad 4d 2a 47 ad 4d 2a 47  |..*......M*G.M*G|
002400d0  ad 4d 2a 47 64 64 00 00  00 00 00 00 00 00 00 00  |.M*Gdd..........|
002400e0  c0 03 00 04 34 e6 00 00  00 00 02 00 00 00 00 00  |....4...........|
002400f0  00 00 00 00 05 00 00 00  00 00 02 00 00 00 00 00  |................|
00240100  c1 00 5f 00 49 00 53 00  4f 00 00 00 00 00 00 00  |.._.I.S.O.......|
00240110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

@relan
Copy link
Owner

relan commented Sep 10, 2015

Fine! Thanks for spending your time for this investigation. I've pushed the fix into issue4 branch, will close this issue when I make a release.

@relan relan changed the title mkfs.exfat FAT first sector Zalman VE-200 cannot read images from the _ISO directory created by fuse-exfat Sep 10, 2015
@Thermionix
Copy link
Author

Much appreciated for the help!

Another quick question, the FAT first sector is that of the partition or of the disk? (i.e. if I embed grub2, could there be any collision?)

@relan
Copy link
Owner

relan commented Sep 24, 2015

the FAT first sector is that of the partition or of the disk?

It's relative to the beginning of the partition.

if I embed grub2, could there be any collision?

I have no idea how grub2 works, sorry.

@relan relan closed this as completed Sep 24, 2015
@teknoraver
Copy link

Hi,

I'm finding the archive bit in newly created files, how can this be possible?

@relan
Copy link
Owner

relan commented Jan 18, 2019

Hi,

I'm finding the archive bit in newly created files, how can this be possible?

This is possible because fuse-exfat code does so, see exfat_mknod().

@teknoraver
Copy link

Hi,

I'm finding the archive bit in newly created files, how can this be possible?

This is possible because fuse-exfat code does so, see exfat_mknod().

I see. How can I remove the archive bit? Some devices refuses to read the files with such bit.

@relan
Copy link
Owner

relan commented Jan 19, 2019

How can I remove the archive bit?

You can modiy fuse-exfat source code. There's no option to manage the archive bit.

Some devices refuses to read the files with such bit.

I don't think that archive bit per se is a problem because Windows also sets it.

@teknoraver
Copy link

How can I remove the archive bit?

You can modiy fuse-exfat source code. There's no option to manage the archive bit.

Every time? Can't we add the possibility to change the but eg. via XATTRS?

Some devices refuses to read the files with such bit.

I don't think that archive bit per se is a problem because Windows also sets it.

Yes, but Windows also allows to clear it.

@relan
Copy link
Owner

relan commented Jan 19, 2019

Can't we add the possibility to change the but eg. via XATTRS?

This would be nice to have. Patches are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants