Kano 14 years ago
parent
commit
2358056606
6 changed files with 160 additions and 72 deletions
  1. 1 0
      AUTHORS
  2. 1 1
      Makefile.am
  3. 57 36
      api.c
  4. 67 26
      linux-usb-cgminer
  5. 24 9
      main.c
  6. 10 0
      miner.h

+ 1 - 0
AUTHORS

@@ -1,2 +1,3 @@
 Original CPU mining software: Jeff Garzik <jgarzik@pobox.com>
 Original CPU mining software: Jeff Garzik <jgarzik@pobox.com>
 GPU mining and rewrite: Con Kolivas <kernel@kolivas.org> 15qSxP1SQcUX3o4nhkfdbgyoWEFMomJ4rZ
 GPU mining and rewrite: Con Kolivas <kernel@kolivas.org> 15qSxP1SQcUX3o4nhkfdbgyoWEFMomJ4rZ
+API+: Kano <kanoi@kano-kun.net> 1Jjk2LmktEQKnv8r2cZ9MvLiZwZ9gxabKm

+ 1 - 1
Makefile.am

@@ -27,7 +27,7 @@ cgminer_SOURCES	= elist.h miner.h compat.h bench_block.h	\
 		  sha256_altivec_4way.c				\
 		  sha256_altivec_4way.c				\
 		  adl.c	adl.h adl_functions.h			\
 		  adl.c	adl.h adl_functions.h			\
 		  phatk110817.cl poclbm110817.cl \
 		  phatk110817.cl poclbm110817.cl \
-		  sha2.c sha2.h
+		  sha2.c sha2.h api.c
 
 
 cgminer_LDFLAGS	= $(PTHREAD_FLAGS)
 cgminer_LDFLAGS	= $(PTHREAD_FLAGS)
 cgminer_LDADD	= $(DLOPEN_FLAGS) @LIBCURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @OPENCL_LIBS@ @NCURSES_LIBS@ @PDCURSES_LIBS@ @WS2_LIBS@ lib/libgnu.a ccan/libccan.a
 cgminer_LDADD	= $(DLOPEN_FLAGS) @LIBCURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @OPENCL_LIBS@ @NCURSES_LIBS@ @PDCURSES_LIBS@ @WS2_LIBS@ lib/libgnu.a ccan/libccan.a

+ 57 - 36
api.c

@@ -34,29 +34,38 @@
 //	#include <sys/wait.h>
 //	#include <sys/wait.h>
 #endif
 #endif
 
 
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
 // Big enough for largest API request
 // Big enough for largest API request
 //  though a PC with 100s of CPUs may exceed the size ...
 //  though a PC with 100s of CPUs may exceed the size ...
 // Current code assumes it can socket send this size also
 // Current code assumes it can socket send this size also
 #define MYBUFSIZ	16384
 #define MYBUFSIZ	16384
 
 
+// Socket is on 127.0.0.1
+#define QUEUE	10
+
 static char *buffer = NULL;
 static char *buffer = NULL;
 
 
 static const char *UNAVAILABLE = " - API will not be available";
 static const char *UNAVAILABLE = " - API will not be available";
 
 
 static const char *BLANK = "";
 static const char *BLANK = "";
 
 
-static const char *VERSION = "0.1";
+static const char *APIVERSION = "0.1";
 static const char *DEAD = "DEAD";
 static const char *DEAD = "DEAD";
 static const char *SICK = "SICK";
 static const char *SICK = "SICK";
 static const char *DISABLED = "DISABLED";
 static const char *DISABLED = "DISABLED";
-static const char * = "";
-zzz -> other pool status
+static const char *ALIVE = "ALIVE";
+
+static const char *YES = "Y";
+static const char *NO = "N";
 
 
 static int bye = 0;
 static int bye = 0;
 
 
 char *apiversion(char *params)
 char *apiversion(char *params)
 {
 {
-	return VERSION;
+	return (char *)APIVERSION;
 }
 }
 
 
 void gpustatus(int thr_id)
 void gpustatus(int thr_id)
