LimHD:EXT2: Difference between revisions

From Lundman Wiki
No edit summary
No edit summary
Line 37: Line 37:
  xseg000:00056908                BNE    loc_56934      ; Branch                                                                             
  xseg000:00056908                BNE    loc_56934      ; Branch                                                                             


Basically, it looks for partition type '''#7''' which is '''HPFS/NTFS''', tries to mount it with strings '''vfat''' and '''iocharset=utf8'''. If that fails, it tries '''#7''' with '''ntfs''' and '''nls=utf8'''. The partition type for Linux should be '''#83''', and changing '''ntfs''' to '''ext2''' will result in:
Basically, it uses mount flags '''#7''' which is '''READONLY|NOSUID''', tries to mount it with type '''vfat''' and mount options '''iocharset=utf8'''. If that fails, it tries '''#7''' with '''ntfs''' and '''nls=utf8'''. Changing '''ntfs''' to '''ext2''' will result in:


  EXT2-fs: Unrecognized mount option nls=utf8
  EXT2-fs: Unrecognized mount option nls=utf8
Line 46: Line 46:


I went with '''nocheck''' for now. There are a few in there that would be relatively harmless.
I went with '''nocheck''' for now. There are a few in there that would be relatively harmless.
So basically, I have decided to change '''vfat''' to '''ext2''' so that you can still mount '''ntfs''' as well as '''ext2'''.  I have changed the first '''#7''' to '''#6''' to make '''ext2''' mount in '''read-write''' mode.
=== Restarting curacao ===


The next problem is restarting '''curacao'''. It needs to be shut down in such a way that we can open '''/dev/ir''' again, which is only allowed to be opened once.
The next problem is restarting '''curacao'''. It needs to be shut down in such a way that we can open '''/dev/ir''' again, which is only allowed to be opened once.
Line 64: Line 70:


I also need to compile '''e2fsck''' and run it at boot. Maybe even '''mke2fs''' because I am nice.
I also need to compile '''e2fsck''' and run it at boot. Maybe even '''mke2fs''' because I am nice.
I have compiled a version of busybox with '''fdisk''', '''e2fsck''' and '''mkfs.ext2''' so that simple ext2 setup can be performed. I have thus made my HDD have partition 1 as '''ntfs''' and partition 2 as '''ext2''' so that I can keep testing my code against both. '''curacao''' mounts both.




Line 75: Line 83:
  #define MS_NOSUID    2      /* Ignore suid and sgid bits */
  #define MS_NOSUID    2      /* Ignore suid and sgid bits */


So, most likely there is a '''3''' somewhere. Probably in '''R4'''.
So, most likely there is a '''3''' somewhere 8actually, '''7''', see above) . Definitely in '''R3'''.
 
