mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-02 01:44:23 +00:00
Refactored kernel source loading (missing / delimiter). Added more debug messages.
This commit is contained in:
parent
b2e500e2a6
commit
c0d79fa3fe
@ -5,35 +5,39 @@ static char *file_contents(const char *filename, int *length)
|
||||
{
|
||||
char *fullpath = (char *)alloca(PATH_MAX);
|
||||
void *buffer;
|
||||
FILE *f;
|
||||
FILE *f = NULL;
|
||||
|
||||
/* Try in the optional kernel path first, defaults to PREFIX */
|
||||
strcpy(fullpath, opt_kernel_path);
|
||||
strcat(fullpath, filename);
|
||||
f = fopen(fullpath, "rb");
|
||||
if (opt_kernel_path && *opt_kernel_path) {
|
||||
/* Try in the optional kernel path first, defaults to PREFIX */
|
||||
snprintf(fullpath, PATH_MAX, "%s/%s", opt_kernel_path, filename);
|
||||
applog(LOG_DEBUG, "Trying to open %s...", fullpath);
|
||||
f = fopen(fullpath, "rb");
|
||||
}
|
||||
if (!f) {
|
||||
/* Then try from the path sgminer was called */
|
||||
strcpy(fullpath, sgminer_path);
|
||||
strcat(fullpath, filename);
|
||||
snprintf(fullpath, PATH_MAX, "%s/%s", sgminer_path, filename);
|
||||
applog(LOG_DEBUG, "Trying to open %s...", fullpath);
|
||||
f = fopen(fullpath, "rb");
|
||||
}
|
||||
if (!f) {
|
||||
/* Then from `pwd`/kernel/ */
|
||||
strcpy(fullpath, sgminer_path);
|
||||
strcat(fullpath, "/kernel/");
|
||||
strcat(fullpath, filename);
|
||||
snprintf(fullpath, PATH_MAX, "%s/kernel/%s", sgminer_path, filename);
|
||||
applog(LOG_DEBUG, "Trying to open %s...", fullpath);
|
||||
f = fopen(fullpath, "rb");
|
||||
}
|
||||
/* Finally try opening it directly */
|
||||
if (!f)
|
||||
if (!f) {
|
||||
applog(LOG_DEBUG, "Trying to open %s...", fullpath);
|
||||
f = fopen(filename, "rb");
|
||||
}
|
||||
|
||||
if (!f) {
|
||||
applog(LOG_ERR, "Unable to open %s or %s for reading",
|
||||
filename, fullpath);
|
||||
applog(LOG_ERR, "Unable to open %s for reading!", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
applog(LOG_DEBUG, "Using %s", fullpath);
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
*length = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
Loading…
x
Reference in New Issue
Block a user