@@ -68,7 +77,7 @@ void gpustatus(int thr_id)
 	int gf, gp;
 	int gf, gp;
 
 
 	if (thr_id >= 0 && thr_id < gpu_threads) {
 	if (thr_id >= 0 && thr_id < gpu_threads) {
-		int gpu = dev_from_id(thr_id);
+		int gpu = thr_info[thr_id].cgpu->cpu_gpu;
 		struct cgpu_info *cgpu = &gpus[gpu];
 		struct cgpu_info *cgpu = &gpus[gpu];
 
 
 		cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
 		cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
@@ -84,21 +93,21 @@ void gpustatus(int thr_id)
 		gt = gf = gp = 0;
 		gt = gf = gp = 0;
 
 
 		if (cgpu->status == LIFE_DEAD)
 		if (cgpu->status == LIFE_DEAD)
-			status = DEAD;
+			status = (char *)DEAD;
 		else if (cgpu->status == LIFE_SICK)
 		else if (cgpu->status == LIFE_SICK)
-			status = SICK;
+			status = (char *)SICK;
 		else if (!gpu_devices[gpu])
 		else if (!gpu_devices[gpu])
-			status = DISABLED;
+			status = (char *)DISABLED;
 		else {
 		else {
 			sprintf(status_buf, "%.1f", cgpu->rolling);
 			sprintf(status_buf, "%.1f", cgpu->rolling);
 			status = status_buf;
 			status = status_buf;
 		}
 		}
 
 
-		sprintf(buf, "G%d=%.2f,%d,%d,%s,%.2f,%d,%d,%d,%.2f,%d|",
+		sprintf(buf, "GPU=%d,GT=%.2f,FR=%d,FP=%d,STA=%s,MHS=%.2f,A=%d,R=%d,HW=%d,U=%.2f,I=%d|",
 			gpu, gt, gf, gp, status,
 			gpu, gt, gf, gp, status,
 			cgpu->total_mhashes / total_secs,
 			cgpu->total_mhashes / total_secs,
 			cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
 			cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
-			cgpu->utility, gpus[gpu].intensity);
+			cgpu->utility, gpus->intensity);
 
 
 		strcat(buffer, buf);
 		strcat(buffer, buf);
 	}
 	}
@@ -109,16 +118,16 @@ void cpustatus(int thr_id)
 	char buf[BUFSIZ];
 	char buf[BUFSIZ];
 
 
 	if (thr_id >= gpu_threads) {
 	if (thr_id >= gpu_threads) {
-		int cpu = dev_from_id(thr_id);
+		int cpu = thr_info[thr_id].cgpu->cpu_gpu;
 		struct cgpu_info *cgpu = &cpus[cpu];
 		struct cgpu_info *cgpu = &cpus[cpu];
 
 
 		cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
 		cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
 
 
-		sprintf(buf, "C%d=%.2f,%.2f,%d,%d,%d,%.2f,%d|",
+		sprintf(buf, "CPU=%d,STA=%.2f,MHS=%.2f,A=%d,R=%d,U=%.2f|",
 			cpu, cgpu->rolling,
 			cpu, cgpu->rolling,
 			cgpu->total_mhashes / total_secs,
 			cgpu->total_mhashes / total_secs,
-			cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
-			cgpu->utility, gpus[gpu].intensity);
+			cgpu->accepted, cgpu->rejected,
+			cgpu->utility);
 
 
 		strcat(buffer, buf);
 		strcat(buffer, buf);
 	}
 	}
