Skip to content

Commit

Permalink
Merge pull request ps2dev#681 from uyjulian/iomanx_file_struct_stk
Browse files Browse the repository at this point in the history
iomanX use stack instead of static data for temporary file structs
  • Loading branch information
fjtrujy authored Nov 28, 2024
2 parents a7d5229 + e913f79 commit 89d7ece
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion iop/system/iomanx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

IOP_BIN ?= iomanX.irx

IOP_CFLAGS += -DIOMANX_OLD_NAME_ADDDELDRV=0 -DIOMANX_OLD_NAME_COMPATIBILITY=0 -DIOMANX_ENABLE_LEGACY_IOMAN_HOOK
IOP_CFLAGS += -DIOMANX_OLD_NAME_ADDDELDRV=0 -DIOMANX_OLD_NAME_COMPATIBILITY=0 -DIOMANX_ENABLE_LEGACY_IOMAN_HOOK -DIOMAN_USE_FILE_STRUCT_TEMP_STACK

IOP_OBJS = iomanX.o ioman_sbv.o exports.o imports.o

Expand Down
63 changes: 63 additions & 0 deletions iop/system/iomanx/src/iomanX.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,17 @@ int iomanX_remove(const char *name)
{
iomanX_iop_file_t *f;
const char *parsefile_res;
#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
iomanX_iop_file_t f_stk;
#endif

#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
f = &f_stk;
#else
f = new_iob();
if ( !f )
return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
#endif
parsefile_res = parsefile(name, &(f->device), &(f->unit));
if ( !parsefile_res )
return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
Expand All @@ -633,10 +640,17 @@ static int xx_stat(int op, const char *name, iox_stat_t *stat, unsigned int stat
{
iomanX_iop_file_t *f;
const char *parsefile_res;
#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
iomanX_iop_file_t f_stk;
#endif

#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
f = &f_stk;
#else
f = new_iob();
if ( !f )
return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
#endif
parsefile_res = parsefile(name, &(f->device), &(f->unit));
if ( !parsefile_res )
return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
Expand Down Expand Up @@ -702,10 +716,17 @@ int iomanX_format(const char *dev, const char *blockdev, void *arg, int arglen)
{
iomanX_iop_file_t *f;
const char *parsefile_res;
#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
iomanX_iop_file_t f_stk;
#endif

#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
f = &f_stk;
#else
f = new_iob();
if ( !f )
return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
#endif
parsefile_res = parsefile(dev, &(f->device), &(f->unit));
if ( !parsefile_res )
return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
Expand All @@ -722,10 +743,17 @@ static int xx_rename(int op, const char *oldname, const char *newname)
const char *parsefile_res_new;
iomanX_iop_device_t *device_new;
int unit_new;
#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
iomanX_iop_file_t f_stk;
#endif

#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
f = &f_stk;
#else
f = new_iob();
if ( !f )
return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
#endif
parsefile_res = parsefile(oldname, &(f->device), &(f->unit));
if ( !parsefile_res )
return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
Expand Down Expand Up @@ -783,10 +811,17 @@ static int xx_dir(int op, const char *name, int mode)
{
iomanX_iop_file_t *f;
const char *parsefile_res;
#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
iomanX_iop_file_t f_stk;
#endif

#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
f = &f_stk;
#else
f = new_iob();
if ( !f )
return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
#endif
parsefile_res = parsefile(name, &(f->device), &(f->unit));
if ( !parsefile_res )
return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
Expand Down Expand Up @@ -822,10 +857,17 @@ int iomanX_mount(const char *fsname, const char *devname, int flag, void *arg, i
{
iomanX_iop_file_t *f;
const char *parsefile_res;
#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
iomanX_iop_file_t f_stk;
#endif

#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
f = &f_stk;
#else
f = new_iob();
if ( !f )
return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
#endif
parsefile_res = parsefile(fsname, &(f->device), &(f->unit));
if ( !parsefile_res )
return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
Expand All @@ -842,10 +884,17 @@ int iomanX_umount(const char *fsname)
{
iomanX_iop_file_t *f;
const char *parsefile_res;
#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
iomanX_iop_file_t f_stk;
#endif

#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
f = &f_stk;
#else
f = new_iob();
if ( !f )
return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
#endif
parsefile_res = parsefile(fsname, &(f->device), &(f->unit));
if ( !parsefile_res )
return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
Expand All @@ -860,10 +909,17 @@ int iomanX_devctl(const char *name, int cmd, void *arg, unsigned int arglen, voi
{
iomanX_iop_file_t *f;
const char *parsefile_res;
#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
iomanX_iop_file_t f_stk;
#endif

#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
f = &f_stk;
#else
f = new_iob();
if ( !f )
return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
#endif
parsefile_res = parsefile(name, &(f->device), &(f->unit));
if ( !parsefile_res )
return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
Expand All @@ -878,10 +934,17 @@ int iomanX_readlink(const char *path, char *buf, unsigned int buflen)
{
iomanX_iop_file_t *f;
const char *parsefile_res;
#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
iomanX_iop_file_t f_stk;
#endif

#ifdef IOMAN_USE_FILE_STRUCT_TEMP_STACK
f = &f_stk;
#else
f = new_iob();
if ( !f )
return handle_result(-EMFILE, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
#endif
parsefile_res = parsefile(path, &(f->device), &(f->unit));
if ( !parsefile_res )
return handle_result(-ENODEV, f, HANDLE_RESULT_CLEAR_INFO_ON_ERROR);
Expand Down

0 comments on commit 89d7ece

Please sign in to comment.