adjtimex

一、介绍

      linux系统有两个时钟:一个是由主板电池驱动的“Real Time Clock”也叫做RTC或者叫CMOS时钟,硬件时钟。当操作系统关机的时候,用这个来记录时间,但是对于运行的系统是不用这个时间的。另一个时间是 “System clock”也叫内核时钟或者软件时钟,是由软件根据时间中断来进行计数的,内核时钟在系统关机的情况下是不存在的,所以,当操作系统启动的时候,内核时钟是要读取RTC时间来进行时间同步(有些情况下,内核时钟也可以通过ntp服务器来读取时间) 这两个时钟通常会有一些误差,所以长时间可以导致这两个时钟偏离的比较多,最简单的保持两个时间同步的方法是用软件测出他们之间的误差率,然后用软件进行修正。在每次重新启动系统的时候,系统都会用hwclock命令对时间进行同步。如果内核时钟在每一个时间中断都快或者慢的话,可以用adjtimex命令进行调整,使得RTC和内核时间走的快慢一致。 adjtimex 允许用户来调整内核的时间参数,因此可以改变内核时间的速度,可以用hwclock命令来比较出内核时间和RTC时间的偏移率,然后利用adjtimex 命令根据偏移率来对内核时间进行校正,使得内核时间走的快些或者慢些,当经过调整的内核时间跟RTC时间走的同样快的时候,可以把这个命令行写到启动脚本里面,让每次机器启动的时候都可以把内核的时间参数调整正确。

二、adjtimex 命令使用说明

语法:adjtimex [OPTION]… 主要参数说明:

  • -p, –print 输出内核时间变量的值
  • -t, –tick val 设置内核时钟计数间隔(微秒)
  • -f, –frequency newfreq 设置系统时钟偏移量
  • -c, –compare[=count] 比较系统时钟和CMOS时钟
  • -i, –interval tim 设置时钟比较间隔时间 (sec)
  • -l, –log[=file] 将当前时间记录到文件中
  • –host timeserver 查询时间服务器
  • -u, –utc 将CMOS时钟设置成UTC
三、 adjtimex应用

查看当前内核时间变量的信息

# adjtimex -p
       mode: 0
     offset: 0
  frequency: 573135
   maxerror: 16384000
   esterror: 16384000
     status: 65
time_constant: 6
  precision: 1
  tolerance: 33554432
       tick: 10000
   raw time:  1189736934s 800946us = 1189736934.800946

return value = 5

比较系统时钟和CMOS时钟的误差

# adjtimex --compare
                                         --- current ---    -- suggested --
cmos time     system-cmos       2nd diff    tick      freq     tick      freq
1191706436  -1969378.503326 -1969378.503326  10000    573135
1191706446  -1969378.503351      -0.000026   10000    573135
1191706456  -1969378.503359      -0.000007   10000    573135    10000    619952
1191706466  -1969378.503403      -0.000045   10000    573135    10000    866825
1191706476  -1969378.503406      -0.000003   10000    573135    10000    591825
1191706486  -1969378.503454      -0.000048   10000    573135    10000    887140
1191706496  -1969378.503449       0.000005   10000    573135    10000    540265
1191706506  -1969378.503510      -0.000061   10000    573135    10000    973075

2nd diff表示系统时间在10秒周期内快了还是慢了几秒种,如“-0.000026”在这里表示系统时间在10秒钟内慢了0.000026秒(注意,这里系统会连续测试出好几个连续的差别,一般可以参考平均值)。 前面的tick/freq字段表示内核的tick和freq值,后面的tick/freq表示系统对tick和freq的推荐值,用这个值可以对系统时间进行校正。针对上面的误差可以不需要校正,若需要修正可使用adjtimex –t或adjtimex –f指令进行修正。

修正系统时间和CMOS时间之间的误差:

# adjtimex –t 10002

把系统10秒(10000微秒)的长度定义成实际时间的10002微秒,也就是说让系统时间走的快点,也可以说每系统时间走10秒(10000微秒)就快2微秒,从而系统时间跟上了RTC时间,达到了时间校正的目的。

四、 系统代码实现说明

头文件 :

 #include <sys/timex.h>

函数原型:

int adjtimex(struct timex *buf);

函数说明:

