chroot-ed环境中的当前时间与当地时间不同

时间:2013-12-06 08:36:22

标签: c linux time chroot

c program环境中的chrooted {}未提供正确current time,如何处理?有东西要装吗?它在正常目录中正常工作。但是chroot似乎有些不对劲。

#include <stdio.h>      /* puts */
#include <time.h>       /* time_t, struct tm, time, localtime, strftime */

int main ()
{
  time_t rawtime;
  struct tm * timeinfo;
  char buffer [80];

  time (&rawtime);
  timeinfo = localtime (&rawtime);

  strftime (buffer,80,"date=%Y-%m-%d time=%H:%M:%S",timeinfo);
  puts (buffer);

  return 0;
}

正常执行:

./bin/binarycode
date=2013-09-23 time=20:09:02

chrooted执行:

/usr/sbin/chroot /var/rooted /bin/binarycode
date=2013-09-24 time=01:50:04 

似乎时间显示为5.30小时。差。

在这种情况下我不能做softlink / hardlink。我在redhat上运行它。

0 个答案:

没有答案