-
Notifications
You must be signed in to change notification settings - Fork 0
/
renameat2.html
749 lines (537 loc) · 20.3 KB
/
renameat2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
<!-- Creator : groff version 1.22.4 -->
<!-- CreationDate: Wed Jan 29 11:25:42 2020 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="Content-Style" content="text/css">
<style type="text/css">
p { margin-top: 0; margin-bottom: 0; vertical-align: top }
pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
table { margin-top: 0; margin-bottom: 0; vertical-align: top }
h1 { text-align: center }
</style>
<title>RENAME</title>
</head>
<body>
<h1 align="center">RENAME</h1>
<a href="#NAME">NAME</a><br>
<a href="#SYNOPSIS">SYNOPSIS</a><br>
<a href="#DESCRIPTION">DESCRIPTION</a><br>
<a href="#RETURN VALUE">RETURN VALUE</a><br>
<a href="#ERRORS">ERRORS</a><br>
<a href="#VERSIONS">VERSIONS</a><br>
<a href="#CONFORMING TO">CONFORMING TO</a><br>
<a href="#NOTES">NOTES</a><br>
<a href="#BUGS">BUGS</a><br>
<a href="#SEE ALSO">SEE ALSO</a><br>
<a href="#COLOPHON">COLOPHON</a><br>
<hr>
<h2>NAME
<a name="NAME"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">rename,
renameat, renameat2 - change the name or location of a
file</p>
<h2>SYNOPSIS
<a name="SYNOPSIS"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>#include
<stdio.h></b></p>
<p style="margin-left:11%; margin-top: 1em"><b>int
rename(const char *</b><i>oldpath</i><b>, const char
*</b><i>newpath</i><b>);</b></p>
<p style="margin-left:11%; margin-top: 1em"><b>#include
<fcntl.h></b> /* Definition of AT_* constants */
<b><br>
#include <stdio.h></b></p>
<p style="margin-left:11%; margin-top: 1em"><b>int
renameat(int</b> <i>olddirfd</i><b>, const char
*</b><i>oldpath</i><b>, <br>
int</b> <i>newdirfd</i><b>, const char
*</b><i>newpath</i><b>);</b></p>
<p style="margin-left:11%; margin-top: 1em"><b>int
renameat2(int</b> <i>olddirfd</i><b>, const char
*</b><i>oldpath</i><b>, <br>
int</b> <i>newdirfd</i><b>, const char
*</b><i>newpath</i><b>, unsigned int</b>
<i>flags</i><b>);</b></p>
<p style="margin-left:5%; margin-top: 1em">Feature Test
Macro Requirements for glibc (see
<b>feature_test_macros</b>(7)):</p>
<p style="margin-left:11%; margin-top: 1em"><b>renameat</b>():</p>
<p style="margin-left:17%;">Since glibc 2.10:</p>
<p style="margin-left:23%;">_POSIX_C_SOURCE >= 200809L</p>
<p style="margin-left:17%;">Before glibc 2.10:</p>
<p style="margin-left:23%;">_ATFILE_SOURCE</p>
<p style="margin-left:11%;"><b>renameat2</b>():</p>
<p style="margin-left:17%;">_GNU_SOURCE</p>
<h2>DESCRIPTION
<a name="DESCRIPTION"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>rename</b>()
renames a file, moving it between directories if required.
Any other hard links to the file (as created using
<b>link</b>(2)) are unaffected. Open file descriptors for
<i>oldpath</i> are also unaffected.</p>
<p style="margin-left:11%; margin-top: 1em">Various
restrictions determine whether or not the rename operation
succeeds: see ERRORS below.</p>
<p style="margin-left:11%; margin-top: 1em">If
<i>newpath</i> already exists, it will be atomically
replaced, so that there is no point at which another process
attempting to access <i>newpath</i> will find it missing.
However, there will probably be a window in which both
<i>oldpath</i> and <i>newpath</i> refer to the file being
renamed.</p>
<p style="margin-left:11%; margin-top: 1em">If
<i>oldpath</i> and <i>newpath</i> are existing hard links
referring to the same file, then <b>rename</b>() does
nothing, and returns a success status.</p>
<p style="margin-left:11%; margin-top: 1em">If
<i>newpath</i> exists but the operation fails for some
reason, <b>rename</b>() guarantees to leave an instance of
<i>newpath</i> in place.</p>
<p style="margin-left:11%; margin-top: 1em"><i>oldpath</i>
can specify a directory. In this case, <i>newpath</i> must
either not exist, or it must specify an empty directory.</p>
<p style="margin-left:11%; margin-top: 1em">If
<i>oldpath</i> refers to a symbolic link, the link is
renamed; if <i>newpath</i> refers to a symbolic link, the
link will be overwritten.</p>
<p style="margin-left:11%; margin-top: 1em"><b>renameat()</b>
<br>
The <b>renameat</b>() system call operates in exactly the
same way as <b>rename</b>(), except for the differences
described here.</p>
<p style="margin-left:11%; margin-top: 1em">If the pathname
given in <i>oldpath</i> is relative, then it is interpreted
relative to the directory referred to by the file descriptor
<i>olddirfd</i> (rather than relative to the current working
directory of the calling process, as is done by
<b>rename</b>() for a relative pathname).</p>
<p style="margin-left:11%; margin-top: 1em">If
<i>oldpath</i> is relative and <i>olddirfd</i> is the
special value <b>AT_FDCWD</b>, then <i>oldpath</i> is
interpreted relative to the current working directory of the
calling process (like <b>rename</b>()).</p>
<p style="margin-left:11%; margin-top: 1em">If
<i>oldpath</i> is absolute, then <i>olddirfd</i> is
ignored.</p>
<p style="margin-left:11%; margin-top: 1em">The
interpretation of <i>newpath</i> is as for <i>oldpath</i>,
except that a relative pathname is interpreted relative to
the directory referred to by the file descriptor
<i>newdirfd</i>.</p>
<p style="margin-left:11%; margin-top: 1em">See
<b>openat</b>(2) for an explanation of the need for
<b>renameat</b>().</p>
<p style="margin-left:11%; margin-top: 1em"><b>renameat2()
<br>
renameat2</b>() has an additional <i>flags</i> argument. A
<b>renameat2</b>() call with a zero <i>flags</i> argument is
equivalent to <b>renameat</b>().</p>
<p style="margin-left:11%; margin-top: 1em">The
<i>flags</i> argument is a bit mask consisting of zero or
more of the following flags: <b><br>
RENAME_EXCHANGE</b></p>
<p style="margin-left:22%;">Atomically exchange
<i>oldpath</i> and <i>newpath</i>. Both pathnames must exist
but may be of different types (e.g., one could be a
non-empty directory and the other a symbolic link).</p>
<p style="margin-left:11%;"><b>RENAME_NOREPLACE</b></p>
<p style="margin-left:22%;">Don’t overwrite
<i>newpath</i> of the rename. Return an error if
<i>newpath</i> already exists.</p>
<p style="margin-left:22%; margin-top: 1em"><b>RENAME_NOREPLACE</b>
can’t be employed together with
<b>RENAME_EXCHANGE</b>.</p>
<p style="margin-left:22%; margin-top: 1em"><b>RENAME_NOREPLACE</b>
requires support from the underlying filesystem. Support for
various filesystems was added as follows:</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="22%"></td>
<td width="1%">
<p>*</p></td>
<td width="3%"></td>
<td width="74%">
<p>ext4 (Linux 3.15);</p></td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="1%">
<p>*</p></td>
<td width="3%"></td>
<td width="74%">
<p>btrfs, shmem, and cifs (Linux 3.17);</p></td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="1%">
<p>*</p></td>
<td width="3%"></td>
<td width="74%">
<p>xfs (Linux 4.0);</p></td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="1%">
<p>*</p></td>
<td width="3%"></td>
<td width="74%">
<p>Support for many other filesystems was added in Linux
4.9, including etx2, minix, reiserfs, jfs, vfat, and
bpf.</p> </td></tr>
</table>
<p style="margin-left:11%;"><b>RENAME_WHITEOUT</b> (since
Linux 3.18)</p>
<p style="margin-left:22%;">This operation makes sense only
for overlay/union filesystem implementations.</p>
<p style="margin-left:22%; margin-top: 1em">Specifying
<b>RENAME_WHITEOUT</b> creates a "whiteout" object
at the source of the rename at the same time as performing
the rename. The whole operation is atomic, so that if the
rename succeeds then the whiteout will also have been
created.</p>
<p style="margin-left:22%; margin-top: 1em">A
"whiteout" is an object that has special meaning
in union/overlay filesystem constructs. In these constructs,
multiple layers exist and only the top one is ever modified.
A whiteout on an upper layer will effectively hide a
matching file in the lower layer, making it appear as if the
file didn’t exist.</p>
<p style="margin-left:22%; margin-top: 1em">When a file
that exists on the lower layer is renamed, the file is first
copied up (if not already on the upper layer) and then
renamed on the upper, read-write layer. At the same time,
the source file needs to be "whiteouted" (so that
the version of the source file in the lower layer is
rendered invisible). The whole operation needs to be done
atomically.</p>
<p style="margin-left:22%; margin-top: 1em">When not part
of a union/overlay, the whiteout appears as a character
device with a {0,0} device number. (Note that other
union/overlay implementations may employ different methods
for storing whiteout entries; specifically, BSD union mount
employs a separate inode type, <b>DT_WHT</b>, which, while
supported by some filesystems available in Linux, such as
CODA and XFS, is ignored by the kernel’s whiteout
support code, as of Linux 4.19, at least.)</p>
<p style="margin-left:22%; margin-top: 1em"><b>RENAME_WHITEOUT</b>
requires the same privileges as creating a device node
(i.e., the <b>CAP_MKNOD</b> capability).</p>
<p style="margin-left:22%; margin-top: 1em"><b>RENAME_WHITEOUT</b>
can’t be employed together with
<b>RENAME_EXCHANGE</b>.</p>
<p style="margin-left:22%; margin-top: 1em"><b>RENAME_WHITEOUT</b>
requires support from the underlying filesystem. Among the
filesystems that provide that support are tmpfs (since Linux
3.18), ext4 (since Linux 3.18), XFS (since Linux 4.1), f2fs
(since Linux 4.2). btrfs (since Linux 4.7), and ubifs (since
Linux 4.9).</p>
<h2>RETURN VALUE
<a name="RETURN VALUE"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">On success,
zero is returned. On error, -1 is returned, and <i>errno</i>
is set appropriately.</p>
<h2>ERRORS
<a name="ERRORS"></a>
</h2>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p style="margin-top: 1em"><b>EACCES</b></p></td>
<td width="2%"></td>
<td width="78%">
<p style="margin-top: 1em">Write permission is denied for
the directory containing <i>oldpath</i> or <i>newpath</i>,
or, search permission is denied for one of the directories
in the path prefix of <i>oldpath</i> or <i>newpath</i>, or
<i>oldpath</i> is a directory and does not allow write
permission (needed to update the <i>..</i> entry). (See also
<b>path_resolution</b>(7).)</p> </td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EBUSY</b></p></td>
<td width="2%"></td>
<td width="78%">
<p>The rename fails because <i>oldpath</i> or
<i>newpath</i> is a directory that is in use by some process
(perhaps as current working directory, or as root directory,
or because it was open for reading) or is in use by the
system (for example as mount point), while the system
considers this an error. (Note that there is no requirement
to return <b>EBUSY</b> in such cases—there is nothing
wrong with doing the rename anyway—but it is allowed
to return <b>EBUSY</b> if the system cannot otherwise handle
such situations.)</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EDQUOT</b></p></td>
<td width="2%"></td>
<td width="78%">
<p>The user’s quota of disk blocks on the filesystem
has been exhausted.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EFAULT</b></p></td>
<td width="2%"></td>
<td width="78%">
<p><i>oldpath</i> or <i>newpath</i> points outside your
accessible address space.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EINVAL</b></p></td>
<td width="2%"></td>
<td width="78%">
<p>The new pathname contained a path prefix of the old, or,
more generally, an attempt was made to make a directory a
subdirectory of itself.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EISDIR</b></p></td>
<td width="2%"></td>
<td width="78%">
<p><i>newpath</i> is an existing directory, but
<i>oldpath</i> is not a directory.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>ELOOP</b></p></td>
<td width="2%"></td>
<td width="78%">
<p>Too many symbolic links were encountered in resolving
<i>oldpath</i> or <i>newpath</i>.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EMLINK</b></p></td>
<td width="2%"></td>
<td width="78%">
<p><i>oldpath</i> already has the maximum number of links
to it, or it was a directory and the directory containing
<i>newpath</i> has the maximum number of links.</p></td></tr>
</table>
<p style="margin-left:11%;"><b>ENAMETOOLONG</b></p>
<p style="margin-left:22%;"><i>oldpath</i> or
<i>newpath</i> was too long.</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>ENOENT</b></p></td>
<td width="2%"></td>
<td width="78%">
<p>The link named by <i>oldpath</i> does not exist; or, a
directory component in <i>newpath</i> does not exist; or,
<i>oldpath</i> or <i>newpath</i> is an empty string.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>ENOMEM</b></p></td>
<td width="2%"></td>
<td width="78%">
<p>Insufficient kernel memory was available.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>ENOSPC</b></p></td>
<td width="2%"></td>
<td width="78%">
<p>The device containing the file has no room for the new
directory entry.</p></td></tr>
</table>
<p style="margin-left:11%;"><b>ENOTDIR</b></p>
<p style="margin-left:22%;">A component used as a directory
in <i>oldpath</i> or <i>newpath</i> is not, in fact, a
directory. Or, <i>oldpath</i> is a directory, and
<i>newpath</i> exists but is not a directory.</p>
<p style="margin-left:11%;"><b>ENOTEMPTY</b> or
<b>EEXIST</b></p>
<p style="margin-left:22%;"><i>newpath</i> is a nonempty
directory, that is, contains entries other than
"." and "..".</p>
<p style="margin-left:11%;"><b>EPERM</b> or
<b>EACCES</b></p>
<p style="margin-left:22%;">The directory containing
<i>oldpath</i> has the sticky bit (<b>S_ISVTX</b>) set and
the process’s effective user ID is neither the user ID
of the file to be deleted nor that of the directory
containing it, and the process is not privileged (Linux:
does not have the <b>CAP_FOWNER</b> capability); or
<i>newpath</i> is an existing file and the directory
containing it has the sticky bit set and the process’s
effective user ID is neither the user ID of the file to be
replaced nor that of the directory containing it, and the
process is not privileged (Linux: does not have the
<b>CAP_FOWNER</b> capability); or the filesystem containing
<i>pathname</i> does not support renaming of the type
requested.</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="7%">
<p><b>EROFS</b></p></td>
<td width="4%"></td>
<td width="78%">
<p>The file is on a read-only filesystem.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="7%">
<p><b>EXDEV</b></p></td>
<td width="4%"></td>
<td width="78%">
<p><i>oldpath</i> and <i>newpath</i> are not on the same
mounted filesystem. (Linux permits a filesystem to be
mounted at multiple points, but <b>rename</b>() does not
work across different mount points, even if the same
filesystem is mounted on both.)</p></td></tr>
</table>
<p style="margin-left:11%; margin-top: 1em">The following
additional errors can occur for <b>renameat</b>() and
<b>renameat2</b>():</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="7%">
<p style="margin-top: 1em"><b>EBADF</b></p></td>
<td width="4%"></td>
<td width="78%">
<p style="margin-top: 1em"><i>olddirfd</i> or
<i>newdirfd</i> is not a valid file descriptor.</p></td></tr>
</table>
<p style="margin-left:11%;"><b>ENOTDIR</b></p>
<p style="margin-left:22%;"><i>oldpath</i> is relative and
<i>olddirfd</i> is a file descriptor referring to a file
other than a directory; or similar for <i>newpath</i> and
<i>newdirfd</i></p>
<p style="margin-left:11%; margin-top: 1em">The following
additional errors can occur for <b>renameat2</b>():</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EEXIST</b></p></td>
<td width="2%"></td>
<td width="78%">
<p><i>flags</i> contains <b>RENAME_NOREPLACE</b> and
<i>newpath</i> already exists.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EINVAL</b></p></td>
<td width="2%"></td>
<td width="78%">
<p>An invalid flag was specified in <i>flags</i>.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EINVAL</b></p></td>
<td width="2%"></td>
<td width="78%">
<p>Both <b>RENAME_NOREPLACE</b> and <b>RENAME_EXCHANGE</b>
were specified in <i>flags</i>.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EINVAL</b></p></td>
<td width="2%"></td>
<td width="78%">
<p>Both <b>RENAME_WHITEOUT</b> and <b>RENAME_EXCHANGE</b>
were specified in <i>flags</i>.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EINVAL</b></p></td>
<td width="2%"></td>
<td width="78%">
<p>The filesystem does not support one of the flags in
<i>flags</i>.</p> </td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>ENOENT</b></p></td>
<td width="2%"></td>
<td width="78%">
<p><i>flags</i> contains <b>RENAME_EXCHANGE</b> and
<i>newpath</i> does not exist.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="9%">
<p><b>EPERM</b></p></td>
<td width="2%"></td>
<td width="78%">
<p><b>RENAME_WHITEOUT</b> was specified in <i>flags</i>,
but the caller does not have the <b>CAP_MKNOD</b>
capability.</p> </td></tr>
</table>
<h2>VERSIONS
<a name="VERSIONS"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>renameat</b>()
was added to Linux in kernel 2.6.16; library support was
added to glibc in version 2.4.</p>
<p style="margin-left:11%; margin-top: 1em"><b>renameat2</b>()
was added to Linux in kernel 3.15; library support was added
in glibc 2.28.</p>
<h2>CONFORMING TO
<a name="CONFORMING TO"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>rename</b>():
4.3BSD, C89, C99, POSIX.1-2001, POSIX.1-2008.</p>
<p style="margin-left:11%; margin-top: 1em"><b>renameat</b>():
POSIX.1-2008.</p>
<p style="margin-left:11%; margin-top: 1em"><b>renameat2</b>()
is Linux-specific.</p>
<h2>NOTES
<a name="NOTES"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>Glibc
notes</b> <br>
On older kernels where <b>renameat</b>() is unavailable, the
glibc wrapper function falls back to the use of
<b>rename</b>(). When <i>oldpath</i> and <i>newpath</i> are
relative pathnames, glibc constructs pathnames based on the
symbolic links in <i>/proc/self/fd</i> that correspond to
the <i>olddirfd</i> and <i>newdirfd</i> arguments.</p>
<h2>BUGS
<a name="BUGS"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">On NFS
filesystems, you can not assume that if the operation
failed, the file was not renamed. If the server does the
rename operation and then crashes, the retransmitted RPC
which will be processed when the server is up again causes a
failure. The application is expected to deal with this. See
<b>link</b>(2) for a similar problem.</p>
<h2>SEE ALSO
<a name="SEE ALSO"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>mv</b>(1),
<b>chmod</b>(2), <b>link</b>(2), <b>symlink</b>(2),
<b>unlink</b>(2), <b>path_resolution</b>(7),
<b>symlink</b>(7)</p>
<h2>COLOPHON
<a name="COLOPHON"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">This page is
part of release 5.02 of the Linux <i>man-pages</i> project.
A description of the project, information about reporting
bugs, and the latest version of this page, can be found at
https://www.kernel.org/doc/man-pages/.</p>
<hr>
</body>
</html>