@@ -142,7 +151,7 @@ char *devstatus(char *params)
 char *poolstatus(char *params)
 char *poolstatus(char *params)
 {
 {
 	char buf[BUFSIZ];
 	char buf[BUFSIZ];
-	char *status;
+	char *status, *lp;
 	int i;
 	int i;
 
 
 	*buffer = '\0';
 	*buffer = '\0';
@@ -151,12 +160,22 @@ char *poolstatus(char *params)
 		struct pool *pool = pools[i];
 		struct pool *pool = pools[i];
 
 
 		if (!pool->enabled)
 		if (!pool->enabled)
-			status = DISABLED;
+			status = (char *)DISABLED;
 		else
 		else
-			status = OK;
+		{
+			if (pool->idle)
+				status = (char *)DEAD;
+			else
+				status = (char *)ALIVE;
+		}
 
 
-		sprintf(buf, "P%d=%s,%s,%d,%d,%d,%d,%d,%d,%d|",
-			i, pool->rpc_url, status,
+		if (pool->hdr_path)
+			lp = (char *)YES;
+		else
+			lp = (char *)NO;
+
+		sprintf(buf, "POOL=%d,URL=%s,STA=%s,PRI=%d,LP=%s,Q=%d,A=%d,R=%d,DW=%d,ST=%d,GF=%d,RF=%d|",
+			i, pool->rpc_url, status, pool->prio, lp,
 			pool->getwork_requested,
 			pool->getwork_requested,
 			pool->accepted, pool->rejected,
 			pool->accepted, pool->rejected,
 			pool->discarded_work,
 			pool->discarded_work,
@@ -171,31 +190,33 @@ char *poolstatus(char *params)
 }
 }
 
 
 struct CMDS {
 struct CMDS {
-	const char *cmd;
-	char (*func)();
+	char *name;
+	char *(*func)(char *);
 } cmds[] = {
 } cmds[] = {
 	{ "apiversion",	apiversion },
 	{ "apiversion",	apiversion },
 	{ "dev",	devstatus },
 	{ "dev",	devstatus },
-	{ "pool",	poolstatus }
+	{ "pool",	poolstatus },
 };
 };
 
 
-#define MAXCMD sizeof(cmds)/sizeof(struct CMDS)
+#define CMDMAX 3
 
 
 void send_result(int c, char *result)
 void send_result(int c, char *result)
 {
 {
 	int n;
 	int n;
 
 
 	if (result == NULL)
 	if (result == NULL)
-		result = BLANK;
+		result = (char *)BLANK;
 
 
 	// ignore failure - it's closed immediately anyway
 	// ignore failure - it's closed immediately anyway
 	n = write(c, result, strlen(result)+1);
 	n = write(c, result, strlen(result)+1);
 }
 }
 
 
-static void api()
+void api()
 {
 {
+	char buf[BUFSIZ];
 	const char *addr;
 	const char *addr;
 	int c, sock, n, bound;
 	int c, sock, n, bound;
+	char tmpaddr[32];
 	char *binderror;
 	char *binderror;
 	time_t bindstart;
 	time_t bindstart;
 	short int port = 4028;
 	short int port = 4028;
@@ -205,13 +226,14 @@ static void api()
 	long long counter;
 	long long counter;
 	char *result;
 	char *result;
 	char *params;
 	char *params;
+	int i;
 
 
 	addr = "127.0.0.1";
 	addr = "127.0.0.1";
 
 
 	sock = socket(AF_INET, SOCK_STREAM, 0);
 	sock = socket(AF_INET, SOCK_STREAM, 0);
 	if (sock < 0) {
 	if (sock < 0) {
 		applog(LOG_ERR, "API1 initialisation failed (%s)%s", strerror(errno), UNAVAILABLE);
 		applog(LOG_ERR, "API1 initialisation failed (%s)%s", strerror(errno), UNAVAILABLE);
-		return NULL;
+		return;
 	}
 	}
 
 
 	memset(&serv, 0, sizeof(serv));
 	memset(&serv, 0, sizeof(serv));
@@ -219,7 +241,7 @@ static void api()
 	serv.sin_family = AF_INET;
 	serv.sin_family = AF_INET;
 	if (inet_pton(AF_INET, addr, &(serv.sin_addr)) == 0) {
 	if (inet_pton(AF_INET, addr, &(serv.sin_addr)) == 0) {
 		applog(LOG_ERR, "API2 initialisation failed (%s)%s", strerror(errno), UNAVAILABLE);
 		applog(LOG_ERR, "API2 initialisation failed (%s)%s", strerror(errno), UNAVAILABLE);
-		return NULL;
+		return;
 	}
 	}
 	serv.sin_port = htons(port);
 	serv.sin_port = htons(port);
 
 
@@ -232,8 +254,8 @@ static void api()
 			if ((time(NULL) - bindstart) > 61)
 			if ((time(NULL) - bindstart) > 61)
 				break;
 				break;
 			else {
 			else {
-				applog(LOG_ERR, "API bind to port %d failed - trying again in 10sec", port);
-				sleep(10);
+				applog(LOG_ERR, "API bind to port %d failed - trying again in 15sec", port);
+				sleep(15);
 			}
 			}
 		}
 		}
 		else
 		else
@@ -242,13 +264,13 @@ static void api()
 
 
 	if (bound == 0) {
 	if (bound == 0) {
 		applog(LOG_ERR, "API bind to port %d failed (%s)%s", port, binderror, UNAVAILABLE);
 		applog(LOG_ERR, "API bind to port %d failed (%s)%s", port, binderror, UNAVAILABLE);
-		return NULL;
+		return;
 	}
 	}
 
 
 	if (listen(sock, QUEUE) < 0) {
 	if (listen(sock, QUEUE) < 0) {
 		applog(LOG_ERR, "API3 initialisation failed (%s)%s", strerror(errno), UNAVAILABLE);
 		applog(LOG_ERR, "API3 initialisation failed (%s)%s", strerror(errno), UNAVAILABLE);
 		close(sock);
 		close(sock);
-		return NULL;
+		return;
 	}
 	}
 
 
 	buffer = malloc(MYBUFSIZ+1);
 	buffer = malloc(MYBUFSIZ+1);
@@ -262,24 +284,25 @@ static void api()
 			applog(LOG_ERR, "API failed (%s)%s", strerror(errno), UNAVAILABLE);
 			applog(LOG_ERR, "API failed (%s)%s", strerror(errno), UNAVAILABLE);
 			close(sock);
 			close(sock);
 			free(buffer);
 			free(buffer);
-			return NULL;
+			return;
 		}
 		}
 
 
 		inet_ntop(AF_INET, &(cli.sin_addr), &(tmpaddr[0]), sizeof(tmpaddr)-1);
 		inet_ntop(AF_INET, &(cli.sin_addr), &(tmpaddr[0]), sizeof(tmpaddr)-1);
 		if (strcmp(tmpaddr, addr) != 0)
 		if (strcmp(tmpaddr, addr) != 0)
 			close(c);
 			close(c);
 		else {
 		else {
-			n = read(c, &buf[0], BUFS);
+			n = read(c, &buf[0], BUFSIZ-1);
 			if (n < 0)
 			if (n < 0)
 				close(c);
 				close(c);
 			else {
 			else {
+				buf[n] = '\0';
 				params = strchr(buf, '|');
 				params = strchr(buf, '|');
 				if (params != NULL)
 				if (params != NULL)
 					*(params++) = '\0';
 					*(params++) = '\0';
 
 
 				for (i = 0; i < CMDMAX; i++) {
 				for (i = 0; i < CMDMAX; i++) {
 					if (strcmp(buf, cmds[i].name) == 0) {
 					if (strcmp(buf, cmds[i].name) == 0) {
-						result = cmds[i].func(params);
+						result = (cmds[i].func)(params);
 						send_result(c, result);
 						send_result(c, result);
 						close(c);
 						close(c);
 						break;
 						break;
@@ -291,6 +314,4 @@ static void api()
 
 
 	close(sock);
 	close(sock);
 	free(buffer);
 	free(buffer);
-
-	return NULL;
 }
 }

+ 67 - 26
linux-usb-cgminer

@@ -1,22 +1,35 @@
-How to setup a cgminer using xubuntu 11.04 live on a USB courtesy of Kano
+How to setup a cgminer using xubuntu 11.04 live on a USB
+
+The master version of this document is here:
+ https://github.com/kanoi/linux-usb-cgminer
+
+The actual file is:
+ https://github.com/kanoi/linux-usb-cgminer/blob/master/linux-usb-cgminer
+
+The copy in cgminer (check to make sure it isn't older) is:
+ https://github.com/ckolivas/cgminer/blob/master/linux-usb-cgminer
+
+The original old verion on bitcointalk is:
+ https://bitcointalk.org/index.php?topic=28402.msg426741#msg426741
 
 
 Software
 Software
 ========
 ========
 Short hardware comment:
 Short hardware comment:
 Your mining computer doesn't need any HDD or CD/DVD/BD as long as it has at
 Your mining computer doesn't need any HDD or CD/DVD/BD as long as it has at
-least 2GB of RAM, can boot USB, has some network connection to the internet and
-of course a reasonable mining ATI graphics card
+least 2GB of RAM, can boot USB, has some network connection to the internet
+and of course a reasonable mining ATI graphics card
 ... Or you can boot a windows PC with the USB to only do mining ... and ignore
 ... Or you can boot a windows PC with the USB to only do mining ... and ignore
-the system HDD ... wasting energy Smiley
+the system HDD ... wasting energy running the HDD :)
 
 
-To create the USB, you need of course a 4GB USB and temporarily need a PC with a
-CD (or DVD/BD) writer, a USB port and of course an internet connection to the PC
+To create the USB, you need of course a 4GB USB and temporarily need a PC
+with a CD (or DVD/BD) writer, a USB port and of course an internet
+connection to the PC
 
 
 1) Download the xubuntu 11.04 desktop live CD iso for amd64
 1) Download the xubuntu 11.04 desktop live CD iso for amd64
    ( look here for mirrors: http://www.xubuntu.org/getubuntu )
    ( look here for mirrors: http://www.xubuntu.org/getubuntu )
 
 
-2) Burn it to CD then boot that temporarily on any PC with a CD/DVD/BD and a USB
-   port (this and the next 2 step won't effect that PC)
+2) Burn it to CD then boot that temporarily on any PC with a CD/DVD/BD and
+   a USB port (this and the next 2 step won't effect that PC)
 
 
 3) Plug in your 4GB USB device and it should appear on the desktop - you can
 3) Plug in your 4GB USB device and it should appear on the desktop - you can
    leave it's contents as long as there is at least 2.8GB free
    leave it's contents as long as there is at least 2.8GB free
@@ -24,8 +37,8 @@ CD (or DVD/BD) writer, a USB port and of course an internet connection to the PC
 4) Now run "Startup Disk Creator" in "Applications->System"
 4) Now run "Startup Disk Creator" in "Applications->System"
    (the system menu is the little rat in the top left corner)
    (the system menu is the little rat in the top left corner)
 
 
-(if you have no mouse you can get the menu with <ctr><esc> and navigate the menu
-with the arrow keys and <return> key)
+(if you have no mouse you can get the menu with <ctr><esc> and navigate
+the menu with the arrow keys and <return> key)
 
 
 From here select the boot CD as the "Source" and the USB as the "Disk to use"
 From here select the boot CD as the "Source" and the USB as the "Disk to use"
 lastly move the slider to 2GB for reserved extra space
 lastly move the slider to 2GB for reserved extra space
@@ -46,21 +59,21 @@ After about 10-15 minutes you have a base xubuntu 11.04 boot USB
 7) sudo apt-get install openssh-server screen
 7) sudo apt-get install openssh-server screen
 
 
    if you have a problem here then it's probably coz the internet isn't
    if you have a problem here then it's probably coz the internet isn't
