diff options
author | hunt <hunt> | 2006-06-26 17:02:21 +0000 |
---|---|---|
committer | hunt <hunt> | 2006-06-26 17:02:21 +0000 |
commit | 51bb792946b6ec2fb7d99195a898a4ada97a9a5a (patch) | |
tree | 81d910a3ca9a50f0eee945f8d1c487188d4c6fa5 /tapset/aux_syscalls.stp | |
parent | 1f901031dc00f0afa0a8a210bafe040ab510154c (diff) | |
download | systemtap-steved-51bb792946b6ec2fb7d99195a898a4ada97a9a5a.tar.gz systemtap-steved-51bb792946b6ec2fb7d99195a898a4ada97a9a5a.tar.xz systemtap-steved-51bb792946b6ec2fb7d99195a898a4ada97a9a5a.zip |
2006-06-26 Martin Hunt <hunt@redhat.com>
* aux_syscalls.stp (_stp_ctime): New function.
(_struct_utimbuf_u): New function.
Diffstat (limited to 'tapset/aux_syscalls.stp')
-rw-r--r-- | tapset/aux_syscalls.stp | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/tapset/aux_syscalls.stp b/tapset/aux_syscalls.stp index fdfa60f2..cfbe3192 100644 --- a/tapset/aux_syscalls.stp +++ b/tapset/aux_syscalls.stp @@ -39,12 +39,66 @@ function _struct_timezone_u:string(uaddr:long) strlcpy (THIS->__retvalue, "NULL", MAXSTRINGLEN); else { if(_stp_copy_from_user((char*)&tz,ptr,sizeof(struct timezone)) == 0) - snprintf(THIS->__retvalue, MAXSTRINGLEN, "[%d, %d]", tz.tz_minuteswest, tz.tz_dsttime); + snprintf(THIS->__retvalue, MAXSTRINGLEN, "[%d, %d]", tz.tz_minuteswest, tz.tz_dsttime); else strlcpy (THIS->__retvalue, "UNKNOWN", MAXSTRINGLEN); } %} +%{ +static const int days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; +static void _stp_ctime(time_t t, char *buf, int buflen) +{ + int mon=1, day, hour, min, sec, num, d, year = 1970; + + sec = t % 60; + min = t/60 % 60; + hour = t/(60*60) % 24; + day = t/(24*60*60); + + while(1) { + d = (!(year % 4) && ((year % 100) || !(year % 400))) ? 366 : 365; + if (day >= d) + day -= d; + else + break; + year++; + } + while (mon < 12) { + num = days_in_month[mon-1]; + if (mon == 2 && d == 366) + num++; + if (day >= num) + day -= num; + else + break; + mon++; + } + + snprintf(buf, buflen, "%4d/%02d/%02d-%02d:%02d:%02d", year, mon, day+1, hour, min, sec); + buf[buflen-1] = 0; +} +%} + +function _struct_utimbuf_u:string(uaddr:long) +%{ /* pure */ + #include <linux/utime.h> + struct utimbuf ubuf; + static char abuf[24], mbuf[24]; + char *ptr = (char *)(unsigned long)THIS->uaddr; + + if (ptr == NULL) + strlcpy (THIS->__retvalue, "NULL", MAXSTRINGLEN); + else { + if(_stp_copy_from_user((char*)&ubuf,ptr,sizeof(struct utimbuf)) == 0) { + _stp_ctime(ubuf.actime, abuf, 24); + _stp_ctime(ubuf.modtime, mbuf, 24); + snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s, %s", abuf, mbuf); + } else + strlcpy (THIS->__retvalue, "UNKNOWN", MAXSTRINGLEN); + } +%} + function _struct_timespec_u:string(uaddr:long) %{ /* pure */ struct timespec ts; |