From f98bc7fea7e892231f1e548d43c85c091bcc35da Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 14 Nov 2024 15:29:15 +0100 Subject: [PATCH] try loading boot firmware from opt.datadir also --- src/x49gpng/module.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/x49gpng/module.c b/src/x49gpng/module.c index 77cc855..f3b2f9a 100644 --- a/src/x49gpng/module.c +++ b/src/x49gpng/module.c @@ -383,6 +383,20 @@ int x49gp_module_open_rodata( x49gp_module_t* module, const char* name, char** p fd = open( *path, O_RDONLY ); + if ( fd < 0 && ( errno == EACCES || errno == ENOENT ) ) { + g_free( *path ); + + *path = g_build_filename( opt.datadir, name, NULL ); + if ( opt.verbose ) + fprintf( stderr, "reading %s\n", *path ); + if ( NULL == *path ) { + fprintf( stderr, "%s: %s:%u: Out of memory\n", module->name, __FUNCTION__, __LINE__ ); + return -ENOMEM; + } + + fd = open( *path, O_RDONLY ); + } + #ifdef X49GP_DATADIR if ( fd < 0 && ( errno == EACCES || errno == ENOENT ) ) { g_free( *path );