.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" Modified by Michael Haardt .\" Modified 1993-07-24 by Rik Faith .\" Modified 1995-06-10 by Andries Brouwer .\" Modified 2004-06-23 by Michael Kerrisk .\" Modified 2004-10-10 by Andries Brouwer .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 SUTO, Mitsuaki .\" all rights reserved. .\" Translated Thu Jun 26 21:28:00 JST 1997 .\" by SUTO, Mitsuaki .\" Updated & Modified Tue Feb 15 03:21:17 JST 2005 .\" by Yuichi SATO .\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36 .\" Updated 2007-10-13, Akihiro MOTOKI, LDP v2.65 .\" Updated 2008-08-08, Akihiro MOTOKI, LDP v3.05 .\" .TH UTIME 2 " 2017\-09\-15" Linux "Linux Programmer's Manual" .SH 名前 utime, utimes \- ファイルの最終アクセス時刻と修正時刻を変更する .SH 書式 .nf \fB#include \fP \fB#include \fP .PP \fBint utime(const char *\fP\fIfilename\fP\fB, const struct utimbuf *\fP\fItimes\fP\fB);\fP .PP \fB#include \fP .PP \fBint utimes(const char *\fP\fIfilename\fP\fB, const struct timeval \fP\fItimes\fP\fB[2]);\fP .fi .SH 説明 \fB備考:\fP 最近のアプリケーションの場合、 \fButimensat\fP(2) で説明されているインターフェースを使いたいと思うかもしれない。 .PP \fButime\fP() システムコールは \fIfilename\fP で示される inode のアクセス時刻と修正時刻を \fItimes\fP 中の \fIactime\fP と \fImodtime\fP にそれぞれ変更する。 .PP \fItimes\fP が \fBNULL\fP の場合、ファイルのアクセス時刻と修正時刻は現在の時刻に設定される。 .PP タイムスタンプの変更は以下のいずれかの場合に許可される。 プロセスに適切な特権がある場合、 実効 (effective) ユーザー ID がファイルのユーザー ID と等しい場合、 \fItimes\fP が NULL かつ、プロセスがファイルへの書き込み許可を持っている場合。 .PP 構造体 \fIutimbuf\fP は以下に示すようになっている。 .PP .in +4n .EX struct utimbuf { time_t actime; /* アクセス時刻 */ time_t modtime; /* 修正時刻 */ }; .EE .in .PP \fButime\fP() システムコールは 1 秒の分解能でタイムスタンプを指定することができる。 .PP \fButimes\fP() は \fButime\fP() と同様であるが、 \fItimes\fP 引数が構造体ではなく配列を参照する。 この配列の要素は \fItimeval\fP 構造体で、タイムスタンプの指定を 1 マイクロ秒の分解能で行うことができる。 構造体 \fItimeval\fP は以下に示す通りである。 .PP .in +4n .EX struct timeval { long tv_sec; /* 秒 */ long tv_usec; /* マイクロ秒 */ }; .EE .in .PP \fItimes[0]\fP は新しいアクセス時刻を、 \fItimes[1]\fP は新しい修正時刻を規定する。 \fItimes\fP が NULL の場合、 \fButime\fP() 同様、ファイルのアクセス時刻と修正時刻は現在の時刻に設定される。 .SH 返り値 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。 .SH エラー .TP \fBEACCES\fP \fIpath\fP を構成する何れかのディレクトリに検索許可がない (\fBpath_resolution\fP(7) も参照すること)。 .TP \fBEACCES\fP \fItimes\fP が NULL である。 または、呼び出し元の実効ユーザー ID がファイルの所有者と一致しない。 または、呼び出し元がそのファイルへの書き込み許可を持たず、 特権も持っていない (Linux の場合、ケーパビリティ \fBCAP_DAC_OVERRIDE\fP も \fBCAP_FOWNER\fP も持っていない)。または、 .TP \fBENOENT\fP \fIfilename\fP が存在しない。 .TP \fBEPERM\fP \fItimes\fP が NULL でなく、かつ呼び出し元の実効 UID がファイルの所有者と一致せず、 かつ呼び出し元が特権を持っていない (Linux の場合、ケーパビリティ \fBCAP_FOWNER\fP を持っていない)。 .TP \fBEROFS\fP \fIpath\fP が読み込み専用のファイルシステム上にある。 .SH 準拠 \fButime\fP(): SVr4, POSIX.1\-2001. POSIX.1\-2008 は \fButime\fP() を廃止予定としている。 .PP \fButimes\fP(): 4.3BSD, POSIX.1\-2001. .SH 注意 .\" .\" In libc4 and libc5, .\" .BR utimes () .\" is just a wrapper for .\" .BR utime () .\" and hence does not allow a subsecond resolution. Linux では、不変 (immutable) ファイルのタイムスタンプを変更したり、 追加専用 (append\-only) のファイルに現在時刻以外のタイムスタンプを 設定したりすることは、許可されていない。 .SH 関連項目 \fBchattr\fP(1), \fBtouch\fP(1), \fBfutimesat\fP(2), \fBstat\fP(2), \fButimensat\fP(2), \fBfutimens\fP(3), \fBfutimes\fP(3), \fBinode\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。