Hi, after messing a bit around with write(1), I've seen that ptyfs has a very strange behaviour. It updates in ptyfs_getattr() all times, including the access time. Thus, even if you only open(2) a tty, its access time is being modified. The appended (as in "bottom text") program shows that. Just run cc on it and give it as argument the path of an idle pty (it has to be a ptyfs-pty!). This breaks e.g. the behaviour of write, which always open's the tty before stat'ing it, thus _always_ giving you the lowest-numbered login terminal of the user, at least in my test cases that was the case (and its the expected behaviour of it). Please do not update write(1) now, I'll supply some other patches for it as well I would have to remerge then, and the work now would perhaps be gone. I didn't file a bug for this nor did I supply a fix because I don't know if you really *can* fix it. This behaviour must be around for a while, perhaps there are userland programs relying on it. Though they'll be broken anyway when being started on a real terminal. Regards, Julian #include <fcntl.h> #include <stdio.h> #include <unistd.h> #include <sys/stat.h> int main(int argc, char *argv[]) { struct stat s; int fd; if (argc != 2) { printf("a.out <filename>\n"); return 1; } if (!stat(argv[1], &s)) printf("stat atime: %d\n", (int)s.st_atime); if ((fd = open(argv[1], O_RDONLY, 0)) != -1) if (fstat(fd, &s) != -1) printf("open atime: %d\n", (int)s.st_atime); return 0; }
Attachment:
signature.asc
Description: PGP signature