ROMDIR filesystem in userspace

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
misfire
Posts: 110
Joined: Mon Sep 06, 2004 7:53 am
Location: Germany

ROMDIR filesystem in userspace

Post by misfire »

Here's romdirfs - my first attempt at writing a userspace filesystem.

From the README:

Code: Select all

---===========---
   About romdirfs
---==============---

romdirfs was mainly developed because I was interested in the technology behind
FUSE (Filesystem in Userspace) and wanted to implement a simple FS on my own.
(With the FUSE interface, you can easily export a virtual FS to the Linux
kernel without root privileges.)

romdirfs makes it possible to mount the ROMDIR "filesystem" which can be found
in PS2 IOPRP images and BIOS dumps to a directory, thereby mapping the included
IOP modules to actual files. The filesystem is read-only.


---==---
   Build
---=====---

To compile romdirfs, you need the following Debian packages:
- cmake >= 2.6
- gcc
- fuse-utils
- libfuse-dev >= 2.6

I recommend doing an out-of-source build:
$ mkdir build
$ cd build
$ cmake ..
$ make

To install romdirfs:
# make install


---==---
   Usage
---=====---

usage&#58; romdirfs <file> <mountpoint> &#91;options&#93;
<file> must be a PS2 IOPRP image or BIOS dump

ROMDIRFS options&#58;
    -V, --version          print version
    -h, --help             print help
    -D, -o romdirfs_debug  print some debugging information

You can get the complete option list with -h.

To unmount the filesystem&#58;
fusermount -u <mountpoint>


---=====--
   Samples
---=======---

    1&#41; Mounting a PS2 IOPRP image

$ mkdir /tmp/romdir
$ romdirfs ioprp15.img /tmp/romdir/

$ mount | grep romdirfs
romdirfs on /tmp/romdir type fuse.romdirfs &#40;rw,nosuid,nodev,user=misfire&#41;

$ ls -l /tmp/romdir/
total 0
-r--r--r-- 1 root root 28533 1970-01-01 01&#58;00 CDVDFSV
-r--r--r-- 1 root root 35317 1970-01-01 01&#58;00 CDVDMAN
-r--r--r-- 1 root root   208 1970-01-01 01&#58;00 EXTINFO
-r--r--r-- 1 root root  9085 1970-01-01 01&#58;00 FILEIO
-r--r--r-- 1 root root     0 1970-01-01 01&#58;00 RESET
-r--r--r-- 1 root root   128 1970-01-01 01&#58;00 ROMDIR
-r--r--r-- 1 root root  9441 1970-01-01 01&#58;00 SIFCMD

$ hd /tmp/romdir/ROMDIR
00000000  52 45 53 45 54 00 00 00  00 00 08 00 00 00 00 00  |RESET...........|
00000010  52 4f 4d 44 49 52 00 00  00 00 44 00 80 00 00 00  |ROMDIR....D.....|
00000020  45 58 54 49 4e 46 4f 00  00 00 00 00 d0 00 00 00  |EXTINFO.........|
00000030  53 49 46 43 4d 44 00 00  00 00 28 00 e1 24 00 00  |SIFCMD....&#40;..$..|
00000040  46 49 4c 45 49 4f 00 00  00 00 20 00 7d 23 00 00  |FILEIO.... .&#125;#..|
00000050  43 44 56 44 4d 41 4e 00  00 00 1c 00 f5 89 00 00  |CDVDMAN.........|
00000060  43 44 56 44 46 53 56 00  00 00 20 00 75 6f 00 00  |CDVDFSV... .uo..|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000080

$ fusermount -u /tmp/romdir/

    2&#41; Mounting a PS2 BIOS dump

$ romdirfs SCPH-30004R_BIOS_V4_PAL_160.BIN /tmp/romdir/