-available ... sort that   out by reading elsewhere about routers etc
+   available ... sort that out by reading elsewhere about routers etc
 
 
 8) sudo apt-get install fglrx fglrx-amdcccle fglrx-dev
 8) sudo apt-get install fglrx fglrx-amdcccle fglrx-dev
    sudo sync
    sudo sync
    sudo shutdown -r now
    sudo shutdown -r now
 
 
 N.B. always do a "sudo sync" and wait for it to finish every time before
 N.B. always do a "sudo sync" and wait for it to finish every time before
-   shutting down the PC to ensure all data is written to the USB
+shutting down the PC to ensure all data is written to the USB
 
 
 9) sudo aticonfig --lsa
 9) sudo aticonfig --lsa
    this lists your ATI cards so you can see them
    this lists your ATI cards so you can see them
  sudo aticonfig --adapter=all --odgt
  sudo aticonfig --adapter=all --odgt
    this checks it can access all the cards ...
    this checks it can access all the cards ...
 
 
-10) aticonfig --adapter=all --initial
+10) sudo aticonfig --adapter=all --initial
    this gets an error - no idea why but the xorg.conf is OK
    this gets an error - no idea why but the xorg.conf is OK
  sudo sync
  sudo sync
  sudo shutdown -r now
  sudo shutdown -r now
