1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
4 .\" 1993 Michael Haardt;
5 .\" 1993,1995 Ian Jackson.
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date. The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein. The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" Modified Sat Jul 24 00:35:52 1993 by Rik Faith <faith@cs.unc.edu>
28 .\" Modified Thu Jun 4 12:21:13 1998 by Andries Brouwer <aeb@cwi.nl>
29 .\" Modified Thu Mar 3 09:49:35 2005 by Michael Haardt <michael@moria.de>
30 .\" 2007-03-25, mtk, added various text to DESCRIPTION.
32 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
33 .\" all rights reserved.
34 .\" Translated Fri Dec 12 00:15:52 JST 1997
35 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
36 .\" Updated & Modified Thu Feb 10 07:23:59 JST 2005
37 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
38 .\" Updated & Modified Fri Apr 22 03:21:04 JST 2005 by Yuichi SATO
39 .\" Updated 2007-05-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.44
40 .\" Updated 2009-04-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.20
42 .\"WORD: directory ディレクトリ
43 .\"WORD: hard link ハード・リンク
44 .\"WORD: overwrite 上書き(overwrite)
47 .\"WORD: symbolic link シンボリック・リンク
48 .\"WORD: working directory ワーキング・ディレクトリ
49 .\"WORD: root directory ルート・ディレクトリ
50 .\"WORD: effective uid 実効ユーザーID
51 .\"WORD: sticky bit スティッキー・ビット
53 .\"WORD: read-only 読み込み専用
55 .\"WORD: dangling symbolic link 壊れたシンボリック・リンク
58 .TH RENAME 2 2009-03-30 "Linux" "Linux Programmer's Manual"
61 .\"O rename \- change the name or location of a file
62 rename \- ファイルの名前や位置を変更する
67 .BI "int rename(const char *" oldpath ", const char *" newpath );
71 .\"O renames a file, moving it between directories if required.
73 はファイルの名前を変更し、必要ならばディレクトリ間の移動を行なう。
74 .\"O Any other hard links to the file (as created using
79 を使用して作られた) 他のハードリンク (hard link) には影響はない。
80 .\"O Open file descriptors for
82 .\"O are also unaffected.
85 に対するファイルディスクリプタにも影響はない。
89 .\"O already exists it will be atomically replaced (subject to
90 .\"O a few conditions; see ERRORS below), so that there is
91 .\"O no point at which another process attempting to access
93 .\"O will find it missing.
95 が既に存在する場合、それは不可分操作で (atomically) 置き換えられる
96 (ただし、いくつかの条件がある; 以下の「エラー」のセクションを参照)。
99 にアクセスしようとしている他のプロセスがファイルを見失うことはない
106 .\"O are existing hard links referring to the same file, then
108 .\"O does nothing, and returns a success status.
112 がどちらも既存のハードリンクで、同じファイルを参照している場合、
114 は何も行わず、ステータスとして成功を返す。
118 .\"O exists but the operation fails for some reason
120 .\"O guarantees to leave an instance of
124 が存在し、何らかの理由で操作が失敗した場合、
131 .\"O can specify a directory.
134 .\"O must either not exist, or it must specify an empty directory.
139 は存在しないか、空のディレクトリでなければならない。
141 .\"O However, when overwriting there will probably be a window in which
146 .\"O refer to the file being renamed.
147 一方で、上書きを行なう場合は、rename が行なわれるファイルを
151 の両方で参照できる瞬間がおそらく存在する。
155 .\"O refers to a symbolic link the link is renamed; if
157 .\"O refers to a symbolic link the link will be overwritten.
159 がシンボリック・リンク (symbolic link) を参照している場合は、
163 がシンボリック・リンクを参照している場合は、リンクが上書きされる。
164 .\"O .SH "RETURN VALUE"
166 .\"O On success, zero is returned.
167 .\"O On error, \-1 is returned, and
169 .\"O is set appropriately.
170 成功した場合は 0 を返す。エラーの場合は \-1 を返し、
177 .\"O Write permission is denied for the directory containing
181 .\"O or, search permission is denied for one of the directories
182 .\"O in the path prefix of
188 .\"O is a directory and does not allow write permission (needed to update
193 .\"O .BR path_resolution (7).)
194 .IR oldpath " または " newpath
195 を含んでいるディレクトリの書き込み許可がない。
197 .IR oldpath " または " newpath
198 のディレクトリ部分のどれかに検索許可がない。
203 エントリを更新するのに必要な) 書き込み許可がない
204 .RB ( path_resolution (7)
208 .\"O The rename fails because
209 .\"O .IR oldpath " or " newpath
210 .\"O is a directory that is in use by some process (perhaps as
211 .\"O current working directory, or as root directory, or because
212 .\"O it was open for reading) or is in use by the system
213 .\"O (for example as mount point), while the system considers
215 .IR oldpath " または " newpath
216 がディレクトリで、何らかのプロセスが使用中
217 (多分、カレント・ワーキング・ディレクトリか、ルートディレクトリか、
218 読み込みのためにオープンされているかでろう)
219 もしくは、システムが使用中 (例えばマウント・ポイントである)
220 であり、システムがこれをエラーであると判断したために rename が失敗した。
221 .\"O (Note that there is no requirement to return
224 .\"O cases\(emthere is nothing wrong with doing the rename anyway\(embut
225 .\"O it is allowed to return
227 .\"O if the system cannot otherwise
228 .\"O handle such situations.)
231 を返すことは規格では要求されていない点に注意すること。
232 このような場合に、rename をとにかく実行してみるのは何の問題もない。
233 ただし、そのような状況で、システムが他に返すエラーがない場合には
238 .\"O .IR oldpath " or " newpath " points outside your accessible address space."
239 .IR oldpath " または " newpath
240 がアクセス可能なアドレス空間の外を指している。
243 .\"O The new pathname contained a path prefix of the old, or, more generally,
244 .\"O an attempt was made to make a directory a subdirectory of itself.
245 .IR newpath " が " oldpath
246 のパス部分を含んでいる。ディレクトリを自分自身のサブディレクトリに
251 .\"O is an existing directory, but
253 .\"O is not a directory.
260 .\"O Too many symbolic links were encountered in resolving
261 .\"O .IR oldpath " or " newpath .
262 .IR oldpath " または " newpath
263 を解決する際に遭遇したシンボリック・リンクが多過ぎる。
267 .\"O already has the maximum number of links to it, or
268 .\"O it was a directory and the directory containing
270 .\"O has the maximum number of links.
272 は既に最大数までのリンクを持っているか、それがディレクトリで
274 を含んでいるディレクトリが最大数までのリンクを持っている。
277 .\"O .IR oldpath " or " newpath " was too long."
278 .IR oldpath " または " newpath " が長過ぎる。"
281 .\"O The link named by
284 .\"O or, a directory component in
291 .\"O is an empty string.
304 .\"O Insufficient kernel memory was available.
308 .\"O The device containing the file has no room for the new directory
310 ファイルを含んでいるデバイスに新しいディレクトリ・エントリを
314 .\"O A component used as a directory in
315 .\"O .IR oldpath " or " newpath
316 .\"O is not, in fact, a directory.
317 .IR oldpath " か " newpath
322 .\"O is a directory, and
324 .\"O exists but is not a directory.
331 .\"O .BR ENOTEMPTY " or " EEXIST
332 .B ENOTEMPTY " または " EEXIST
334 .\"O is a nonempty directory, that is, contains entries other than "." and "..".
336 が空でないディレクトリである。すなわち "." と ".." 以外を含んでいる。
338 .\"O .BR EPERM " or " EACCES
339 .BR EPERM " または " EACCES
340 .\"O The directory containing
342 .\"O has the sticky bit
344 .\"O set and the process's effective user ID is neither
345 .\"O the user ID of the file to be deleted nor that of the directory
346 .\"O containing it, and the process is not privileged
347 .\"O (Linux: does not have the
351 のあるディレクトリにスティッキー・ビット (sticky bit)
355 削除しようとするファイルのユーザー ID と
356 そのファイルを含むディレクトリのユーザー ID のいずれとも一致せず、かつ
359 ケーパビリティ (capability) がない)。
362 .\"O is an existing file and the directory containing it has the sticky bit set
363 .\"O and the process's effective user ID is neither the user ID of the file
364 .\"O to be replaced nor that of the directory containing it,
365 .\"O and the process is not privileged
366 .\"O (Linux: does not have the
371 がすでに存在するファイルで、親ディレクトリにスティッキービットが設定されており、
373 置き換えようとするファイルのユーザー ID と
374 そのファイルを含むディレクトリのユーザー ID のいずれとも一致せず、かつ
378 .\"O or the file system containing
380 .\"O does not support renaming of the type requested.
382 .IR oldpath " と " newpath
383 が存在するファイル・システムが、要求された種類の名前の変更を
387 .\"O The file is on a read-only file system.
388 ファイルが読み込み専用 (read-only) ファイル・システムにある。
391 .\"O .IR oldpath " and " newpath
392 .\"O are not on the same mounted file system.
393 .IR oldpath " と " newpath
394 が同じマウントされたファイル・システムに存在しない。
395 .\"O (Linux permits a file system to be mounted at multiple points, but
397 .\"O does not work across different mount points,
398 .\"O even if the same file system is mounted on both.)
399 (Linux は 1 つのファイル・システムを複数のマウント位置に
403 は、たとえ同じファイル・システムであっても、
404 別々のマウント位置を跨いでは動作しない。)
405 .\"O .SH "CONFORMING TO"
407 4.3BSD, C89, C99, POSIX.1-2001.
410 .\"O On NFS file systems, you can not assume that if the operation
411 .\"O failed the file was not renamed.
412 .\"O If the server does the rename operation
413 .\"O and then crashes, the retransmitted RPC which will be processed when the
414 .\"O server is up again causes a failure.
415 .\"O The application is expected to
419 .\"O for a similar problem.
420 NFS ファイル・システムでは、操作が失敗したからといって、
421 ファイルの名前が変更できなかったと決めてかかることはできない。
422 サーバが rename 操作を終えてからクラッシュした場合、
424 再送信された RPC が処理されるが、これは失敗となる。
425 アプリケーションはこの問題を正しく取り扱うことが期待されている。
437 .BR path_resolution (7),