ref: 258a072d95cc8324dfeeb8e9d9a347a92422a844
parent: d642d726babfc8e6a04a9ea2280655b0c5ff8f98
parent: 3b003767cd4fb50a0837cb40332e54a3ed912f3a
author: cinap_lenrek <cinap_lenrek@localhost>
date: Mon May 16 08:17:07 EDT 2011
merge
--- a/rc/bin/xargs
+++ b/rc/bin/xargs
@@ -19,3 +19,5 @@
}
while(x = `{read -n $nargs})
$* $x
+if(! ~ $#x 0)
+ $* $x
--- /dev/null
+++ b/sys/src/cmd/aux/icanhasmsi.c
@@ -1,0 +1,60 @@
+#include <u.h>
+#include <libc.h>
+
+int
+pcicfg16r(int fd, ushort *s, vlong offset)
+{
+ char buf[2];
+
+ if(pread(fd, buf, 2, offset) < 2) return -1;
+ *s = buf[0] | (buf[1] << 8);
+ return 0;
+}
+
+void
+main()
+{
+ int fd;
+ long n;
+ Dir *dir;
+ char *p, *s;
+ uchar cap, c;
+ ushort sh;
+
+ fd = open("/dev/pci", OREAD);
+ if(fd < 0) sysfatal("open /dev/pci: %r");
+ n = dirreadall(fd, &dir);
+ if(n < 0) sysfatal("dirreadall /dev/pci: %r");
+ close(fd);
+ for(; n--; dir++) {
+ p = dir->name + strlen(dir->name) - 3;
+ if(strcmp(p, "raw") != 0)
+ continue;
+ s = smprint("/dev/pci/%s", dir->name);
+ fd = open(s, OREAD);
+ if(fd < 0) {
+ fprint(2, "open %s: %r", s);
+ free(s);
+ continue;
+ }
+ if(pcicfg16r(fd, &sh, 0) < 0) goto err;
+ if(sh == 0xFFFF) goto end;
+ if(pcicfg16r(fd, &sh, 0x06) < 0) goto err;
+ if((sh & (1<<4)) == 0) goto end;
+ cap = 0x33;
+ for(;;) {
+ if(pread(fd, &cap, 1, cap+1) < 0) goto err;
+ if(cap == 0) goto end;
+ if(pread(fd, &c, 1, cap) < 0) goto err;
+ if(c == 0x05) break;
+ }
+ s[strlen(s) - 3] = 0;
+ print("%s\n", s+9);
+ goto end;
+ err:
+ fprint(2, "read %s: %r", s);
+ end:
+ free(s);
+ close(fd);
+ }
+}
--- a/sys/src/games/xs.c
+++ b/sys/src/games/xs.c
@@ -848,7 +848,7 @@
snprint(buf, sizeof(buf), "/sys/games/lib/%dscores", N);
scores = open(buf, OWRITE);
if(scores < 0)
- sysfatal("can't open %s: %r", buf);
+ print("can't open %s: %r\n", buf);
tb = 0;
if(screen->depth < 3){
tb = allocimage(display, Rect(0,0,16,16), 0, 1, -1);
@@ -881,7 +881,7 @@
points = 0;
memset(board, 0, sizeof(board));
redraw(0);
- if(play()){
+ if(play() && scores >= 0){
endtime = time(0);
fprint(scores, "%ld\t%s\t%lud\t%ld\n",
points, getuser(), starttime, endtime-starttime);