@@ -91,13 +104,17 @@ N.B. always do a "sudo sync" and wait for it to finish every time before
 13) cgminer:
 13) cgminer:
  sudo apt-get install curl
  sudo apt-get install curl
 
 
- get the binary linux cgminer (see the bitcoin forum cgminer thread
- for where to get it)
+ get the binary linux cgminer
+ (see the bitcoin forum cgminer thread for where to get it)
+ https://bitcointalk.org/index.php?topic=28402.0
 
 
  ./cgminer -n
  ./cgminer -n
    this shows you the GPU's it found on your PC
    this shows you the GPU's it found on your PC
+   See further below if you get an error regarding libtinfo.so.5
 
 
 14) An OC option:
 14) An OC option:
+ This is no longer needed since cgminer 2.* includes OC, however:
+
  sudo apt-get install libwxbase2.8-0 libwxgtk2.8-0
  sudo apt-get install libwxbase2.8-0 libwxgtk2.8-0
 
 
  http://sourceforge.net/projects/amdovdrvctrl/
  http://sourceforge.net/projects/amdovdrvctrl/
@@ -106,21 +123,22 @@ N.B. always do a "sudo sync" and wait for it to finish every time before
 
 
 15) set the screen saver to ONLY blank ...
 15) set the screen saver to ONLY blank ...
 
 