Unfortunately, the mount commands does a:
 
  LDR    R4, [R11, #arg_4]
 
Just before it calls sys_mount. So, I have to chase down where this is set. That isn't as easy.

Revision as of 02:31, 19 October 2007

ext2

Since I only use OsX at home, and do not really use Windows, it does not make much sense to use NTFS on the internal HDD. The Linux kernel has ext2 support, and since the limits of ext2 are quite acceptable [1] I formatted it ext2 with block size of 2048.

As it turns out, I actually had a lot of other problems, in that the HDD stops working after being on for about 10 minutes. Usually with "lost interrupt", "resetting MBUS" messages. Either the HDD is bad and dying, or my LimHD200i is bad. Either way, since I want a writable HDD, and run FTP and SMB, ext2 makes much more sense.


But, curacao does not recognise ext2 on the internal HDD. Only vfat and ntfs. The check for that is located here:


xseg000:000568A4 loc_568A4                               ; CODE XREF: print_mounted+C8vj                                                     
xseg000:000568A4                 MOV     R0, R7          ; loops here until R5 is 10                                                         
xseg000:000568A8                 LDR     R1, =aDevIdeHost0Bus ; Load from Memory                                                             
xseg000:000568AC                 MOV     R2, R5          ; Rd = Op2                                                                          
xseg000:000568B0                 BL      sprintf_2A3314  ; R1 = /dev/ide/%R5 (R2)                                                            
xseg000:000568B4                 MOV     R0, R6          ; R6 = /dev/ide/host%d                                                              
xseg000:000568B8                 LDR     R1, =aMntHdD    ; Load from Memory                                                                  
xseg000:000568BC                 MOV     R2, R5          ; Rd = Op2                                                                          
xseg000:000568C0                 BL      sprintf_2A3314  ; /mnt/HD%R5                                                                        
xseg000:000568C4                 LDR     R3, =aIocharsetUtf8_0 ; Load from Memory                                                            
xseg000:000568C8                 STR     R3, [SP,#0x88+var_88] ; Store to Memory                                                             
xseg000:000568CC                 MOV     R0, R7          ; Rd = Op2                                                                          
xseg000:000568D0                 MOV     R1, R6          ; Rd = Op2                                                                          
xseg000:000568D4                 LDR     R2, =aVfat_0    ; Load from Memory                                                                  
xseg000:000568D8                 MOV     R3, #7          ; Rd = Op2                                                                          
xseg000:000568DC                 BL      testfstype_2A9E1C ; Branch with Link                                                                
xseg000:000568E0                 CMP     R0, #0          ; Set cond. codes on Op1 - Op2                                                      
xseg000:000568E4                 BEQ     loc_5690C       ; Branch                                                                            
xseg000:000568E8                 LDR     R3, =aNlsUtf8   ; Load from Memory                                                                  
xseg000:000568EC                 STR     R3, [SP,#0x88+var_88] ; Store to Memory                                                             
xseg000:000568F0                 SUB     R0, R11, #0x60  ; Rd = Op1 - Op2                                                                    
xseg000:000568F4                 SUB     R1, R11, #0x80  ; Rd = Op1 - Op2                                                                    
xseg000:000568F8                 LDR     R2, =aNtfs_0    ; Load from Memory                                                                  
xseg000:000568FC                 MOV     R3, #7          ; Rd = Op2                                                                          
xseg000:00056900                 BL      testfstype_2A9E1C ; Branch with Link                                                                
xseg000:00056904                 CMP     R0, #0          ; Set cond. codes on Op1 - Op2                                                      
xseg000:00056908                 BNE     loc_56934       ; Branch                                                                             

Basically, it uses mount flags #7 which is READONLY|NOSUID, tries to mount it with type vfat and mount options iocharset=utf8. If that fails, it tries #7 with ntfs and nls=utf8. Changing ntfs to ext2 will result in:

EXT2-fs: Unrecognized mount option nls=utf8

So, we need to replace the mount option nls=utf8 as well. According to linux-2.4.22-em86xx/fs/ext2/super.c we can chose from:

bsddf nouid32 check debug errors=continue/remount-ro/panic) grpid bsdgroups minixdf nocheck nogrpid sysvgroups resgid resuid sb grpquota noquota quota usrquota

I went with nocheck for now. There are a few in there that would be relatively harmless.

So basically, I have decided to change vfat to ext2 so that you can still mount ntfs as well as ext2. I have changed the first #7 to #6 to make ext2 mount in read-write mode.


Restarting curacao

The next problem is restarting curacao. It needs to be shut down in such a way that we can open /dev/ir again, which is only allowed to be opened once.

First you kill the curacao process, usually the lowest pid. Then you should kill all the udhcpc processes, (I used highest pid to lowest order, does this matter?) and if you ran cat /proc/kmsg & before then, you should get this message:

<7>ir: Disable NEC decoder
<7>ir: Disable RC5 decoder
<7>ir: Disable RC6 decoder

Sweet, now you can start curacao again, I use Samba mount.

/mnt/smbfs/curacao-ext2 /mnt /dev/ir

I can not provide the patched binary of curacao sorry!

Naturally, eventually I will roll my own firmware with my version of curacao but you really want to make sure it works before you do that, since without a working curacao you can not flash a new firmware!. This is why I did it this way for now.

I also need to compile e2fsck and run it at boot. Maybe even mke2fs because I am nice.

I have compiled a version of busybox with fdisk, e2fsck and mkfs.ext2 so that simple ext2 setup can be performed. I have thus made my HDD have partition 1 as ntfs and partition 2 as ext2 so that I can keep testing my code against both. curacao mounts both.


read-only

/dev/ide/host0/bus0/target0/lun0/part1 on /mnt/HD1 type ext2 (ro,nosuid)

Alas, it is mounted read-only. I need to find this option next.

#define MS_RDONLY    1      /* Mount read-only */
#define MS_NOSUID    2      /* Ignore suid and sgid bits */

So, most likely there is a 3 somewhere 8actually, 7, see above) . Definitely in R3.