$ ls /tmp/romdir/
ADDDRV     EXTINFO    IOPBOOT    MODLOAD  ROMDRV    SYSMEM     VBLANK
ATAD       FILEIO     IOPBTCON2  OSDCNF   ROMVER    TBIN       VERSTR
CDVDFSV    FNTIMAGE   IOPBTCONF  OSDSND   SBIN      TESTMODE   XCDVDFSV
CDVDMAN    FONTM      KERNEL     OSDSYS   SECRMAN   TESTSPU    XCDVDMAN
CLEARSPU   HDDLOAD    KROM       PADMAN   SIFCMD    TEXIMAGE   XFILEIO
DMACMAN    HDDOSD     KROMG      PS1DRV   SIFINIT   THREADMAN  XLOADFILE
EECONF     HEAPLIB    LIBSD      PS2LOGO  SIFMAN    TIMEMANI   XMCMAN
EELOAD     ICOIMAGE   LOADCORE   RDRAM    SIO2MAN   TIMEMANP   XMCSERV
EELOADCNF  IGREETING  LOADFILE   REBOOT   SNDIMAGE  TPADMAN    XMTAPMAN
EENULL     INTRMANI   LOGO       RESET    SSBUSC    TSIO2MAN   XPADMAN
EESYNC     INTRMANP   MCMAN      RMRESET  STDIO     TZLIST     XSIFCMD
EXCEPMAN   IOMAN      MCSERV     ROMDIR   SYSCLIB   UDNL       XSIO2MAN

$ cat /tmp/romdir/ROMVER
0160EC20010704

$ fusermount -u /tmp/romdir/
romdirfs-1.0.tar.gz
yoshi314
Posts: 36
Joined: Sat Jul 26, 2008 11:19 pm

Post by yoshi314 »

looks cool, i'll give it a shot.
misfire
Posts: 110
Joined: Mon Sep 06, 2004 7:53 am
Location: Germany

Post by misfire »

Cool, the first user. :)
yownas
Posts: 4
Joined: Wed Aug 12, 2009 7:13 pm

Post by yownas »

I tried it the other day. It worked great. :)
yownas
Posts: 4
Joined: Wed Aug 12, 2009 7:13 pm

Post by yownas »

I added some basic write-support for romdirfs.

Notes:
* EXTINFO is ignored for all files and lost if any file is updated.
* The content of ROMDIR isn't updated until you remount the file system.
* Appending to files is not supported. But most commands such as cp, mv, editing and overwriting files should work.
* Unlinked (deleted) files will be removed from memory even if it is still open. Accessing a removed file will probably result in a segfault.
* The order of the files written to the romdirfile isn't controlled in any way. Removing RESET or ROMDIR will probably result in a messed up romdirfile.

If you still wan't to test it the source could be found here:

romdirfs-1.1.tar.gz
misfire
Posts: 110
Joined: Mon Sep 06, 2004 7:53 am
Location: Germany

Post by misfire »

Ah, cool. :)

I updated romdirfs too and added some EXTINFO (read) support.

Originally, I also thought about write support but I've actually never felt the need for it. Although I don't know if things like EXTINFO, file order etc. actually matter to the IOP image loader, I guess that proper write support is really hard to accomplish with a virtual FS. A simple user-space tool would do a better job.

Anyway, good work. Interesting to see how writing can be done.
misfire
Posts: 110
Joined: Mon Sep 06, 2004 7:53 am
Location: Germany

Post by misfire »

Here is my new version: romdirfs-1.1.tar.gz

Code: Select all

1.1 &#40;Aug 25 2009&#41;
- Read whole input file into memory rather than reading each module's data.
- Define -DUSE_MMAP to map the input file into memory with mmap&#40;&#41;.
- Add EXTINFO information to romfile_t struct.
Unfortunately, it's now more a read-only filesystem than before.
misfire
Posts: 110
Joined: Mon Sep 06, 2004 7:53 am
Location: Germany

Post by misfire »

FYI, romdirfs now has its own online repository: http://bitbucket.org/misfire/romdirfs/
Post Reply