Browse Source

Refactored kernel source loading (missing / delimiter). Added more debug messages.

djm34
troky 11 years ago
parent
commit
c0d79fa3fe
  1. 30
      ocl/build_kernel.c

30
ocl/build_kernel.c

@ -5,35 +5,39 @@ static char *file_contents(const char *filename, int *length)
{ {
char *fullpath = (char *)alloca(PATH_MAX); char *fullpath = (char *)alloca(PATH_MAX);
void *buffer; void *buffer;
FILE *f; FILE *f = NULL;
/* Try in the optional kernel path first, defaults to PREFIX */ if (opt_kernel_path && *opt_kernel_path) {
strcpy(fullpath, opt_kernel_path); /* Try in the optional kernel path first, defaults to PREFIX */
strcat(fullpath, filename); snprintf(fullpath, PATH_MAX, "%s/%s", opt_kernel_path, filename);
f = fopen(fullpath, "rb"); applog(LOG_DEBUG, "Trying to open %s...", fullpath);
f = fopen(fullpath, "rb");
}
if (!f) { if (!f) {
/* Then try from the path sgminer was called */ /* Then try from the path sgminer was called */
strcpy(fullpath, sgminer_path); snprintf(fullpath, PATH_MAX, "%s/%s", sgminer_path, filename);
strcat(fullpath, filename); applog(LOG_DEBUG, "Trying to open %s...", fullpath);
f = fopen(fullpath, "rb"); f = fopen(fullpath, "rb");
} }
if (!f) { if (!f) {
/* Then from `pwd`/kernel/ */ /* Then from `pwd`/kernel/ */
strcpy(fullpath, sgminer_path); snprintf(fullpath, PATH_MAX, "%s/kernel/%s", sgminer_path, filename);
strcat(fullpath, "/kernel/"); applog(LOG_DEBUG, "Trying to open %s...", fullpath);
strcat(fullpath, filename);
f = fopen(fullpath, "rb"); f = fopen(fullpath, "rb");
} }
/* Finally try opening it directly */ /* Finally try opening it directly */
if (!f) if (!f) {
applog(LOG_DEBUG, "Trying to open %s...", fullpath);
f = fopen(filename, "rb"); f = fopen(filename, "rb");
}
if (!f) { if (!f) {
applog(LOG_ERR, "Unable to open %s or %s for reading", applog(LOG_ERR, "Unable to open %s for reading!", filename);
filename, fullpath);
return NULL; return NULL;
} }
applog(LOG_DEBUG, "Using %s", fullpath);
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
*length = ftell(f); *length = ftell(f);
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);

Loading…
Cancel
Save