Linux 使用 David L. Mill 的时钟调整算法系统调用 adjtimex() 读取和可选地设置该算法的调整参数。它以一个指向结构体 timex 指针为参数,更新内核参数相应的值,并且通过相同的结构体来返回内核当前的值。这个结构体被声明为如下:

struct timex {
int modes; /* 模式选择符 */
long offset; /* 时间偏移 (微秒) */
long freq; /* 频率偏移 (由 ppm 缩放) */
long maxerror; /* 最大错误 (微秒) */
long esterror; /* 估计的错误 (微秒) */
int status; /* 时钟 命令/状态 */
long constant; /* pll time constant */
long precision; /* clock precision (usec) (read-only) */
long tolerance; /* clock frequency tolerance (ppm) (read-only) */
struct timeval time; /* current time (read-only) */
long tick; /* 时钟滴答之间的微秒 */
};
modes 域用来指定哪个参数用于设置,如果需要的话。它可能包含下面值的位-或的组合:
#define ADJ_OFFSET 0x0001 /* 时间利偏移 */
#define ADJ_FREQUENCY 0x0002 /* 频率偏移 */
#define ADJ_MAXERROR 0x0004 /* 最大错误值 */
#define ADJ_ESTERROR 0x0008 /* 估计的错误值 */
#define ADJ_STATUS 0x0010 /* 时钟状态 */
#define ADJ_TIMECONST 0x0020 /* pll time constant */
#define ADJ_TICK 0x4000 /* 时钟滴答值 */
#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime() */
一般用户严格要求把 mode 的值设置为零,只有超级用户可以设置某些参数。
注意:adjtimex() 是 Linux 定义并不应该出现在可移植的程序里。参看 adjtime(3) 来获得更好移植性,但却缺少灵活性的调整系统时钟的方法。

返回值

成功时,adjtimex() 返回时钟状态:
#define TIME_OK 0 /* 时钟已同步 */
#define TIME_INS 1 /* 插入调整值 */
#define TIME_DEL 2 /* 删除调整值 */
#define TIME_OOP 3 /* 调整正进行 */
#define TIME_WAIT 4 /* 调整已经发生 */
#define TIME_BAD 5 /* 时钟没有同步 */
失败时,adjtimex() 返回 -1 并把 errno 设置为合适的值。

错误

EFAULT
buf 没有指向一个可写的内存。
EINVAL
试图设置,但是 buf.offset 超过从 -131071 到 +131071 范围,或者 buf.status 不是上面列出的值,或者     buf.tick 值超出从 900000/HZ 到 1100000/HZ,此处的 HZ 是系统时钟中断频率。
EPERM
buf.mode 不是零但调用者没有足够的权限。在 Linux 下至少需要要 CAP_SYS_TIME 权限。

