/home/bbs/bin/fixdir -h 运行结果:
Usage: /home/bbs/bin/fixdir [OPTION]... DIR
-m fix mail mode
-t test mode. generate .tmpfile only
-h show this message
examples:
To fix a user's mail directory:
/home/bbs/bin/fixdir -m /home/bbs/mail/K/kxn
notice:
In mailmode it will set all the mail readed.
根据以上信息,“-t”应该“只生成.tmpfile”,即测试模式。
fixdir.c 摘录(最新snapshot from dev.kcn.cn,20060908):
//...
int flag=1;
//...
while (1) {
//...
c = getopt(argc, argv, "mth");
//...
switch (c) {
//...
case 't':
flag = 0;
break;
//...
}
//...
}
//...
if (!flag) { // 这儿应该是测试模式?因为 flag=0 是由 -t 得来的。
struct stat st;
int restore = 0;
struct utimbuf ut;
if (stat(".DIR", &st) != -1)
restore = 1;
// 但是似乎这个 if 语句块是非 test mode 部分,
// 因为下面替换了 .DIR 文件。
printf("\nwrite .DIR ok=%d\n", f_mv(".tmpfile", ".DIR"));
if (restore) {
chmod(".DIR", st.st_mode);
ut.actime = st.st_atime;
ut.modtime = st.st_mtime;
utime(".DIR", &ut);
}
}
//...
从程序运行结果来看,“-t”时只生成了 .DIR 文件,而不加“-t”则只是生成了
.tmpfile,而没有 mv .tmpfile .DIR。
不知道这是不是 fixdir.c 的一个 bug?
--
FROM 211.151.89.*