- Move the mouse to the bottom of the screen and you see a set of icons
- like on an Apple PC
+ Move the mouse to the bottom of the screen and you see a set of icons like
+ on an Apple PC
  Click on Settings, then in the Settings window "Screensaver"
  Click on Settings, then in the Settings window "Screensaver"
  Set "Mode:" to "Blank Screen Only"
  Set "Mode:" to "Blank Screen Only"
 
 
-Edit: originally left this somewhat useful addition out:
 16) apt-get install ntpd
 16) apt-get install ntpd
- An accurate clock is always a good idea Smiley
+ An accurate clock is always a good idea :)
 
 
-Edit2: another item that seems I missed
 17) if you wish to ssh into the box you must set a password
 17) if you wish to ssh into the box you must set a password
     to do this you simply have to be logged into it at the screen and type
     to do this you simply have to be logged into it at the screen and type
+
   sudo passwd ubuntu
   sudo passwd ubuntu
+
     it will prompt you (twice) to enter a password for the ubuntu account
     it will prompt you (twice) to enter a password for the ubuntu account
 
 
+
 Initial setup complete.
 Initial setup complete.
 
 
 ========
 ========
@@ -129,17 +147,23 @@ If you want to SSH into the machine and run cgminer:
  From a terminal on the miner display each time after you boot:
  From a terminal on the miner display each time after you boot:
   xhost +
   xhost +
 
 
-Then after ssh into the machine:
+ 'xhost +' isn't needed if you ssh into the machine with the same
+ username that the GUI boots into (which is 'ubuntu' in this case)
+
+Then after you ssh into the machine:
  export DISPLAY=:0
  export DISPLAY=:0
 before running cgminer
 before running cgminer
 
 
