hdd listing

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

Moderators: cheriff, Herben

Post Reply
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

hdd listing

Post by radad »

I am trying to list the partitions on the hd but it is not working correctly. The sizes and number of partitions looks correct but the names dont work.

Can someone please help me and tell where I am going wrong.

Here is some test code:

Code: Select all

#include <tamtypes.h>
#include <sifrpc.h>
#include <debug.h>
#include <loadfile.h>
#include <iopheap.h>
#include <iopcontrol.h>
#include <kernel.h>
#include <fileXio_rpc.h>
#include <libhdd.h>
#include <string.h>

#define RESET_IOP

extern u8 *iomanx_irx;
extern int size_iomanx_irx;
extern u8 *filexio_irx;
extern int size_filexio_irx;
extern u8 *ps2dev9_irx;
extern int size_ps2dev9_irx;
extern u8 *ps2atad_irx;
extern int size_ps2atad_irx;
extern u8 *ps2hdd_irx;
extern int size_ps2hdd_irx;

int main&#40;&#41;
&#123;
#ifdef RESET_IOP
    SifInitRpc&#40;0&#41;;
    SifIopReset&#40;"rom0&#58;UDNL rom0&#58;EELOADCNF", 0&#41;;
    while &#40;SifIopSync&#40;&#41;&#41;
        ;
#endif
    SifInitRpc&#40;0&#41;;
    
    init_scr&#40;&#41;;
    scr_printf&#40;"HDD Test\n"&#41;;
    
    int ret;
    
    ret = SifExecModuleBuffer&#40;&iomanx_irx, size_iomanx_irx, 0, NULL, &ret&#41;;
    scr_printf&#40;"Loaded iomanX.irx %d\n", ret&#41;;
    
    
    ret = SifExecModuleBuffer&#40;&ps2dev9_irx, size_ps2dev9_irx, 0, NULL, &ret&#41;;
    scr_printf&#40;"Loaded ps2dev9.irx %d\n", ret&#41;;
    
    ret = SifExecModuleBuffer&#40;&ps2atad_irx, size_ps2atad_irx, 0, NULL, &ret&#41;;
    scr_printf&#40;"Loaded ps2atad.irx %d\n", ret&#41;;
    
    ret = SifExecModuleBuffer&#40;&ps2hdd_irx, size_ps2hdd_irx, 0, NULL, &ret&#41;;
    scr_printf&#40;"Loaded ps2hdd.irx %d\n", ret&#41;;

    ret = SifExecModuleBuffer&#40;&filexio_irx, size_filexio_irx, 0, NULL, &ret&#41;;
    scr_printf&#40;"Loaded fileXio.irx %d\n", ret&#41;;
    
    ret = fileXioInit&#40;&#41;;
    scr_printf&#40;"fileXioInit %d\n", ret&#41;;
    
    int fd;
    
    fd = fileXioDopen&#40;"hdd0&#58;/"&#41;;
    scr_printf&#40;"fileXioDopen %d\n", ret&#41;;
    
    while &#40;1&#41;
    &#123;
        iox_dirent_t l_dir_entry __attribute__&#40;&#40;aligned&#40;64&#41;&#41;&#41;;

        ret = fileXioDread&#40;fd, &l_dir_entry&#41;;
        if &#40;ret == 0&#41;
            break;
        
        if &#40;&#40; l_dir_entry.stat.attr  & ATTR_SUB_PARTITION&#41; ||
            &#40; l_dir_entry.stat.mode == FS_TYPE_EMPTY&#41; ||
            &#40; l_dir_entry.stat.mode == 0x1337&#41; ||
            &#40;strncmp&#40;l_dir_entry.name, "__", 2&#41; == 0&#41;&#41;
            continue;

        scr_printf&#40;"fileXioDread %d\t", ret&#41;;

        scr_printf&#40;"\"%s\"%c\t%x\t%x\t%d\n",
            l_dir_entry.name,
            FIO_S_ISDIR&#40;l_dir_entry.stat.mode&#41; ? '/' &#58; ' ',
            l_dir_entry.stat.mode,
            l_dir_entry.stat.attr,
            l_dir_entry.stat.size&#41;;
    &#125;

    ret = fileXioDclose&#40;fd&#41;;
    scr_printf&#40;"fileXioDclose %d\n", ret&#41;;

    return 0;
