: Denby Wong writes:
:: Feb 16 09:42:17 lowry kernel: TIOCLINUX (0/8/9) ioctl is gone - use /dev/vcs
::
:: What does this mean? Where does it come from? Do I need to be
:: concerned about it (no functional problems so far).
: From /usr/src/linux/drivers/char/vc_screen.c of 1.1.92:
: /*
: * Provide access to virtual console memory.
: * /dev/vcs0: the screen as it is being viewed right now (possibly scrolled)
: * /dev/vcsN: the screen of /dev/ttyN (1 <= N <= 63)
: * [minor: N]
: *
: * /dev/vcsaN: idem, but including attributes, and prefixed with
: * the 4 bytes lines,columns,x,y (as screendump used to give)
: * [minor: N+128]
: *
: * This replaces screendump and part of selection, so that the system
: * administrator can control access using file system permissions.
: *
: */
: So:
: mknod /dev/vcs[0-63] c 7 [0-63]
: mknod /dev/vcsa[0-63] c 7 [128-191]
: for the number of VC's you plan to support.
Yes. Maybe I should provide a small replacement screendump utility,
as long as the updated setterm is not out yet. Keeping with standard
Unix conventions, it writes to stdout, not to a file "screen.dump".
------------------ cut here ------------------------------------------
/*
* screendump.c - aeb 950214
*
* Call: "screendump N" when the screen of /dev/ttyN has to be dumped
*
* On Linux up to 1.1.91 there is an ioctl that will do the dumping.
* Because of problems with security this has been scrapped.
* From 1.1.92 on, make devices "virtual console screen" and
* "virtual console screen with attributes" by (fill in the ellipses):
* cd /dev
* for i in 0 1 2 3 ...; do
* mknod vcs$i c 7 $i
* mknod vcsa$i c 7 `expr 128 + $i`
* done
* and give them your favourite owners and permissions.
*/
#include <stdio.h>
#include <linux/termios.h>
extern char *malloc();
main(int argc, char **argv) {
int cons = 0;
char infile[20];
unsigned char header[4];
unsigned int rows, cols;
int fd, i, j;
char *inbuf, *outbuf, *p, *q;
if (argc == 2)
cons = atoi(argv[1]);
sprintf(infile, "/dev/vcsa%d", cons);
fd = open(infile, 0);
if (fd < 0 || read(fd, header, 4) != 4)
goto try_ioctl;
rows = header[0];
cols = header[1];
if (rows * cols == 0)
goto try_ioctl;
inbuf = malloc(rows*cols*2);
outbuf = malloc(rows*(cols+1));
if(!inbuf || !outbuf) {
fprintf(stderr, "Out of memory?\n");
exit(1);
}
if (read(fd, inbuf, rows*cols*2) != rows*cols*2) {
fprintf(stderr, "Error reading %s\n", infile);
exit(1);
}
p = inbuf;
q = outbuf;
for(i=0; i<rows; i++) {
for(j=0; j<cols; j++) {
*q++ = *p;
p += 2;
}
while(j-- > 0 && q[-1] == ' ')
q--;
*q++ = '\n';
}
goto done;
try_ioctl:
{
/* bug in the old ioctl: there is no way to guess
the size of its output */
#define NUM_COLS 200
#define NUM_ROWS 100
unsigned char screenbuf[2 + NUM_ROWS*NUM_COLS];
screenbuf[0] = 0;
screenbuf[1] = (unsigned char) cons;
if (ioctl(0,TIOCLINUX,screenbuf) < 0) {
fprintf(stderr,"couldn't read %s, and cannot ioctl dump\n",
infile);
exit(1);
}
rows = screenbuf[0];
cols = screenbuf[1];
outbuf = malloc(rows*(cols+1));
if(!outbuf) {
fprintf(stderr, "Out of memory?\n");
exit(1);
}
p = screenbuf + 2;
q = outbuf;
for (i=0; i<rows; i++) {
for (j=0; j<cols; j++)
*q++ = *p++;
while (j-- > 0 && (q[-1] == ' '))
q--;
*q++ = '\n';
}
}
done:
if (write(1, outbuf, q-outbuf) != q-outbuf) {
fprintf(stderr, "Error writing screendump\n");
exit(1);
}
return;
Quote:}