2009-11-22 07:07:58 +00:00
|
|
|
# Copyright (c) 2009 Upi Tamminen <desaster@gmail.com>
|
|
|
|
# See the COPYRIGHT file for more information
|
|
|
|
|
|
|
|
# Should be compatible with user mode linux
|
|
|
|
|
|
|
|
import struct, sys
|
|
|
|
|
|
|
|
OP_OPEN, OP_CLOSE, OP_WRITE, OP_EXEC = 1, 2, 3, 4
|
|
|
|
DIR_READ, DIR_WRITE = 1, 2
|
|
|
|
|
|
|
|
def ttylog_write(logfile, len, direction, stamp, data = None):
|
2009-11-22 19:22:36 +00:00
|
|
|
f = file(logfile, 'ab')
|
2009-11-22 07:07:58 +00:00
|
|
|
sec, usec = int(stamp), int(1000000 * (stamp - int(stamp)))
|
2010-08-16 16:15:18 +00:00
|
|
|
f.write(struct.pack('<iLiiLL', 3, 0, len, direction, sec, usec))
|
2009-11-22 07:07:58 +00:00
|
|
|
f.write(data)
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
def ttylog_open(logfile, stamp):
|
2009-11-22 19:22:36 +00:00
|
|
|
f = file(logfile, 'ab')
|
2009-11-22 07:07:58 +00:00
|
|
|
sec, usec = int(stamp), int(1000000 * (stamp - int(stamp)))
|
2010-08-16 16:15:18 +00:00
|
|
|
f.write(struct.pack('<iLiiLL', 1, 0, 0, 0, sec, usec))
|
2009-11-22 07:07:58 +00:00
|
|
|
f.close()
|
|
|
|
|
|
|
|
def ttylog_close(logfile, stamp):
|
2009-11-22 19:22:36 +00:00
|
|
|
f = file(logfile, 'ab')
|
2009-11-22 07:07:58 +00:00
|
|
|
sec, usec = int(stamp), int(1000000 * (stamp - int(stamp)))
|
2010-08-16 16:15:18 +00:00
|
|
|
f.write(struct.pack('<iLiiLL', 2, 0, 0, 0, sec, usec))
|
2009-11-22 07:07:58 +00:00
|
|
|
f.close()
|
|
|
|
|
|
|
|
# vim: set sw=4 et:
|