Capture the Output of the SKI emulator
Introduction
Catching the output of the IA64 SKI emulator is easy but has lots of traps for new players. Described below is a method that may be of use.
Traps
The --conslog option of SKI is not actually implemented, and does not work.
The -S option of xterm isn't that well documented.
Solution
We need a fake xterm wrapper to capture the output from SKI. Matthew Chapman wrote an xterm forwarder that relays a pseudo terminal which is available from http://www.cse.unsw.edu.au/~matthewc/files/fake-xterm.c
I wanted something slightly different to simply log output to a file.
get the attached files/copy from this page below/download fake-xterm.c, xterm and Makefile
run make and then make install as root. This will copy fake-xterm and xterm to /usr/local/bin/
if you set the environment variable FAKE_XTERM=yes you will use the "fake" xterm. This must be provided with -S option.
- the variable FAKE_XTERM_OUT can be set to the file you wish to log to.
use this in conjunction with an input file to ski, with the -i flag to ski. e.g.
FAKE_XTERM=yes FAKE_XTERM_OUT=/home/ianw/ski.out ski -i skicommands.in bootloader linux
Files
fake-xterm.c
/* fake-xterm
* Behaves like xterm -S, but logs the output to a file.
*
* Original idea by Matthew Chapman <matthewc@cse.unsw.edu.au>
* If you have problems with this you can email Ian Wienand <ianw@gelato.unsw.edu.au>
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
int fd = 0;
int c;
char buf[BUFSIZ];
int fileout_flag = 0;
int fileout_fd = 1;
opterr = 0;
while ((c = getopt(argc, argv, "S:o:h")) != -1)
switch (c) {
case 'h':
fprintf(stdout,
"fake-xterm -o file [arguments to xterm, must include -S]\n");
return 0;
case 'S':
/* the format of -S arg to xterm is
-Sppnn
where
pp is the pseduo terminal to use in slave mode.
nn is the file descriptor you get your input from
*/
fd = atoi(&optarg[2]);
break;
case 'o':
if (fileout_flag) /* -geo 80x25 matches this too unfortunately */
continue;
fileout_flag = 1;
fileout_fd =
open(optarg, O_CREAT | O_RDWR | O_TRUNC,
S_IRUSR | S_IWUSR);
if (fileout_fd == -1) {
perror("open file");
return 1;
}
break;
case '?':
break;
default:
abort();
}
if (fd <= 0) {
fprintf(stderr, "fake-xterm: Must specifiy -S\n");
return 1;
}
/* xterms write back their window id, apparently.
(undocumented feature) */
if (write(fd, "0000000\n\r", 9) == -1) {
perror("writeback");
return 1;
}
while ((c = read(fd, buf, sizeof(buf)))) {
if (c == -1) {
perror("xread");
return 1;
}
if (write(fileout_fd, buf, c) == -1) {
perror("log write");
return 1;
}
}
close(fileout_fd);
close(fd);
exit(0);
}
xterm shell script
#!/bin/bash
if [ ! $FAKE_XTERM_OUT ] ; then
FAKE_XTERM_OUT=~/fake-xterm.out
fi
if [ $FAKE_XTERM ] ; then
/usr/local/bin/fake-xterm -i -o $FAKE_XTERM_OUT "$@" ;
else
/usr/X11R6/bin/xterm "$@"
fi
Makefile
CFLAGS=-g -Wall
fake-xterm: fake-xterm.c
$(CC) $(CFLAGS) -o fake-xterm fake-xterm.c
.PHONY : install
install:
install --owner root --group root ./fake-xterm /usr/local/bin/fake-xterm
install --owner root --group root ./xterm /usr/local/bin/xterm