loginutils/getty.c: In function ‘open_tty’: loginutils/getty.c:224:17: warning: ignoring return value of ‘fchown’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 224 | fchown(0, 0, 0); /* 0:0 */ | ^~~~~~~~~~~~~~~ CC loginutils/login.o loginutils/login.c: In function ‘login_main’: loginutils/login.c:558:9: warning: ignoring return value of ‘fchown’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 558 | fchown(0, pw->pw_uid, pw->pw_gid); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC loginutils/passwd.o CC loginutils/su.o CC loginutils/sulogin.o loginutils/sulogin.c: In function ‘sulogin_main’: loginutils/sulogin.c:55:17: warning: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 55 | dup(xopen(argv[0], O_RDWR)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ loginutils/sulogin.c:57:17: warning: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 57 | dup(0); | ^~~~~~ CC loginutils/vlock.o AR loginutils/lib.a LD mailutils/built-in.o CC mailutils/mail.o CC mailutils/makemime.o mailutils/makemime.c: In function ‘makemime_main’: mailutils/makemime.c:204:17: warning: ignoring return value of ‘freopen’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 204 | freopen(opt_output, "w", stdout); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC mailutils/popmaildir.o CC mailutils/reformime.o CC mailutils/sendmail.o AR mailutils/lib.a LD miscutils/built-in.o CC miscutils/adjtimex.o CC miscutils/ascii.o CC miscutils/bc.o CC miscutils/beep.o CC miscutils/chat.o CC miscutils/conspy.o CC miscutils/crond.o CC miscutils/crontab.o miscutils/crontab.c: In function ‘crontab_main’: miscutils/crontab.c:161:17: warning: ignoring return value of ‘fchown’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 161 | fchown(src_fd, pas->pw_uid, pas->pw_gid); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC miscutils/devmem.o CC miscutils/fbsplash.o CC miscutils/hdparm.o CC miscutils/hexedit.o CC miscutils/i2c_tools.o miscutils/i2c_tools.c: In function ‘list_i2c_busses_and_exit’: miscutils/i2c_tools.c:1152:46: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 236 [-Wformat-truncation=] 1152 | snprintf(path, NAME_MAX, "%s/%s/name", | ^~ In file included from /usr/arm-linux-gnueabi/include/stdio.h:980, from include/libbb.h:31, from miscutils/i2c_tools.c:66: In function ‘snprintf’, inlined from ‘list_i2c_busses_and_exit’ at miscutils/i2c_tools.c:1152:3: /usr/arm-linux-gnueabi/include/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 25 and 280 bytes into a destination of size 255 54 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ miscutils/i2c_tools.c: In function ‘list_i2c_busses_and_exit’: miscutils/i2c_tools.c:1157:38: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 236 [-Wformat-truncation=] 1157 | "%s/%s/device/name", | ^~ In function ‘snprintf’, inlined from ‘list_i2c_busses_and_exit’ at miscutils/i2c_tools.c:1156:4: /usr/arm-linux-gnueabi/include/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 32 and 287 bytes into a destination of size 255 54 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ miscutils/i2c_tools.c: In function ‘list_i2c_busses_and_exit’: miscutils/i2c_tools.c:1165:38: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 236 [-Wformat-truncation=] 1165 | "%s/%s/device/name", | ^~ In function ‘snprintf’, inlined from ‘list_i2c_busses_and_exit’ at miscutils/i2c_tools.c:1164:4: /usr/arm-linux-gnueabi/include/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 32 and 287 bytes into a destination of size 255 54 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ miscutils/i2c_tools.c: In function ‘list_i2c_busses_and_exit’: miscutils/i2c_tools.c:1177:54: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 236 [-Wformat-truncation=] 1177 | "%s/%s/device/%s/name", | ^~ In function ‘snprintf’, inlined from ‘list_i2c_busses_and_exit’ at miscutils/i2c_tools.c:1176:6: /usr/arm-linux-gnueabi/include/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 33 and 543 bytes into a destination of size 255 54 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ CC miscutils/less.o CC miscutils/lsscsi.o CC miscutils/makedevs.o CC miscutils/man.o miscutils/man.c: In function ‘run_pipe’: miscutils/man.c:160:9: warning: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 160 | system(cmd); | ^~~~~~~~~~~ CC miscutils/microcom.o miscutils/microcom.c: In function ‘microcom_main’: miscutils/microcom.c:160:25: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 160 | write(sfd, &c, 1); | ^~~~~~~~~~~~~~~~~ CC miscutils/mt.o CC miscutils/nandwrite.o CC miscutils/partprobe.o CC miscutils/raidautorun.o CC miscutils/readahead.o CC miscutils/runlevel.o CC miscutils/rx.o CC miscutils/seedrng.o CC miscutils/setfattr.o CC miscutils/setserial.o CC miscutils/strings.o CC miscutils/time.o CC miscutils/tree.o CC miscutils/ts.o CC miscutils/ttysize.o CC miscutils/ubi_tools.o CC miscutils/ubirename.o CC miscutils/volname.o CC miscutils/watchdog.o miscutils/watchdog.c: In function ‘watchdog_main’: miscutils/watchdog.c:161:17: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 161 | write(3, "", 1); /* write zero byte */ | ^~~~~~~~~~~~~~~ miscutils/watchdog.c: In function ‘shutdown_watchdog’: miscutils/watchdog.c:71:9: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 71 | write(3, &V, 1); /* Magic, see watchdog-api.txt in kernel */ | ^~~~~~~~~~~~~~~ AR miscutils/lib.a LD modutils/built-in.o CC modutils/modinfo.o CC modutils/modprobe-small.o CC modutils/modutils.o modutils/modutils.c: In function ‘filename2modname’: modutils/modutils.c:115:1: warning: function may return address of local variable [-Wreturn-local-addr] 115 | } | ^ modutils/modutils.c:94:14: note: declared here 94 | char local_modname[MODULE_NAME_LEN]; | ^~~~~~~~~~~~~ AR modutils/lib.a LD networking/built-in.o CC networking/arp.o In file included from networking/arp.c:43: networking/arp.c: In function ‘arp_show’: include/libbb.h:236:28: warning: ignoring return value of ‘fgets_unlocked’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 236 | # define fgets(s,n,stream) fgets_unlocked(s,n,stream) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ networking/arp.c:430:9: note: in expansion of macro ‘fgets’ 430 | fgets(line, sizeof(line), fp); | ^~~~~ CC networking/arping.o CC networking/brctl.o CC networking/dnsd.o CC networking/ether-wake.o CC networking/ftpd.o networking/ftpd.c: In function ‘popen_ls’: networking/ftpd.c:718:17: warning: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 718 | dup(STDOUT_FILENO); /* copy will become STDIN_FILENO */ | ^~~~~~~~~~~~~~~~~~ CC networking/ftpgetput.o CC networking/hostname.o CC networking/httpd.o CC networking/ifconfig.o CC networking/ifenslave.o CC networking/ifplugd.o CC networking/ifupdown.o CC networking/inetd.o CC networking/interface.o In file included from networking/interface.c:33: networking/interface.c: In function ‘if_readlist_proc’: include/libbb.h:236:28: warning: ignoring return value of ‘fgets_unlocked’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 236 | # define fgets(s,n,stream) fgets_unlocked(s,n,stream) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ networking/interface.c:554:9: note: in expansion of macro ‘fgets’ 554 | fgets(buf, sizeof buf, fh); /* eat line */ | ^~~~~ include/libbb.h:236:28: warning: ignoring return value of ‘fgets_unlocked’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 236 | # define fgets(s,n,stream) fgets_unlocked(s,n,stream) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ networking/interface.c:555:9: note: in expansion of macro ‘fgets’ 555 | fgets(buf, sizeof buf, fh); | ^~~~~ CC networking/ip.o CC networking/ipcalc.o CC networking/isrv.o CC networking/isrv_identd.o CC networking/nameif.o CC networking/nbd-client.o networking/nbd-client.c: In function ‘nbdclient_main’: networking/nbd-client.c:281:25: warning: ignoring return value of ‘daemon’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 281 | daemon(0, 0); | ^~~~~~~~~~~~ CC networking/nc.o CC networking/netstat.o CC networking/nslookup.o networking/nslookup.c: In function ‘send_queries’: networking/nslookup.c:622:33: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 622 | write(pfd.fd, G.query[qn].query, G.query[qn].qlen); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC networking/ntpd.o networking/ntpd.c: In function ‘update_local_clock’: networking/ntpd.c:1624:49: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘long long int’ [-Wformat=] 1624 | bb_error_msg("p adjtimex freq:%ld offset:%+ld status:0x%x tc:%ld", | ~~^ | | | long int | %lld 1625 | tmx.freq, tmx.offset, tmx.status, tmx.constant); | ~~~~~~~~ | | | long long int networking/ntpd.c:1624:61: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘long long int’ [-Wformat=] 1624 | bb_error_msg("p adjtimex freq:%ld offset:%+ld status:0x%x tc:%ld", | ~~~^ | | | long int | %+lld 1625 | tmx.freq, tmx.offset, tmx.status, tmx.constant); | ~~~~~~~~~~ | | | long long int networking/ntpd.c:1624:80: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘long long int’ [-Wformat=] 1624 | bb_error_msg("p adjtimex freq:%ld offset:%+ld status:0x%x tc:%ld", | ~~^ | | | long int | %lld 1625 | tmx.freq, tmx.offset, tmx.status, tmx.constant); | ~~~~~~~~~~~~ | | | long long int networking/ntpd.c:1739:48: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘long long int’ [-Wformat=] 1739 | VERB4 bb_error_msg("adjtimex:%d freq:%ld offset:%+ld status:0x%x", | ~~^ | | | long int | %lld 1740 | rc, tmx.freq, tmx.offset, tmx.status); | ~~~~~~~~ | | | long long int networking/ntpd.c:1739:60: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘long long int’ [-Wformat=] 1739 | VERB4 bb_error_msg("adjtimex:%d freq:%ld offset:%+ld status:0x%x", | ~~~^ | | | long int | %+lld 1740 | rc, tmx.freq, tmx.offset, tmx.status); | ~~~~~~~~~~ | | | long long int CC networking/parse_pasv_epsv.o CC networking/ping.o CC networking/pscan.o CC networking/route.o CC networking/slattach.o networking/slattach.c: In function ‘slattach_main’: networking/slattach.c:225:17: warning: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 225 | system(extcmd); | ^~~~~~~~~~~~~~ CC networking/ssl_client.o CC networking/tc.o networking/tc.c: In function ‘cbq_print_opt’: networking/tc.c:236:27: error: ‘TCA_CBQ_MAX’ undeclared (first use in this function); did you mean ‘TCA_CBS_MAX’? 236 | struct rtattr *tb[TCA_CBQ_MAX+1]; | ^~~~~~~~~~~ | TCA_CBS_MAX networking/tc.c:236:27: note: each undeclared identifier is reported only once for each function it appears in networking/tc.c:249:16: error: ‘TCA_CBQ_RATE’ undeclared (first use in this function); did you mean ‘TCA_TBF_RATE64’? 249 | if (tb[TCA_CBQ_RATE]) { | ^~~~~~~~~~~~ | TCA_TBF_RATE64 networking/tc.c:255:16: error: ‘TCA_CBQ_LSSOPT’ undeclared (first use in this function) 255 | if (tb[TCA_CBQ_LSSOPT]) { | ^~~~~~~~~~~~~~ networking/tc.c:256:61: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_lssopt’ 256 | if (RTA_PAYLOAD(tb[TCA_CBQ_LSSOPT]) < sizeof(*lss)) | ^ networking/tc.c:261:16: error: ‘TCA_CBQ_WRROPT’ undeclared (first use in this function) 261 | if (tb[TCA_CBQ_WRROPT]) { | ^~~~~~~~~~~~~~ networking/tc.c:262:61: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_wrropt’ 262 | if (RTA_PAYLOAD(tb[TCA_CBQ_WRROPT]) < sizeof(*wrr)) | ^ networking/tc.c:267:16: error: ‘TCA_CBQ_FOPT’ undeclared (first use in this function) 267 | if (tb[TCA_CBQ_FOPT]) { | ^~~~~~~~~~~~ networking/tc.c:268:59: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_fopt’ 268 | if (RTA_PAYLOAD(tb[TCA_CBQ_FOPT]) < sizeof(*fopt)) | ^ networking/tc.c:273:16: error: ‘TCA_CBQ_OVL_STRATEGY’ undeclared (first use in this function) 273 | if (tb[TCA_CBQ_OVL_STRATEGY]) { | ^~~~~~~~~~~~~~~~~~~~ networking/tc.c:274:67: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_ovl’ 274 | if (RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]) < sizeof(*ovl)) | ^ networking/tc.c:277:50: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_ovl’ 277 | (unsigned) sizeof(*ovl)); | ^ networking/tc.c:293:23: error: invalid use of undefined type ‘struct tc_cbq_lssopt’ 293 | if (lss && lss->flags) { | ^~ networking/tc.c:296:24: error: invalid use of undefined type ‘struct tc_cbq_lssopt’ 296 | if (lss->flags&TCF_CBQ_LSS_BOUNDED) { | ^~ networking/tc.c:296:32: error: ‘TCF_CBQ_LSS_BOUNDED’ undeclared (first use in this function) 296 | if (lss->flags&TCF_CBQ_LSS_BOUNDED) { | ^~~~~~~~~~~~~~~~~~~ networking/tc.c:300:24: error: invalid use of undefined type ‘struct tc_cbq_lssopt’ 300 | if (lss->flags&TCF_CBQ_LSS_ISOLATED) { | ^~ networking/tc.c:300:32: error: ‘TCF_CBQ_LSS_ISOLATED’ undeclared (first use in this function) 300 | if (lss->flags&TCF_CBQ_LSS_ISOLATED) { | ^~~~~~~~~~~~~~~~~~~~ networking/tc.c:308:24: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 308 | if (wrr->priority != TC_CBQ_MAXPRIO) | ^~ networking/tc.c:308:38: error: ‘TC_CBQ_MAXPRIO’ undeclared (first use in this function) 308 | if (wrr->priority != TC_CBQ_MAXPRIO) | ^~~~~~~~~~~~~~ networking/tc.c:309:46: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 309 | printf("prio %u", wrr->priority); | ^~ networking/tc.c:313:43: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 313 | printf("/%u ", wrr->cpriority); | ^~ networking/tc.c:314:32: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 314 | if (wrr->weight != 1) { | ^~ networking/tc.c:315:65: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 315 | print_rate(buf, sizeof(buf), wrr->weight); | ^~ networking/tc.c:318:32: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 318 | if (wrr->allot) | ^~ networking/tc.c:319:57: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 319 | printf("allot %ub ", wrr->allot); | ^~ networking/tc.c:236:24: warning: unused variable ‘tb’ [-Wunused-variable] 236 | struct rtattr *tb[TCA_CBQ_MAX+1]; | ^~ make[1]: *** [scripts/Makefile.build:198:networking/tc.o] 错误 1 make: *** [Makefile:744:networking] 错误 2 CC networking/tc.o networking/tc.c: In function ‘cbq_print_opt’: networking/tc.c:236:27: error: ‘TCA_CBQ_MAX’ undeclared (first use in this function); did you mean ‘TCA_CBS_MAX’? 236 | struct rtattr *tb[TCA_CBQ_MAX+1]; | ^~~~~~~~~~~ | TCA_CBS_MAX networking/tc.c:236:27: note: each undeclared identifier is reported only once for each function it appears in networking/tc.c:249:16: error: ‘TCA_CBQ_RATE’ undeclared (first use in this function); did you mean ‘TCA_TBF_RATE64’? 249 | if (tb[TCA_CBQ_RATE]) { | ^~~~~~~~~~~~ | TCA_TBF_RATE64 networking/tc.c:255:16: error: ‘TCA_CBQ_LSSOPT’ undeclared (first use in this function) 255 | if (tb[TCA_CBQ_LSSOPT]) { | ^~~~~~~~~~~~~~ networking/tc.c:256:61: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_lssopt’ 256 | if (RTA_PAYLOAD(tb[TCA_CBQ_LSSOPT]) < sizeof(*lss)) | ^ networking/tc.c:261:16: error: ‘TCA_CBQ_WRROPT’ undeclared (first use in this function) 261 | if (tb[TCA_CBQ_WRROPT]) { | ^~~~~~~~~~~~~~ networking/tc.c:262:61: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_wrropt’ 262 | if (RTA_PAYLOAD(tb[TCA_CBQ_WRROPT]) < sizeof(*wrr)) | ^ networking/tc.c:267:16: error: ‘TCA_CBQ_FOPT’ undeclared (first use in this function) 267 | if (tb[TCA_CBQ_FOPT]) { | ^~~~~~~~~~~~ networking/tc.c:268:59: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_fopt’ 268 | if (RTA_PAYLOAD(tb[TCA_CBQ_FOPT]) < sizeof(*fopt)) | ^ networking/tc.c:273:16: error: ‘TCA_CBQ_OVL_STRATEGY’ undeclared (first use in this function) 273 | if (tb[TCA_CBQ_OVL_STRATEGY]) { | ^~~~~~~~~~~~~~~~~~~~ networking/tc.c:274:67: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_ovl’ 274 | if (RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]) < sizeof(*ovl)) | ^ networking/tc.c:277:50: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_ovl’ 277 | (unsigned) sizeof(*ovl)); | ^ networking/tc.c:293:23: error: invalid use of undefined type ‘struct tc_cbq_lssopt’ 293 | if (lss && lss->flags) { | ^~ networking/tc.c:296:24: error: invalid use of undefined type ‘struct tc_cbq_lssopt’ 296 | if (lss->flags&TCF_CBQ_LSS_BOUNDED) { | ^~ networking/tc.c:296:32: error: ‘TCF_CBQ_LSS_BOUNDED’ undeclared (first use in this function) 296 | if (lss->flags&TCF_CBQ_LSS_BOUNDED) { | ^~~~~~~~~~~~~~~~~~~ networking/tc.c:300:24: error: invalid use of undefined type ‘struct tc_cbq_lssopt’ 300 | if (lss->flags&TCF_CBQ_LSS_ISOLATED) { | ^~ networking/tc.c:300:32: error: ‘TCF_CBQ_LSS_ISOLATED’ undeclared (first use in this function) 300 | if (lss->flags&TCF_CBQ_LSS_ISOLATED) { | ^~~~~~~~~~~~~~~~~~~~ networking/tc.c:308:24: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 308 | if (wrr->priority != TC_CBQ_MAXPRIO) | ^~ networking/tc.c:308:38: error: ‘TC_CBQ_MAXPRIO’ undeclared (first use in this function) 308 | if (wrr->priority != TC_CBQ_MAXPRIO) | ^~~~~~~~~~~~~~ networking/tc.c:309:46: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 309 | printf("prio %u", wrr->priority); | ^~ networking/tc.c:313:43: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 313 | printf("/%u ", wrr->cpriority); | ^~ networking/tc.c:314:32: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 314 | if (wrr->weight != 1) { | ^~ networking/tc.c:315:65: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 315 | print_rate(buf, sizeof(buf), wrr->weight); | ^~ networking/tc.c:318:32: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 318 | if (wrr->allot) | ^~ networking/tc.c:319:57: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 319 | printf("allot %ub ", wrr->allot); | ^~ networking/tc.c:236:24: warning: unused variable ‘tb’ [-Wunused-variable] 236 | struct rtattr *tb[TCA_CBQ_MAX+1]; | ^~ make[1]: *** [scripts/Makefile.build:198:networking/tc.o] 错误 1 make: *** [Makefile:744:networking] 错误 2
06-12
networking/ntpd.c: In function ‘update_local_clock’: networking/ntpd.c:1624:49: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘long long int’ [-Wformat=] 1624 | bb_error_msg("p adjtimex freq:%ld offset:%+ld status:0x%x tc:%ld", | ~~^ | | | long int | %lld 1625 | tmx.freq, tmx.offset, tmx.status, tmx.constant); | ~~~~~~~~ | | | long long int networking/ntpd.c:1624:61: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘long long int’ [-Wformat=] 1624 | bb_error_msg("p adjtimex freq:%ld offset:%+ld status:0x%x tc:%ld", | ~~~^ | | | long int | %+lld 1625 | tmx.freq, tmx.offset, tmx.status, tmx.constant); | ~~~~~~~~~~ | | | long long int networking/ntpd.c:1624:80: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘long long int’ [-Wformat=] 1624 | bb_error_msg("p adjtimex freq:%ld offset:%+ld status:0x%x tc:%ld", | ~~^ | | | long int | %lld 1625 | tmx.freq, tmx.offset, tmx.status, tmx.constant); | ~~~~~~~~~~~~ | | | long long int networking/ntpd.c:1739:48: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘long long int’ [-Wformat=] 1739 | VERB4 bb_error_msg("adjtimex:%d freq:%ld offset:%+ld status:0x%x", | ~~^ | | | long int | %lld 1740 | rc, tmx.freq, tmx.offset, tmx.status); | ~~~~~~~~ | | | long long int networking/ntpd.c:1739:60: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘long long int’ [-Wformat=] 1739 | VERB4 bb_error_msg("adjtimex:%d freq:%ld offset:%+ld status:0x%x", | ~~~^ | | | long int | %+lld 1740 | rc, tmx.freq, tmx.offset, tmx.status); | ~~~~~~~~~~ | | | long long int CC networking/parse_pasv_epsv.o CC networking/ping.o CC networking/pscan.o CC networking/route.o CC networking/slattach.o networking/slattach.c: In function ‘slattach_main’: networking/slattach.c:225:17: warning: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 225 | system(extcmd); | ^~~~~~~~~~~~~~ CC networking/ssl_client.o CC networking/tc.o networking/tc.c: In function ‘cbq_print_opt’: networking/tc.c:236:27: error: ‘TCA_CBQ_MAX’ undeclared (first use in this function); did you mean ‘TCA_CBS_MAX’? 236 | struct rtattr *tb[TCA_CBQ_MAX+1]; | ^~~~~~~~~~~ | TCA_CBS_MAX networking/tc.c:236:27: note: each undeclared identifier is reported only once for each function it appears in networking/tc.c:249:16: error: ‘TCA_CBQ_RATE’ undeclared (first use in this function); did you mean ‘TCA_TBF_RATE64’? 249 | if (tb[TCA_CBQ_RATE]) { | ^~~~~~~~~~~~ | TCA_TBF_RATE64 networking/tc.c:255:16: error: ‘TCA_CBQ_LSSOPT’ undeclared (first use in this function) 255 | if (tb[TCA_CBQ_LSSOPT]) { | ^~~~~~~~~~~~~~ networking/tc.c:256:61: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_lssopt’ 256 | if (RTA_PAYLOAD(tb[TCA_CBQ_LSSOPT]) < sizeof(*lss)) | ^ networking/tc.c:261:16: error: ‘TCA_CBQ_WRROPT’ undeclared (first use in this function) 261 | if (tb[TCA_CBQ_WRROPT]) { | ^~~~~~~~~~~~~~ networking/tc.c:262:61: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_wrropt’ 262 | if (RTA_PAYLOAD(tb[TCA_CBQ_WRROPT]) < sizeof(*wrr)) | ^ networking/tc.c:267:16: error: ‘TCA_CBQ_FOPT’ undeclared (first use in this function) 267 | if (tb[TCA_CBQ_FOPT]) { | ^~~~~~~~~~~~ networking/tc.c:268:59: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_fopt’ 268 | if (RTA_PAYLOAD(tb[TCA_CBQ_FOPT]) < sizeof(*fopt)) | ^ networking/tc.c:273:16: error: ‘TCA_CBQ_OVL_STRATEGY’ undeclared (first use in this function) 273 | if (tb[TCA_CBQ_OVL_STRATEGY]) { | ^~~~~~~~~~~~~~~~~~~~ networking/tc.c:274:67: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_ovl’ 274 | if (RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]) < sizeof(*ovl)) | ^ networking/tc.c:277:50: error: invalid application of ‘sizeof’ to incomplete type ‘struct tc_cbq_ovl’ 277 | (unsigned) sizeof(*ovl)); | ^ networking/tc.c:293:23: error: invalid use of undefined type ‘struct tc_cbq_lssopt’ 293 | if (lss && lss->flags) { | ^~ networking/tc.c:296:24: error: invalid use of undefined type ‘struct tc_cbq_lssopt’ 296 | if (lss->flags&TCF_CBQ_LSS_BOUNDED) { | ^~ networking/tc.c:296:32: error: ‘TCF_CBQ_LSS_BOUNDED’ undeclared (first use in this function) 296 | if (lss->flags&TCF_CBQ_LSS_BOUNDED) { | ^~~~~~~~~~~~~~~~~~~ networking/tc.c:300:24: error: invalid use of undefined type ‘struct tc_cbq_lssopt’ 300 | if (lss->flags&TCF_CBQ_LSS_ISOLATED) { | ^~ networking/tc.c:300:32: error: ‘TCF_CBQ_LSS_ISOLATED’ undeclared (first use in this function) 300 | if (lss->flags&TCF_CBQ_LSS_ISOLATED) { | ^~~~~~~~~~~~~~~~~~~~ networking/tc.c:308:24: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 308 | if (wrr->priority != TC_CBQ_MAXPRIO) | ^~ networking/tc.c:308:38: error: ‘TC_CBQ_MAXPRIO’ undeclared (first use in this function) 308 | if (wrr->priority != TC_CBQ_MAXPRIO) | ^~~~~~~~~~~~~~ networking/tc.c:309:46: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 309 | printf("prio %u", wrr->priority); | ^~ networking/tc.c:313:43: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 313 | printf("/%u ", wrr->cpriority); | ^~ networking/tc.c:314:32: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 314 | if (wrr->weight != 1) { | ^~ networking/tc.c:315:65: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 315 | print_rate(buf, sizeof(buf), wrr->weight); | ^~ networking/tc.c:318:32: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 318 | if (wrr->allot) | ^~ networking/tc.c:319:57: error: invalid use of undefined type ‘struct tc_cbq_wrropt’ 319 | printf("allot %ub ", wrr->allot); | ^~ networking/tc.c:236:24: warning: unused variable ‘tb’ [-Wunused-variable] 236 | struct rtattr *tb[TCA_CBQ_MAX+1]; | ^~ make[1]: *** [scripts/Makefile.build:198:networking/tc.o] 错误 1 make: *** [Makefile:744:networking] 错误 2
06-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值