📄 128.html
字号:
1.ctime含inode信息修改的时间.mtime只指文件内容建立或修改的时间.<br>
2 不会.<br>
3.这些信息应该是存在文件系统的超级块里.<br>
<br>
我查了书 -ctime 是指 inode 的改变(或称文件的状态改变).<br>
请问 inode 存了哪些信息 ?<br>
做了些小测试,-mtime 改, -ctime 一定也改.<br>
改文件名, -ctime 也会改.<br>
谁能回答 i-node 存了哪些东西 ?<br>
<br>
vi /usr/include/sys/inode.h<br>
<br>
班主,我不能 access /usr/include/sys/inode.h .<br>
摘书如下:<br>
Directories contain directory entries. Each entry contains a file or subdirectory name and an index node reference number (i-node number). To increase speed and enhance use of disk space, the data in a file is stored at various locations in the computer's memory. The i-node contains the addresses used to locate all the scattered blocks of data associated with a file. The i-node also records other information about the file including time of modification and access, access modes, number of links, file owner, and file type.<br>
可我发现 -atime 改了, -ctime 还没改. why ?<br>
( 我先 cat 一个 ASCII 文件,再用 -atime -1 有它用 -ctime -1 居然没有它.)<br>
着岂不跟 inode 信息改变, ctime 就改矛盾吗?<br>
<br>
我不同意你贴出来的那段文章,正如我提到的那样,atime,ctime,mtime是放到超级块里,在sco unix下是一种叫stat的结构.(stat_32),不同的系统文件系统可能不同.<br>
sco 下inode的结构如下:<br>
<br>
typedef struct inode<br>
{<br>
struct inode *i_forw; /* inode hash chain */<br>
struct inode *i_back; /* '' */<br>
struct inode *av_forw; /* freelist chain */<br>
struct inode *av_back; /* '' */<br>
int *i_fsptr; /* "typeless" pointer to fs dependent */<br>
ino32_t i_number; /* i number, 1-to-1 with dev address */<br>
ushort i_ftype; /* file type = IFDIR, IFREG, etc. */<br>
short i_fstyp; /* File system type */<br>
off_t i_size; /* size of file */<br>
ushort i_uid; /* owner */<br>
ushort i_gid; /* group of owner */<br>
ushort i_flag;<br>
ushort i_want; /* i_flag extension to avoid MP races */<br>
ushort i_count; /* reference count */<br>
short i_nlink; /* directory entries */<br>
dev_t i_rdev; /* Raw device number */<br>
#define i_namtype i_rdev /* i_ftype==IFNAM subtype */<br>
dev_t i_dev; /* device where inode resides */<br>
struct mount *i_mton;/* ptr to mount table entry that */<br>
/* this directory is mounted on */<br>
struct region *i_rp; /* ptr to shared region if any */<br>
struct stdata *i_sp; /* ptr to associated stream */<br>
struct iisem *isem; /* ptr to XENIX semaphores */<br>
struct iisd *isd; /* ptr to XENIX shared data */<br>
} i_un;<br>
#define i_mnton i_un.i_mton /* i_ftype==IFDIR IMOUNT */<br>
#define i_rptr i_un.i_rp /* i_ftype==IFREG || i_ftype==IFBLK */<br>
#define i_sptr i_un.i_sp /* i_ftype==IFCHR || i_ftype==IFIFO */<br>
#define i_sem i_un.isem /* i_ftype==IFNAM && i_namtype==IFSEM */<br>
#define i_sd i_un.isd /* i_ftype==IFNAM && i_namtype==IFSHD */<br>
<br>
struct fstypsw *i_fstypp; /* ptr to file system switch FSPTR */<br>
long *i_filocks; /* pointer to filock (structure) list */<br>
unsigned long i_mappages; /* number of pages currently cached */<br>
unsigned long i_vcode; /* read-ahead block save (NFS) */<br>
short i_wcnt; /* write open count or ITEXT count */<br>
struct lockb i_cilock; /* tas to synchronize i_flag changes */<br>
ushort i_rdlocks; /* count of non-exclusive lockers */<br>
} inode_t;<br>
<br>
<br>
所以,访问一个文件不能改变inode信息.<br>
使用chown, chgrp, chmod命令可以很好的比较mtime和ctime<br>
chown改变一个文件的属主,用ctime可以找到,用mtime便找不到.<br>
试试看.<br>
<br>
多谢斑竹! 我是在 Solaris 上面试的.我是对 -ctime 不明白.<br>
试的结果如下:<br>
修改文件,-mtime 改了, -ctime 也会改.<br>
访问文件,-atime 改了, -ctime 没变.<br>
chown, chgrp, chmod,mv, 都会使 -ctime 改变,但不影响 -atime 和 -mtime.<br>
touch 可以改 -mtime and/or -atime,但 touch -a 只改访问时间时,-ctime也改了.<br>
touch -m 改修改时间时,-ctime当然也改了.<br>
好象还有别的很多东西可以令 -ctime 改变, 搞不清楚.<br>
有什么方法可以显示 -mtime,atime,ctime 吗?<br>
可以用 -ctime 来实现对目录的增量文件进行备份或 transfer 吗 ?<br>
多谢!<br>
<br>
没有什么工具显示,(可能是俺不知道)<br>
把下面程序里的st_mtime换成st_ctime,或st_atime便可以得到你要的了.<br>
#include <sys/stat.h><br>
int<br>
main (int argc, char **argv)<br>
{<br>
struct stat buf;<br>
char date[80];<br>
char fname[80];<br>
printf("Enter filename (with full path) to check mtime : ");<br>
scanf("%s",fname);<br>
stat(fname, &buf);<br>
printf ("mtime (in sec) of %s = %ld", fname, buf.st_mtime);<br>
strcpy(date, ctime((time_t *)&(buf.st_mtime)));<br>
printf ("mtime (in date) of %s = %s", fname, date);<br>
}<br>
<br>
至于文件备份,有什么不可以的么?<br>
<br>
mtime ls -l 最近修改文件内容的时间<br>
atime ls -lu 最近访问文件的时间<br>
ctime ls -li 最近文件有所改变的状态 ,如文件修改,属性属主 改变 ,节点 ,链接变化等 ,应该是不拘泥只是时间前后的改变<br>
<br>
俺看了ls的帮助,以为只是按ctime或atime排序,显示的时间还是mtime.<br>
<br>
仔细比较了一下,ayhan说的是对的.谢谢ayhan.<br>
<br>
多谢 ahyan 提示 ! 我在 Solaris 上试过如下:<br>
mtime 用 ls -l 看到<br>
atime 用 ls -lu 看到<br>
ctime 用 ls -lc 看到. (ls -li 只有 inode number)<br>
摘书如下:<br>
-c Uses time of last modification of the i-node (file<br>
created, mode changed, and so forth) for sorting (-t)<br>
or printing (-l or -n).<br>
-u Uses time of last access instead of last modification<br>
for sorting (with the -t option) or printing (with the<br>
-l option).<br>
-i For each file, prints the i-node number in the first<br>
column of the report.<br>
<br>
我在sco unix5.0.5中试了一下,好像不对:chmod,chgrp等不会改变ls -il显示的时间;vi,touch倒是有影响。
</FONT><br>
</TD>
</TR>
<TR>
<TD colSpan=2><FONT
class=middlefont></FONT><BR>
<FONT
class=normalfont>全文结束</FONT> </TD>
</TR>
<TR>
<TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2
height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top width="20%"
background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2>
<DIV align=center>
<table class=tableoutline cellspacing=1 cellpadding=4
width="100%" align=center border=0>
<tr class=firstalt>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
<font class=normalfont><b>所有分类</b></font></td>
</tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td> </tr> </table></td></tr> </table>
</DIV></TD></TR>
<TR vAlign=top>
<TD width="80%">
<DIV align=center><BR>
</DIV>
</TD></TR></TBODY></TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee
border=0><TBODY>
<TR>
<TD width="50%">
<P><FONT class=middlefont>版权所有 © 2004 <A
href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
违者必究. </FONT></P>
</TD>
<TD width="50%">
<DIV align=right><FONT class=middlefont>Powered by: <A
href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
</TD></TR></TBODY></TABLE>
<CENTER></CENTER></TD></TR>
</TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -