OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[linuxjm/LDP_man-pages.git] / release / man2 / utime.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1995-06-10 by Andries Brouwer <aeb@cwi.nl>
28 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
29 .\" Modified 2004-10-10 by Andries Brouwer <aeb@cwi.nl>
30 .\"
31 .\" Japanese Version Copyright (c) 1997 SUTO, Mitsuaki
32 .\"         all rights reserved.
33 .\" Translated Thu Jun 26 21:28:00 JST 1997
34 .\"         by SUTO, Mitsuaki <suto@av.crl.sony.co.jp>
35 .\" Updated & Modified Tue Feb 15 03:21:17 JST 2005
36 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
37 .\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36
38 .\" Updated 2007-10-13, Akihiro MOTOKI, LDP v2.65
39 .\" Updated 2008-08-08, Akihiro MOTOKI, LDP v3.05
40 .\"
41 .TH UTIME 2 2008-08-06 "Linux" "Linux Programmer's Manual"
42 .SH 名前
43 utime, utimes \- ファイルの最終アクセス時刻と修正時刻を変更する
44 .SH 書式
45 .nf
46 .B #include <sys/types.h>
47 .br
48 .B #include <utime.h>
49 .sp
50 .BI "int utime(const char *" filename ", const struct utimbuf *" times );
51 .sp
52 .B #include <sys/time.h>
53 .sp
54 .BI "int utimes(const char *" filename ", const struct timeval " times [2]);
55 .fi
56 .SH 説明
57 .BR utime ()
58 システムコールは
59 .I filename
60 で示される inode のアクセス時刻と修正時刻を
61 .I times
62 中の
63 .IR actime " と " modtime
64 にそれぞれ変更する。
65
66 .I times
67
68 .B NULL
69 の場合、ファイルのアクセス時刻と修正時刻は現在の時刻に設定される。
70
71 タイムスタンプの変更は以下のいずれかの場合に許可される。
72 プロセスに適切な特権がある場合、
73 実効 (effective) ユーザ ID がファイルのユーザ ID と等しい場合、
74 .I times
75 が NULL かつ、プロセスがファイルへの書き込み許可を持っている場合。
76
77 構造体
78 .I utimbuf
79 は以下に示すようになっている。
80
81 .in +4n
82 .nf
83 struct utimbuf {
84     time_t actime;       /* アクセス時刻 */
85     time_t modtime;      /* 修正時刻 */
86 };
87 .fi
88 .in
89
90 .BR utime ()
91 システムコールは 1 秒の分解能でタイムスタンプを指定することができる。
92
93 .BR utimes ()
94
95 .BR utime ()
96 と同様であるが、
97 .I times
98 引き数が構造体ではなく配列を参照する。
99 この配列の要素は
100 .I timeval
101 構造体で、タイムスタンプの指定を 1 マイクロ秒の分解能で行うことができる。
102 構造体
103 .I timeval
104 は以下に示す通りである。
105
106 .in +4n
107 .nf
108 struct timeval {
109     long tv_sec;        /* 秒 */
110     long tv_usec;       /* マイクロ秒 */
111 };
112 .fi
113 .in
114 .PP
115 .IR times [0]
116 は新しいアクセス時刻を、
117 .IR times [1]
118 は新しい修正時刻を規定する。
119 .I times
120 が NULL の場合、
121 .BR utime ()
122 同様、ファイルのアクセス時刻と修正時刻は現在の時刻に設定される。
123 .SH 返り値
124 成功した場合 0 が返る。失敗した場合 \-1 が返り、
125 .I errno
126 がエラーの内容に従って設定される。
127 .SH エラー
128 .TP
129 .B EACCES
130 .I path
131 を構成する何れかのディレクトリに検索許可がない
132 .RB ( path_resolution (7)
133 も参照すること)。
134 .TP
135 .B EACCES
136 .I times
137 が NULL である。
138 または、呼び出し元の実効ユーザ ID がファイルの所有者と一致しない。
139 または、呼び出し元がそのファイルへの書き込み許可を持たず、
140 特権も持っていない (Linux の場合、ケーパビリティ
141 .B CAP_DAC_OVERRIDE
142
143 .B CAP_FOWNER
144 も持っていない)。または、
145 .TP
146 .B ENOENT
147 .I filename
148 が存在しない。
149 .TP
150 .B EPERM
151 .I times
152 が NULL でなく、かつ呼び出し元の実効 UID がファイルの所有者と一致せず、
153 かつ呼び出し元が特権を持っていない
154 (Linux の場合、ケーパビリティ
155 .B CAP_FOWNER
156 を持っていない)。
157 .TP
158 .B EROFS
159 .I path
160 が読み込み専用のファイルシステム上にある。
161 .SH 準拠
162 .BR utime ():
163 SVr4, POSIX.1-2001.
164 POSIX.1-2008 は
165 .BR utime ()
166 を廃止予定としている。
167 .br
168 .BR utimes ():
169 4.3BSD, POSIX.1-2001.
170 .SH 注意
171 Linux では、不変 (immutable) ファイルのタイムスタンプを変更したり、
172 追加専用 (append-only) のファイルに現在時刻以外のタイムスタンプを
173 設定したりすることは、許可されていない。
174
175 libc4 と libc5 では、
176 .BR utimes ()
177 は単に
178 .BR utime ()
179 のラッパー (wrapper) である。
180 そのため秒以下を指定することはできない。
181 .SH 関連項目
182 .BR chattr (1),
183 .BR futimesat (2),
184 .BR stat (2),
185 .BR utimensat (2),
186 .BR futimens (3),
187 .BR futimes (3)