summaryrefslogtreecommitdiffstats
path: root/init/bootchart.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/bootchart.c')
-rw-r--r--init/bootchart.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/init/bootchart.c b/init/bootchart.c
index f72fcaa..a514261 100644
--- a/init/bootchart.c
+++ b/init/bootchart.c
@@ -119,6 +119,18 @@ file_buff_done( FileBuff buff )
}
}
+static long long
+get_uptime_jiffies()
+{
+ char buff[64];
+ long long jiffies = 0;
+
+ if (proc_read("/proc/uptime", buff, sizeof(buff)) > 0)
+ jiffies = 100LL*strtod(buff,NULL);
+
+ return jiffies;
+}
+
static void
log_header(void)
{
@@ -185,22 +197,11 @@ static void
do_log_uptime(FileBuff log)
{
char buff[65];
- int fd, ret, len;
+ int len;
- fd = open("/proc/uptime",O_RDONLY);
- if (fd >= 0) {
- int ret;
- ret = unix_read(fd, buff, 64);
- close(fd);
- buff[64] = 0;
- if (ret >= 0) {
- long long jiffies = 100LL*strtod(buff,NULL);
- int len;
- snprintf(buff,sizeof(buff),"%lld\n",jiffies);
- len = strlen(buff);
- file_buff_write(log, buff, len);
- }
- }
+ snprintf(buff,sizeof(buff),"%lld\n",get_uptime_jiffies());
+ len = strlen(buff);
+ file_buff_write(log, buff, len);
}
static void
@@ -376,3 +377,9 @@ void bootchart_finish( void )
file_buff_done(log_procs);
acct(NULL);
}
+
+/* called to get time (in ms) used by bootchart */
+long long bootchart_gettime( void )
+{
+ return 10LL*get_uptime_jiffies();
+}