-Also note, that you should force the screen to blank when mining if the ATI card
-is displaying the screen (using the screen saver application menu)
+Also note, that you should force the screen to blank when mining if
+the ATI card is displaying the screen (using the screen saver
+application menu)
 In my case it takes away 50Mh/s when the screen isn't blanked
 In my case it takes away 50Mh/s when the screen isn't blanked
+It will auto blank - but make sure the blank is of course just blank
+as mentioned above at 15)
 
 
 
 
-This is of course just the basics ... but it should get you a computer up and
-running and able to run cgminer
+This is of course just the basics ... but it should get you a computer
+up and running and able to run cgminer
 
 
 ========
 ========
 
 
@@ -147,10 +171,15 @@ You should keep an eye on USB disk space
 The system logger writes log files in the /var/log/ directory
 The system logger writes log files in the /var/log/ directory
 The two main ones that grow large are 'kern.log' and 'syslog'
 The two main ones that grow large are 'kern.log' and 'syslog'
 If you want to keep them, save them away to some other computer
 If you want to keep them, save them away to some other computer
-When space is low, just delete them.
+When space is low, just delete them e.g.
+
+   sudo rm -i /var/log/syslog
+   sudo rm -i /var/log/kern.log
 
 
 The 'df' command will show you the current space e.g.:
 The 'df' command will show you the current space e.g.:
 
 
+   sudo df
+
 Filesystem           1K-blocks      Used Available Use% Mounted on
 Filesystem           1K-blocks      Used Available Use% Mounted on
 aufs                   2099420    892024   1100748  45% /
 aufs                   2099420    892024   1100748  45% /
 none                   1015720       628   1015092   1% /dev
 none                   1015720       628   1015092   1% /dev
@@ -164,3 +193,15 @@ none                   1023772         0   1023772   0% /var/lock
 
 
 This shows the 2GB space allocated when you setup the USB as '/' (aufs)
 This shows the 2GB space allocated when you setup the USB as '/' (aufs)
 In this example, it's currently 45% full with almost 1.1GB of free space
 In this example, it's currently 45% full with almost 1.1GB of free space
+
+========
+
+The latest version (2.0.8) of cgminer is built with 11.10 (not 11.04)
+If you get the following error when running the prebuilt version in 11.04:
+
+   ./cgminer: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
+
+The fix is to simply link the old curses library to the new name e.g.:
+
+   cd /lib64/
+   sudo ln -s libncurses.so.5 libtinfo.so.5

+ 24 - 9
main.c

@@ -219,11 +219,11 @@ static int nDevs;
 static int opt_g_threads = 2;
 static int opt_g_threads = 2;
 static int opt_device;
 static int opt_device;
 static int total_devices;
 static int total_devices;
-static bool gpu_devices[MAX_GPUDEVICES];
-static int gpu_threads;
+bool gpu_devices[MAX_GPUDEVICES];
+int gpu_threads;
 static bool forced_n_threads;
 static bool forced_n_threads;
 static int opt_n_threads;
 static int opt_n_threads;
-static int mining_threads;
+int mining_threads;
 static int num_processors;
 static int num_processors;
 bool use_curses = true;
 bool use_curses = true;
 static bool opt_submit_stale;
 static bool opt_submit_stale;
@@ -248,6 +248,7 @@ static int watchdog_thr_id;
 static int input_thr_id;
 static int input_thr_id;
 static int gpur_thr_id;
 static int gpur_thr_id;
 static int cpur_thr_id;
 static int cpur_thr_id;
+static int api_thr_id;
 static int total_threads;
 static int total_threads;
 
 
 struct work_restart *work_restart = NULL;
 struct work_restart *work_restart = NULL;
@@ -273,15 +274,13 @@ static unsigned int found_blocks;
 static unsigned int local_work;
 static unsigned int local_work;
 static unsigned int total_go, total_ro;
 static unsigned int total_go, total_ro;
 
 