&#125;
EEUG
Posts: 136
Joined: Fri May 13, 2005 4:49 am
Location: The Netherlands

Post by EEUG »

...iomanX module from SVN is the reason for that. SMS uses one from ps2link's distribution, so if you take it from there then your problem will be solved :)...
EP
Posts: 39
Joined: Sat Nov 05, 2005 1:14 pm

Post by EP »

OK I had done some investigating on the issue with iomanX.irx. I can safely say that it is do to some changes that herben submitted back in February. I recompiled the module using the older source for iomanX.c file dated October 11, 2004. Maybe it could be possible to fix the partition display mess another way but I'm still not sure.

Location of the file in the sdk is for those that are interested: ps2sdk/iop/system/iomanx/src/iomanx.c

In other words, use Rev 629 of iomanX.c instead of Rev 799 or Rev 864. Compile the iomanX.irx module and that should resolve the issue.
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

Post by radad »

Thanks guys. I am going to have a closer look at the sources.

I can see the change is the introduction of iox_dirent_t. This has some extra fields. It appears the extra fields are never used though. Does anybody see any need for iox_dirent_t? Should I remove it and go back to io_dirent_t?

I shall have a closer look tonight.
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

Post by radad »

Ok, I think the dread function in iomanx.c needs to be changed to this:

Code: Select all

int dread&#40;int fd, void *buf&#41;
&#123;
    iox_dirent_t *iox_dirent = &#40;iox_dirent_t *&#41; buf;
    iop_file_t *f = get_file&#40;fd&#41;;
    int res;
    
    if &#40;f == NULL ||  !&#40;f->mode & 8&#41;&#41;
            return -EBADF;
    
    /* If this is a legacy device &#40;such as mc&#58;&#41; then we need to convert the mode
       variable of the stat structure to iomanX's extended format.  */
    if &#40;&#40;f->device->type & 0xf0000000&#41; != IOP_DT_FSEXT&#41;
    &#123;
        io_dirent_t io_dirent;
        res = f->device->ops->dread&#40;f, &io_dirent&#41;;
        
        iox_dirent->stat.mode = mode2modex&#40;io_dirent.stat.mode&#41;;
        iox_dirent->stat.attr = io_dirent.stat.attr;
        iox_dirent->stat.size = io_dirent.stat.size;
        memcpy&#40;iox_dirent->stat.ctime, io_dirent.stat.ctime, sizeof&#40;io_dirent.stat.ctime&#41;&#41;;
        memcpy&#40;iox_dirent->stat.atime, io_dirent.stat.atime, sizeof&#40;io_dirent.stat.atime&#41;&#41;;
        memcpy&#40;iox_dirent->stat.mtime, io_dirent.stat.mtime, sizeof&#40;io_dirent.stat.mtime&#41;&#41;;
        iox_dirent->stat.hisize = io_dirent.stat.hisize;
    
        strncpy&#40;iox_dirent->name, io_dirent.name, sizeof&#40;iox_dirent->name&#41;&#41;;
    &#125;
    else
        res = f->device->ops->dread&#40;f, iox_dirent&#41;;

    return res;
&#125;
I shall test it out tonight.
EP
Posts: 39
Joined: Sat Nov 05, 2005 1:14 pm

Post by EP »

Thanks radad, works fine. Tested my new compiles of uLaunchELF and ps2link with those changes to iomanX.

Turns out that iomanX file was the root cause of the problem I was having with ps2link. I guess I should have known.

Hope those changes can be approved and added it to SVN.
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

Post by radad »

I tried it out last night and my above test now works. It also works in ps2link as EP pointed out.

Can someone please check this in? Or can I have write permission to svn and I will check it in myself.
Post Reply