Skip to content

Commit b1ec886

Browse files
committed
Auto merge of #806 - Mic92:renameat2, r=alexcrichton
define SYS_renameat2 + flags on linux Motivation: there is no glibc wrapper for this syscall
2 parents b09d655 + 8c24117 commit b1ec886

File tree

9 files changed

+28
-1
lines changed

9 files changed

+28
-1
lines changed

libc-test/build.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ fn main() {
226226
cfg.header("sys/reboot.h");
227227
if !emscripten {
228228
cfg.header("linux/netfilter_ipv4.h");
229+
cfg.header("linux/fs.h");
229230
}
230231
if !musl {
231232
cfg.header("asm/mman.h");
@@ -464,7 +465,8 @@ fn main() {
464465

465466
// Musl uses old, patched kernel headers
466467
"FALLOC_FL_COLLAPSE_RANGE" | "FALLOC_FL_ZERO_RANGE" |
467-
"FALLOC_FL_INSERT_RANGE" | "FALLOC_FL_UNSHARE_RANGE" if musl => true,
468+
"FALLOC_FL_INSERT_RANGE" | "FALLOC_FL_UNSHARE_RANGE" |
469+
"RENAME_NOREPLACE" | "RENAME_EXCHANGE" | "RENAME_WHITEOUT" if musl => true,
468470

469471
// Defined by libattr not libc on linux (hard to test).
470472
// See constant definition for more details.

src/unix/notbsd/linux/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,10 @@ pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0;
673673
pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
674674
pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
675675

676+
pub const RENAME_NOREPLACE: ::c_int = 1;
677+
pub const RENAME_EXCHANGE: ::c_int = 2;
678+
pub const RENAME_WHITEOUT: ::c_int = 4;
679+
676680
pub const SCHED_OTHER: ::c_int = 0;
677681
pub const SCHED_FIFO: ::c_int = 1;
678682
pub const SCHED_RR: ::c_int = 2;

src/unix/notbsd/linux/musl/b32/arm.rs

+3
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,6 @@ pub const TIOCM_RNG: ::c_int = 0x080;
390390
pub const TIOCM_DSR: ::c_int = 0x100;
391391
pub const TIOCM_CD: ::c_int = TIOCM_CAR;
392392
pub const TIOCM_RI: ::c_int = TIOCM_RNG;
393+
394+
// Syscall table
395+
pub const SYS_renameat2: ::c_long = 382;

src/unix/notbsd/linux/musl/b64/aarch64.rs

+3
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,6 @@ pub const SIGSTKSZ: ::size_t = 12288;
7979
pub const PF_MAX: ::c_int = 43;
8080
#[doc(hidden)]
8181
pub const AF_MAX: ::c_int = PF_MAX;
82+
83+
// Syscall table
84+
pub const SYS_renameat2: ::c_long = 276;

src/unix/notbsd/linux/musl/b64/powerpc64.rs

+3
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ pub const MINSIGSTKSZ: ::size_t = 2048;
7878
pub const AF_MAX: ::c_int = 42;
7979
#[doc(hidden)]
8080
pub const PF_MAX: ::c_int = AF_MAX;
81+
82+
// Syscall table
83+
pub const SYS_renameat2: ::c_long = 357;

src/unix/notbsd/linux/other/b32/arm.rs

+3
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,6 @@ pub const TIOCOUTQ: ::c_ulong = 0x5411;
249249
pub const TIOCGWINSZ: ::c_ulong = 0x5413;
250250
pub const TIOCSWINSZ: ::c_ulong = 0x5414;
251251
pub const FIONREAD: ::c_ulong = 0x541B;
252+
253+
// Syscall table
254+
pub const SYS_renameat2: ::c_long = 382;

src/unix/notbsd/linux/other/b64/aarch64.rs

+3
Original file line numberDiff line numberDiff line change
@@ -488,3 +488,6 @@ pub const TIOCOUTQ: ::c_ulong = 0x5411;
488488
pub const TIOCGWINSZ: ::c_ulong = 0x5413;
489489
pub const TIOCSWINSZ: ::c_ulong = 0x5414;
490490
pub const FIONREAD: ::c_ulong = 0x541B;
491+
492+
// Syscall table
493+
pub const SYS_renameat2: ::c_long = 276;

src/unix/notbsd/linux/other/b64/powerpc64.rs

+3
Original file line numberDiff line numberDiff line change
@@ -485,3 +485,6 @@ pub const TIOCOUTQ: ::c_ulong = 0x40047473;
485485
pub const TIOCGWINSZ: ::c_ulong = 0x40087468;
486486
pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
487487
pub const FIONREAD: ::c_ulong = 0x4004667f;
488+
489+
// Syscall table
490+
pub const SYS_renameat2: ::c_long = 357;

src/unix/notbsd/linux/s390x.rs

+3
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,9 @@ pub const TIOCMSET: ::c_ulong = 0x5418;
779779
pub const FIONREAD: ::c_ulong = 0x541B;
780780
pub const TIOCCONS: ::c_ulong = 0x541D;
781781

782+
// Syscall table
783+
pub const SYS_renameat2: ::c_long = 347;
784+
782785
pub const RTLD_DEEPBIND: ::c_int = 0x8;
783786
pub const RTLD_GLOBAL: ::c_int = 0x100;
784787
pub const RTLD_NOLOAD: ::c_int = 0x4;

0 commit comments

Comments
 (0)