Chinaunix首页 | 论坛 | 博客
  • 博客访问: 968692
  • 博文数量: 200
  • 博客积分: 5011
  • 博客等级: 大校
  • 技术积分: 2479
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-27 15:07
文章分类

全部博文(200)

文章存档

2009年(12)

2008年(190)

我的朋友

分类:

2008-11-03 17:44:16

4.18 file times

三个time:

1.       access time 上一次文件数据被访问读取的时间

2.       modification time 上一次文件数据被修改的时间

3.       change-status time 上一次inode被修改的时间,如对文件权限,所有者的修改

系统没有办法记载文件inode的上一次的读取时间,即没办法记录stat, access对某个文件的访问时间。但是我认为至少系统如果要根据你提供的文件路径定位文件的inode的话,首先要找到文件所在目录,要访问文件目录的directory entries数据,找到该文件对应的inode编号。所以上述操作会修改该文件所在目录的access time

 

下表,展示了各个函数会影响到的时间属性。

a : last access time

m: last modification time 这个是ls默认显示的时间。

c: last change-status time

Figure 4.20. Effect of various functions on the access, modification, and changed-status times


Function

Referenced file or directory

Parent directory of referenced file or directory

Section

Note

 

a

m

c

a

m

c

 

chmod, fchmod

 

 

 

 

 

4.9

 

 

chown, fchown

 

 

 

 

 

4.11

 

 

creat

 

3.4

O_CREAT new file

 

creat

 

 

 

 

3.4

O_TRUNC existing file

 

exec

 

 

 

 

 

8.10

 

 

lchown

 

 

 

 

 

4.11

 

 

link

 

 

 

4.15

parent of second argument

 

mkdir

 

4.20

 

 

mkfifo

 

15.5

 

 

open

 

3.3

O_CREAT new file

 

open

 

 

 

 

3.3

O_TRUNC existing file

 

pipe

 

 

 

15.2

 

 

read

 

 

 

 

 

3.7

 

 

remove

 

 

 

4.15

remove file = unlink

 

remove

 

 

 

 

4.15

remove directory = rmdir

 

rename

 

 

 

4.15

for both arguments

 

rmdir

 

 

 

 

4.20

 

 

truncate, ftruncate

 

 

 

 

4.13

 

 

unlink

 

 

 

4.15

 

 

utime

 

 

 

4.19

 

 

write

 

 

 

 

3.8

 

 

 

4.19 utime function

#include

 

int utime(const char *pathname, const struct

 utimbuf *times);

 

Returns: 0 if OK, 1 on error

struct utimbuf {
      time_t actime;    /* access time */
      time_t modtime;   /* modification time */
    }

 

这个函数可以修改atimemtime, 即最新的file data访问时间以及最新的file data修改时间。但是我们没有办法修改文件的inode的最新的修改时间,这个时间在我们调用utime时,就自动被设置成了当前的时间。

Touch tar命令等会利用这个函数用来设置,以及恢复文件的时间。

阅读(645) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~