/usr/share/systemtap/tapset/dyninst/ctime.stp is in systemtap-common 2.3-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | /* ctime.stp - Convert seconds to human readable date string.
*
* Copyright (C) 2012 Red Hat, Inc.
*/
/* NB: functionally equivalent to linux/ctime.stp
* This means unlike normal userspace ctime(), this version
* returns time in UTC, without a final newline.
*/
%{
#include <string.h>
#include <time.h>
%}
function ctime:string(epochsecs:long)
%{ /* pure */
struct tm gmt;
char buf[26];
const time_t t = STAP_ARG_epochsecs;
if (gmtime_r(&t, &gmt) && asctime_r(&gmt, buf)) {
char* newline = strchr(buf, '\n');
if (newline)
*newline = '\0';
strlcpy (STAP_RETVALUE, buf, MAXSTRINGLEN);
} else {
#if STAP_COMPAT_VERSION <= STAP_VERSION(2,2)
strlcpy(STAP_RETVALUE, "<invalid time>", MAXSTRINGLEN);
#else
CONTEXT->last_error = "Time cannot be converted";
#endif
}
%}
|