-#define MAX_POOLS (32)
-
-static struct pool *pools[MAX_POOLS];
+struct pool *pools[MAX_POOLS];
 static struct pool *currentpool = NULL;
 static struct pool *currentpool = NULL;
 
 
 static float opt_donation = 0.0;
 static float opt_donation = 0.0;
 static struct pool donationpool;
 static struct pool donationpool;
 
 
-static int total_pools;
+int total_pools;
 static enum pool_strategy pool_strategy = POOL_FAILOVER;
 static enum pool_strategy pool_strategy = POOL_FAILOVER;
 static int opt_rotate_period;
 static int opt_rotate_period;
 static int total_urls, total_users, total_passes, total_userpasses;
 static int total_urls, total_users, total_passes, total_userpasses;
@@ -1938,11 +1937,11 @@ static int requests_staged(void)
 }
 }
 
 
 static WINDOW *mainwin, *statuswin, *logwin;
 static WINDOW *mainwin, *statuswin, *logwin;
-static double total_secs = 0.1;
+double total_secs = 0.1;
 static char statusline[256];
 static char statusline[256];
 static int cpucursor, gpucursor, logstart, logcursor;
 static int cpucursor, gpucursor, logstart, logcursor;
 struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */
 struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */
-static struct cgpu_info *cpus;
+struct cgpu_info *cpus;
 
 
 static inline void unlock_curses(void)
 static inline void unlock_curses(void)
 {
 {
@@ -3747,6 +3746,15 @@ static void *workio_thread(void *userdata)
 	return NULL;
 	return NULL;
 }
 }
 
 
+static void *api_thread(void *userdata)
+{
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+	api();
+
+	return NULL;
+}
+
 static void thread_reportin(struct thr_info *thr)
 static void thread_reportin(struct thr_info *thr)
 {
 {
 	gettimeofday(&thr->last, NULL);
 	gettimeofday(&thr->last, NULL);
@@ -6088,6 +6096,13 @@ retry_pools:
 	if (thr_info_create(thr, NULL, reinit_gpu, thr))
 	if (thr_info_create(thr, NULL, reinit_gpu, thr))
 		quit(1, "reinit_gpu thread create failed");
 		quit(1, "reinit_gpu thread create failed");
 
 
+	/* Create API socket thread */
+	api_thr_id = mining_threads + 7;
+	thr = &thr_info[api_thr_id];
+	if (thr_info_create(thr, NULL, api_thread, thr))
+		quit(1, "API thread create failed");
+	pthread_detach(thr->pth);
+
 	sleep(opt_log_interval);
 	sleep(opt_log_interval);
 	if (opt_donation > 0.0)
 	if (opt_donation > 0.0)
 		applog(LOG_WARNING, "Donation is enabled at %.1f%% thank you :-)", opt_donation);
 		applog(LOG_WARNING, "Donation is enabled at %.1f%% thank you :-)", opt_donation);

+ 10 - 0
miner.h

@@ -394,8 +394,11 @@ struct work_restart {
 	char			padding[128 - sizeof(unsigned long)];
 	char			padding[128 - sizeof(unsigned long)];
 };
 };
 
 
+extern void api();
+
 
 
 #define MAX_GPUDEVICES 16
 #define MAX_GPUDEVICES 16
+#define MAX_POOLS (32)
 
 
 extern int hw_errors;
 extern int hw_errors;
 extern bool use_syslog;
 extern bool use_syslog;
@@ -403,6 +406,13 @@ extern struct thr_info *thr_info;
 extern int longpoll_thr_id;
 extern int longpoll_thr_id;
 extern struct work_restart *work_restart;
 extern struct work_restart *work_restart;
 extern struct cgpu_info gpus[MAX_GPUDEVICES];
 extern struct cgpu_info gpus[MAX_GPUDEVICES];
+extern int gpu_threads;
+extern double total_secs;
+extern bool gpu_devices[MAX_GPUDEVICES];
+extern int mining_threads;
+extern struct cgpu_info *cpus;
+extern int total_pools;
+extern struct pool *pools[MAX_POOLS];
 
 
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
 typedef struct {
 typedef struct {