mirror of
https://github.com/GOSTSec/sgminer
synced 2025-03-12 13:41:05 +00:00
Add the directory name from the arguments cgminer was called from as well to allow it running from a relative pathname.
This commit is contained in:
parent
d3642bec6f
commit
2053de6d59
12
main.c
12
main.c
@ -31,6 +31,8 @@
|
|||||||
#include <ccan/opt/opt.h>
|
#include <ccan/opt/opt.h>
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "miner.h"
|
#include "miner.h"
|
||||||
#include "findnonce.h"
|
#include "findnonce.h"
|
||||||
@ -225,6 +227,7 @@ bool opt_autofan;
|
|||||||
bool opt_autoengine;
|
bool opt_autoengine;
|
||||||
|
|
||||||
char *opt_kernel_path;
|
char *opt_kernel_path;
|
||||||
|
char *cgminer_path;
|
||||||
|
|
||||||
#define QUIET (opt_quiet || opt_realquiet)
|
#define QUIET (opt_quiet || opt_realquiet)
|
||||||
|
|
||||||
@ -4950,8 +4953,11 @@ int main (int argc, char *argv[])
|
|||||||
sigaction(SIGTERM, &handler, &termhandler);
|
sigaction(SIGTERM, &handler, &termhandler);
|
||||||
sigaction(SIGINT, &handler, &inthandler);
|
sigaction(SIGINT, &handler, &inthandler);
|
||||||
|
|
||||||
opt_kernel_path = malloc(PATH_MAX);
|
opt_kernel_path = alloca(PATH_MAX);
|
||||||
strcpy(opt_kernel_path, CGMINER_PREFIX);
|
strcpy(opt_kernel_path, CGMINER_PREFIX);
|
||||||
|
cgminer_path = alloca(PATH_MAX);
|
||||||
|
strcpy(cgminer_path, dirname(argv[0]));
|
||||||
|
strcat(cgminer_path, "/");
|
||||||
|
|
||||||
// Hack to make cgminer silent when called recursively on WIN32
|
// Hack to make cgminer silent when called recursively on WIN32
|
||||||
int skip_to_bench = 0;
|
int skip_to_bench = 0;
|
||||||
@ -5307,8 +5313,6 @@ int main (int argc, char *argv[])
|
|||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
applog(LOG_ERR, "The most common reason for this failure is cgminer being unable to read the kernel .cl files");
|
applog(LOG_ERR, "The most common reason for this failure is cgminer being unable to read the kernel .cl files");
|
||||||
applog(LOG_ERR, "You must either CD into the directory you are running cgminer from,");
|
|
||||||
applog(LOG_ERR, "or run it from a 'make install'ed location. ");
|
|
||||||
applog(LOG_ERR, "Alternatively if it has failed on different GPUs, restarting might help.");
|
applog(LOG_ERR, "Alternatively if it has failed on different GPUs, restarting might help.");
|
||||||
failmessage = true;
|
failmessage = true;
|
||||||
buf = curses_input("Press enter to continue");
|
buf = curses_input("Press enter to continue");
|
||||||
@ -5415,8 +5419,6 @@ int main (int argc, char *argv[])
|
|||||||
free(block);
|
free(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(opt_kernel_path);
|
|
||||||
|
|
||||||
curl_global_cleanup();
|
curl_global_cleanup();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
1
miner.h
1
miner.h
@ -304,6 +304,7 @@ extern bool opt_debug;
|
|||||||
extern bool opt_protocol;
|
extern bool opt_protocol;
|
||||||
extern bool opt_log_output;
|
extern bool opt_log_output;
|
||||||
extern char *opt_kernel_path;
|
extern char *opt_kernel_path;
|
||||||
|
extern char *cgminer_path;
|
||||||
extern bool opt_autofan;
|
extern bool opt_autofan;
|
||||||
extern bool opt_autoengine;
|
extern bool opt_autoengine;
|
||||||
|
|
||||||
|
12
ocl.c
12
ocl.c
@ -39,9 +39,17 @@ char *file_contents(const char *filename, int *length)
|
|||||||
strcpy(fullpath, opt_kernel_path);
|
strcpy(fullpath, opt_kernel_path);
|
||||||
strcat(fullpath, filename);
|
strcat(fullpath, filename);
|
||||||
|
|
||||||
f = fopen(filename, "rb");
|
/* Try in the optional kernel path or installed prefix first */
|
||||||
if (!f)
|
f = fopen(fullpath, "rb");
|
||||||
|
if (!f) {
|
||||||
|
/* Then try from the path cgminer was called */
|
||||||
|
strcpy(fullpath, cgminer_path);
|
||||||
|
strcat(fullpath, filename);
|
||||||
f = fopen(fullpath, "rb");
|
f = fopen(fullpath, "rb");
|
||||||
|
}
|
||||||
|
/* Finally try opening it directly */
|
||||||
|
if (!f)
|
||||||
|
f = fopen(filename, "rb");
|
||||||
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
applog(LOG_ERR, "Unable to open %s or %s for reading", filename, fullpath);
|
applog(LOG_ERR, "Unable to open %s or %s for reading", filename, fullpath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user