Bug 9946

Summary: mv is corrupting files on aufs filesystem (e.g. used by open-source docker V17.03)
Product: Busybox Reporter: Steffen <steffen.guertler>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.22.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: strace-output.txt

Description Steffen 2017-06-09 15:54:59 UTC
if mv several subdirectories to another directory mv is not copying the correct content but several files have content of other files.

Debugging this behavior with strace, I could see that the rename() call failed with EXDEV and the underlying aufs filesystem changing (and reusing) inode numbers during the whole process. This conflicts with the inode_hash table.

In the trace output below, "target/d2/c" will have the content of "target/d1/image4.bmp" and "target/d2/d" the content of "target/d1/image3.bmp" instead of there original content:

~ $ find -not -name ".*" -exec ls -lid {} \;
     48 drwxr-sr-x    2 root     root          4096 Jun  9 15:35 ./target
     49 drwxr-xr-x    4 2226832  1049089       4096 Jun  9 15:29 ./example
     43 drwxr-xr-x    2 2226832  1049089       4096 Jun  9 15:30 ./example/d1
     63 -rw-r--r--    1 2226832  1049089    2764938 Jun  9 15:29 ./example/d1/image4.bmp
     64 -rw-r--r--    1 2226832  1049089    2764938 Jun  9 15:29 ./example/d1/image3.bmp
     65 -rw-r--r--    1 2226832  1049089    2764938 Jun  9 15:29 ./example/d1/image1.bmp
     66 -rw-r--r--    1 2226832  1049089          1 Jun  9 15:11 ./example/d1/a
     67 -rw-r--r--    1 2226832  1049089    2764938 Jun  9 15:30 ./example/d1/image7.bmp
     68 -rw-r--r--    1 2226832  1049089          1 Jun  9 15:11 ./example/d1/b
     69 -rw-r--r--    1 2226832  1049089    2764938 Jun  9 15:30 ./example/d1/image9.bmp
     70 -rw-r--r--    1 2226832  1049089    2764938 Jun  9 15:30 ./example/d1/image0.bmp
     71 -rw-r--r--    1 2226832  1049089    2764938 Jun  9 15:30 ./example/d1/image8.bmp
     72 -rw-r--r--    1 2226832  1049089    2764938 Jun  9 15:29 ./example/d1/image5.bmp
     73 -rw-r--r--    1 2226832  1049089    2764938 Jun  9 15:29 ./example/d1/image2.bmp
     74 -rw-r--r--    1 2226832  1049089    2764938 Jun  9 15:29 ./example/d1/image6.bmp
     44 drwxr-xr-x    2 2226832  1049089       4096 Jun  9 15:11 ./example/d2
     63 -rw-r--r--    1 2226832  1049089          1 Jun  9 15:11 ./example/d2/c
     64 -rw-r--r--    1 2226832  1049089          1 Jun  9 15:11 ./example/d2/d
~ # sudo strace -v mv example/* target/
execve("/bin/mv", ["mv", "example/d1", "example/d2", "target/"], ["HOSTNAME=05c4de545fa3", "TERM=xterm", "PATH=/usr/local/sbin:/usr/l
sh", "LOGNAME=root", "USER=root", "USERNAME=root", "MAIL=/var/mail/root", "HOME=/root", "SUDO_COMMAND=/usr/local/bin/stra"..., "SUDO_
1", "SUDO_GID=50"]) = 0
brk(0)                                  = 0x14c9000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0668a2a000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_dev=makedev(0, 33), st_ino=29, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_si
06/09-15:35:01, st_mtime=2017/06/09-15:35:01, st_ctime=2017/06/09-15:35:01}) = 0
mmap(NULL, 2299, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f0668a29000
close(3)                                = 0
open("/lib/libcrypt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\v\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_dev=makedev(0, 33), st_ino=31, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=64, st_s
7/06/07-19:32:07, st_mtime=2016/07/08-10:55:03, st_ctime=2017/06/07-19:16:21}) = 0
mmap(NULL, 2314752, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f06685d9000
mprotect(0x7f06685e0000, 2093056, PROT_NONE) = 0
mmap(0x7f06687df000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7f06687df000
mmap(0x7f06687e1000, 184832, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f06687e1000
close(3)                                = 0
open("/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240T\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_dev=makedev(0, 33), st_ino=33, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=1920, st
2017/06/07-19:32:07, st_mtime=2016/07/08-10:55:03, st_ctime=2017/06/07-19:16:21}) = 0
mmap(NULL, 3076400, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f06682e9000
mprotect(0x7f06683d8000, 2093056, PROT_NONE) = 0
mmap(0x7f06685d7000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xee000) = 0x7f06685d7000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\16\21\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_dev=makedev(0, 33), st_ino=35, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=2904, st
=2017/06/09-12:42:08, st_mtime=2016/07/08-10:55:03, st_ctime=2017/06/07-19:16:21}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0668a28000
mmap(NULL, 3592160, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f0667f7c000
mprotect(0x7f06680df000, 2097152, PROT_NONE) = 0
mmap(0x7f06682df000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x163000) = 0x7f06682df000
mmap(0x7f06682e5000, 16352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f06682e5000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0668a27000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0668a26000
arch_prctl(ARCH_SET_FS, 0x7f0668a27700) = 0
mprotect(0x7f06682df000, 16384, PROT_READ) = 0
mprotect(0x7f06685d7000, 4096, PROT_READ) = 0
mprotect(0x7f06687df000, 4096, PROT_READ) = 0
mprotect(0x7f0668a2b000, 4096, PROT_READ) = 0
munmap(0x7f0668a29000, 2299)            = 0
brk(0)                                  = 0x14c9000
brk(0x14ea000)                          = 0x14ea000
stat("target/d1", 0x7ffc755485e0)       = -1 ENOENT (No such file or directory)
rename("example/d1", "target/d1")       = -1 EXDEV (Invalid cross-device link)
lstat("example/d1", {st_dev=makedev(0, 33), st_ino=43, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=4
ze=4096, st_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:30:07, st_ctime=2017/06/09-15:35:00}) = 0
lstat("example/d1", {st_dev=makedev(0, 33), st_ino=43, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=4
ze=4096, st_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:30:07, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d1", 0x7ffc75548480)      = -1 ENOENT (No such file or directory)
umask(0)                                = 022
mkdir("target/d1", 040755)              = 0
umask(022)                              = 0
lstat("target/d1", {st_dev=makedev(0, 33), st_ino=62, st_mode=S_IFDIR|S_ISGID|0755, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096,
96, st_atime=2017/06/09-15:41:26, st_mtime=2017/06/09-15:41:26, st_ctime=2017/06/09-15:41:26}) = 0
stat("example/d1", {st_dev=makedev(0, 33), st_ino=43, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=40
e=4096, st_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:30:07, st_ctime=2017/06/09-15:35:00}) = 0
open("example/d1", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(3, {st_dev=makedev(0, 33), st_ino=43, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=4096, st_blo
_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:30:07, st_ctime=2017/06/09-15:35:00}) = 0
getdents(3, {{d_ino=63, d_off=24, d_reclen=32, d_name="image4.bmp", d_type=DT_REG} {d_ino=64, d_off=48, d_reclen=32, d_name="image3.b
ino=65, d_off=72, d_reclen=32, d_name="image1.bmp", d_type=DT_REG} {d_ino=66, d_off=88, d_reclen=24, d_name="a", d_type=DT_REG} {d_in
en=24, d_name="..", d_type=DT_DIR} {d_ino=67, d_off=128, d_reclen=32, d_name="image7.bmp", d_type=DT_REG} {d_ino=43, d_off=144, d_rec
ype=DT_DIR} {d_ino=68, d_off=160, d_reclen=24, d_name="b", d_type=DT_REG} {d_ino=69, d_off=184, d_reclen=32, d_name="image9.bmp", d_t
d_off=208, d_reclen=32, d_name="image0.bmp", d_type=DT_REG} {d_ino=71, d_off=232, d_reclen=32, d_name="image8.bmp", d_type=DT_REG} {d
eclen=32, d_name="image5.bmp", d_type=DT_REG} {d_ino=73, d_off=280, d_reclen=32, d_name="image2.bmp", d_type=DT_REG} {d_ino=74, d_off
me="image6.bmp", d_type=DT_REG}}, 32768) = 416
lstat("example/d1/image4.bmp", {st_dev=makedev(0, 33), st_ino=63, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:59, st_mtime=2017/06/09-15:29:59, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d1/image4.bmp", 0x7ffc755482e0) = -1 ENOENT (No such file or directory)
open("example/d1/image4.bmp", O_RDONLY) = 4
open("target/d1/image4.bmp", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 2764938
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/image4.bmp", {{1497022199, 0}, {1497022199, 0}}) = 0
chown("target/d1/image4.bmp", 2226832, 1049089) = 0
chmod("target/d1/image4.bmp", 0100644)  = 0
lstat("example/d1/image3.bmp", {st_dev=makedev(0, 33), st_ino=64, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:59, st_mtime=2017/06/09-15:29:59, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d1/image3.bmp", 0x7ffc755482e0) = -1 ENOENT (No such file or directory)
open("example/d1/image3.bmp", O_RDONLY) = 4
open("target/d1/image3.bmp", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 2764938
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/image3.bmp", {{1497022199, 0}, {1497022199, 0}}) = 0
chown("target/d1/image3.bmp", 2226832, 1049089) = 0
chmod("target/d1/image3.bmp", 0100644)  = 0
lstat("example/d1/image1.bmp", {st_dev=makedev(0, 33), st_ino=65, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:00, st_mtime=2017/06/09-15:29:00, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d1/image1.bmp", 0x7ffc755482e0) = -1 ENOENT (No such file or directory)
open("example/d1/image1.bmp", O_RDONLY) = 4
open("target/d1/image1.bmp", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 2764938
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/image1.bmp", {{1497022140, 0}, {1497022140, 0}}) = 0
chown("target/d1/image1.bmp", 2226832, 1049089) = 0
chmod("target/d1/image1.bmp", 0100644)  = 0
lstat("example/d1/a", {st_dev=makedev(0, 33), st_ino=66, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, st_blksize
size=1, st_atime=2017/06/09-15:11:12, st_mtime=2017/06/09-15:11:12, st_ctime=2017/06/09-15:34:59}) = 0
lstat("target/d1/a", 0x7ffc755482e0)    = -1 ENOENT (No such file or directory)
open("example/d1/a", O_RDONLY)          = 4
open("target/d1/a", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 1
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/a", {{1497021072, 0}, {1497021072, 0}}) = 0
chown("target/d1/a", 2226832, 1049089)  = 0
chmod("target/d1/a", 0100644)           = 0
lstat("example/d1/image7.bmp", {st_dev=makedev(0, 33), st_ino=67, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:30:00, st_mtime=2017/06/09-15:30:00, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d1/image7.bmp", 0x7ffc755482e0) = -1 ENOENT (No such file or directory)
open("example/d1/image7.bmp", O_RDONLY) = 4
open("target/d1/image7.bmp", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 2764938
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/image7.bmp", {{1497022200, 0}, {1497022200, 0}}) = 0
chown("target/d1/image7.bmp", 2226832, 1049089) = 0
chmod("target/d1/image7.bmp", 0100644)  = 0
lstat("example/d1/b", {st_dev=makedev(0, 33), st_ino=68, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, st_blksize
size=1, st_atime=2017/06/09-15:11:24, st_mtime=2017/06/09-15:11:24, st_ctime=2017/06/09-15:34:59}) = 0
lstat("target/d1/b", 0x7ffc755482e0)    = -1 ENOENT (No such file or directory)
open("example/d1/b", O_RDONLY)          = 4
open("target/d1/b", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 1
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/b", {{1497021084, 0}, {1497021084, 0}}) = 0
chown("target/d1/b", 2226832, 1049089)  = 0
chmod("target/d1/b", 0100644)           = 0
lstat("example/d1/image9.bmp", {st_dev=makedev(0, 33), st_ino=69, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:30:00, st_mtime=2017/06/09-15:30:00, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d1/image9.bmp", 0x7ffc755482e0) = -1 ENOENT (No such file or directory)
open("example/d1/image9.bmp", O_RDONLY) = 4
open("target/d1/image9.bmp", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 2764938
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/image9.bmp", {{1497022200, 0}, {1497022200, 0}}) = 0
chown("target/d1/image9.bmp", 2226832, 1049089) = 0
chmod("target/d1/image9.bmp", 0100644)  = 0
lstat("example/d1/image0.bmp", {st_dev=makedev(0, 33), st_ino=70, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:30:00, st_mtime=2017/06/09-15:30:00, st_ctime=2017/06/09-15:34:59}) = 0
lstat("target/d1/image0.bmp", 0x7ffc755482e0) = -1 ENOENT (No such file or directory)
open("example/d1/image0.bmp", O_RDONLY) = 4
open("target/d1/image0.bmp", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 2764938
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/image0.bmp", {{1497022200, 0}, {1497022200, 0}}) = 0
chown("target/d1/image0.bmp", 2226832, 1049089) = 0
chmod("target/d1/image0.bmp", 0100644)  = 0
lstat("example/d1/image8.bmp", {st_dev=makedev(0, 33), st_ino=71, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:30:00, st_mtime=2017/06/09-15:30:00, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d1/image8.bmp", 0x7ffc755482e0) = -1 ENOENT (No such file or directory)
open("example/d1/image8.bmp", O_RDONLY) = 4
open("target/d1/image8.bmp", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 2764938
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/image8.bmp", {{1497022200, 0}, {1497022200, 0}}) = 0
chown("target/d1/image8.bmp", 2226832, 1049089) = 0
chmod("target/d1/image8.bmp", 0100644)  = 0
lstat("example/d1/image5.bmp", {st_dev=makedev(0, 33), st_ino=72, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:59, st_mtime=2017/06/09-15:29:59, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d1/image5.bmp", 0x7ffc755482e0) = -1 ENOENT (No such file or directory)
open("example/d1/image5.bmp", O_RDONLY) = 4
open("target/d1/image5.bmp", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 2764938
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/image5.bmp", {{1497022199, 0}, {1497022199, 0}}) = 0
chown("target/d1/image5.bmp", 2226832, 1049089) = 0
chmod("target/d1/image5.bmp", 0100644)  = 0
lstat("example/d1/image2.bmp", {st_dev=makedev(0, 33), st_ino=73, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:59, st_mtime=2017/06/09-15:29:59, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d1/image2.bmp", 0x7ffc755482e0) = -1 ENOENT (No such file or directory)
open("example/d1/image2.bmp", O_RDONLY) = 4
open("target/d1/image2.bmp", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 2764938
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/image2.bmp", {{1497022199, 0}, {1497022199, 0}}) = 0
chown("target/d1/image2.bmp", 2226832, 1049089) = 0
chmod("target/d1/image2.bmp", 0100644)  = 0
lstat("example/d1/image6.bmp", {st_dev=makedev(0, 33), st_ino=74, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:59, st_mtime=2017/06/09-15:29:59, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d1/image6.bmp", 0x7ffc755482e0) = -1 ENOENT (No such file or directory)
open("example/d1/image6.bmp", O_RDONLY) = 4
open("target/d1/image6.bmp", O_WRONLY|O_CREAT|O_EXCL, 0100644) = 5
sendfile(5, 4, NULL, 16777216)          = 2764938
sendfile(5, 4, NULL, 16777216)          = 0
close(5)                                = 0
close(4)                                = 0
utimes("target/d1/image6.bmp", {{1497022199, 0}, {1497022199, 0}}) = 0
chown("target/d1/image6.bmp", 2226832, 1049089) = 0
chmod("target/d1/image6.bmp", 0100644)  = 0
getdents(3, {}, 32768)                  = 0
close(3)                                = 0
chmod("target/d1", 040755)              = 0
utimes("target/d1", {{1497022207, 0}, {1497022207, 0}}) = 0
chown("target/d1", 2226832, 1049089)    = 0
chmod("target/d1", 040755)              = 0
lstat("example/d1", {st_dev=makedev(0, 33), st_ino=43, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=4
ze=4096, st_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:30:07, st_ctime=2017/06/09-15:35:00}) = 0
stat("example/d1", {st_dev=makedev(0, 33), st_ino=43, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=40
e=4096, st_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:30:07, st_ctime=2017/06/09-15:35:00}) = 0
open("example/d1", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(3, {st_dev=makedev(0, 33), st_ino=43, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=4096, st_blo
_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:30:07, st_ctime=2017/06/09-15:35:00}) = 0
getdents(3, {{d_ino=63, d_off=24, d_reclen=32, d_name="image4.bmp", d_type=DT_REG} {d_ino=64, d_off=48, d_reclen=32, d_name="image3.b
ino=65, d_off=72, d_reclen=32, d_name="image1.bmp", d_type=DT_REG} {d_ino=66, d_off=88, d_reclen=24, d_name="a", d_type=DT_REG} {d_in
en=24, d_name="..", d_type=DT_DIR} {d_ino=67, d_off=128, d_reclen=32, d_name="image7.bmp", d_type=DT_REG} {d_ino=43, d_off=144, d_rec
ype=DT_DIR} {d_ino=68, d_off=160, d_reclen=24, d_name="b", d_type=DT_REG} {d_ino=69, d_off=184, d_reclen=32, d_name="image9.bmp", d_t
d_off=208, d_reclen=32, d_name="image0.bmp", d_type=DT_REG} {d_ino=71, d_off=232, d_reclen=32, d_name="image8.bmp", d_type=DT_REG} {d
eclen=32, d_name="image5.bmp", d_type=DT_REG} {d_ino=73, d_off=280, d_reclen=32, d_name="image2.bmp", d_type=DT_REG} {d_ino=74, d_off
me="image6.bmp", d_type=DT_REG}}, 32768) = 416
lstat("example/d1/image4.bmp", {st_dev=makedev(0, 33), st_ino=63, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:59, st_mtime=2017/06/09-15:29:59, st_ctime=2017/06/09-15:35:00}) = 0
unlink("example/d1/image4.bmp")         = 0
lstat("example/d1/image3.bmp", {st_dev=makedev(0, 33), st_ino=64, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:59, st_mtime=2017/06/09-15:29:59, st_ctime=2017/06/09-15:35:00}) = 0
unlink("example/d1/image3.bmp")         = 0
lstat("example/d1/image1.bmp", {st_dev=makedev(0, 33), st_ino=65, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:00, st_mtime=2017/06/09-15:29:00, st_ctime=2017/06/09-15:35:00}) = 0
unlink("example/d1/image1.bmp")         = 0
lstat("example/d1/a", {st_dev=makedev(0, 33), st_ino=66, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, st_blksize
size=1, st_atime=2017/06/09-15:11:12, st_mtime=2017/06/09-15:11:12, st_ctime=2017/06/09-15:34:59}) = 0
unlink("example/d1/a")                  = 0
lstat("example/d1/image7.bmp", {st_dev=makedev(0, 33), st_ino=67, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:30:00, st_mtime=2017/06/09-15:30:00, st_ctime=2017/06/09-15:35:00}) = 0
unlink("example/d1/image7.bmp")         = 0
lstat("example/d1/b", {st_dev=makedev(0, 33), st_ino=68, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, st_blksize
size=1, st_atime=2017/06/09-15:11:24, st_mtime=2017/06/09-15:11:24, st_ctime=2017/06/09-15:34:59}) = 0
unlink("example/d1/b")                  = 0
lstat("example/d1/image9.bmp", {st_dev=makedev(0, 33), st_ino=69, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:30:00, st_mtime=2017/06/09-15:30:00, st_ctime=2017/06/09-15:35:00}) = 0
unlink("example/d1/image9.bmp")         = 0
lstat("example/d1/image0.bmp", {st_dev=makedev(0, 33), st_ino=70, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:30:00, st_mtime=2017/06/09-15:30:00, st_ctime=2017/06/09-15:34:59}) = 0
unlink("example/d1/image0.bmp")         = 0
lstat("example/d1/image8.bmp", {st_dev=makedev(0, 33), st_ino=71, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:30:00, st_mtime=2017/06/09-15:30:00, st_ctime=2017/06/09-15:35:00}) = 0
unlink("example/d1/image8.bmp")         = 0
lstat("example/d1/image5.bmp", {st_dev=makedev(0, 33), st_ino=72, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:59, st_mtime=2017/06/09-15:29:59, st_ctime=2017/06/09-15:35:00}) = 0
unlink("example/d1/image5.bmp")         = 0
lstat("example/d1/image2.bmp", {st_dev=makedev(0, 33), st_ino=73, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:59, st_mtime=2017/06/09-15:29:59, st_ctime=2017/06/09-15:35:00}) = 0
unlink("example/d1/image2.bmp")         = 0
lstat("example/d1/image6.bmp", {st_dev=makedev(0, 33), st_ino=74, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, s
ks=5408, st_size=2764938, st_atime=2017/06/09-15:29:59, st_mtime=2017/06/09-15:29:59, st_ctime=2017/06/09-15:35:00}) = 0
unlink("example/d1/image6.bmp")         = 0
getdents(3, {}, 32768)                  = 0
close(3)                                = 0
rmdir("example/d1")                     = 0
stat("target/d2", 0x7ffc755485e0)       = -1 ENOENT (No such file or directory)
rename("example/d2", "target/d2")       = -1 EXDEV (Invalid cross-device link)
lstat("example/d2", {st_dev=makedev(0, 33), st_ino=44, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=4
ze=4096, st_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:11:48, st_ctime=2017/06/09-15:35:00}) = 0
lstat("example/d2", {st_dev=makedev(0, 33), st_ino=44, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=4
ze=4096, st_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:11:48, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d2", 0x7ffc75548480)      = -1 ENOENT (No such file or directory)
umask(0)                                = 022
mkdir("target/d2", 040755)              = 0
umask(022)                              = 0
lstat("target/d2", {st_dev=makedev(0, 33), st_ino=43, st_mode=S_IFDIR|S_ISGID|0755, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096,
96, st_atime=2017/06/09-15:41:26, st_mtime=2017/06/09-15:41:26, st_ctime=2017/06/09-15:41:26}) = 0
stat("example/d2", {st_dev=makedev(0, 33), st_ino=44, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=40
e=4096, st_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:11:48, st_ctime=2017/06/09-15:35:00}) = 0
open("example/d2", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(3, {st_dev=makedev(0, 33), st_ino=44, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=4096, st_blo
_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:11:48, st_ctime=2017/06/09-15:35:00}) = 0
getdents(3, {{d_ino=63, d_off=16, d_reclen=24, d_name="c", d_type=DT_REG} {d_ino=42, d_off=32, d_reclen=24, d_name="..", d_type=DT_DI
 d_reclen=24, d_name=".", d_type=DT_DIR} {d_ino=64, d_off=64, d_reclen=24, d_name="d", d_type=DT_REG}}, 32768) = 96
lstat("example/d2/c", {st_dev=makedev(0, 33), st_ino=63, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, st_blksize
size=1, st_atime=2017/06/09-15:11:39, st_mtime=2017/06/09-15:11:39, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d2/c", 0x7ffc755482e0)    = -1 ENOENT (No such file or directory)
link("target/d1/image4.bmp", "target/d2/c") = 0
lstat("example/d2/d", {st_dev=makedev(0, 33), st_ino=64, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, st_blksize
size=1, st_atime=2017/06/09-15:11:51, st_mtime=2017/06/09-15:11:51, st_ctime=2017/06/09-15:35:00}) = 0
lstat("target/d2/d", 0x7ffc755482e0)    = -1 ENOENT (No such file or directory)
link("target/d1/image3.bmp", "target/d2/d") = 0
getdents(3, {}, 32768)                  = 0
close(3)                                = 0
chmod("target/d2", 040755)              = 0
utimes("target/d2", {{1497021108, 0}, {1497021108, 0}}) = 0
chown("target/d2", 2226832, 1049089)    = 0
chmod("target/d2", 040755)              = 0
lstat("example/d2", {st_dev=makedev(0, 33), st_ino=44, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=4
ze=4096, st_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:11:48, st_ctime=2017/06/09-15:35:00}) = 0
stat("example/d2", {st_dev=makedev(0, 33), st_ino=44, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=40
e=4096, st_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:11:48, st_ctime=2017/06/09-15:35:00}) = 0
open("example/d2", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(3, {st_dev=makedev(0, 33), st_ino=44, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=2226832, st_gid=1049089, st_blksize=4096, st_blo
_atime=2017/06/09-15:35:00, st_mtime=2017/06/09-15:11:48, st_ctime=2017/06/09-15:35:00}) = 0
getdents(3, {{d_ino=63, d_off=16, d_reclen=24, d_name="c", d_type=DT_REG} {d_ino=42, d_off=32, d_reclen=24, d_name="..", d_type=DT_DI
 d_reclen=24, d_name=".", d_type=DT_DIR} {d_ino=64, d_off=64, d_reclen=24, d_name="d", d_type=DT_REG}}, 32768) = 96
lstat("example/d2/c", {st_dev=makedev(0, 33), st_ino=63, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, st_blksize
size=1, st_atime=2017/06/09-15:11:39, st_mtime=2017/06/09-15:11:39, st_ctime=2017/06/09-15:35:00}) = 0
unlink("example/d2/c")                  = 0
lstat("example/d2/d", {st_dev=makedev(0, 33), st_ino=64, st_mode=S_IFREG|0644, st_nlink=1, st_uid=2226832, st_gid=1049089, st_blksize
size=1, st_atime=2017/06/09-15:11:51, st_mtime=2017/06/09-15:11:51, st_ctime=2017/06/09-15:35:00}) = 0
unlink("example/d2/d")                  = 0
getdents(3, {}, 32768)                  = 0
close(3)                                = 0
rmdir("example/d2")                     = 0
exit_group(0)                           = ?
+++ exited with 0 +++
Comment 1 Steffen 2017-06-09 15:57:23 UTC
Created attachment 7071 [details]
strace-output.txt
Comment 2 Bernhard Reutner-Fischer 2017-06-11 10:01:18 UTC
From http://aufs.sourceforge.net/aufs.html

---8<---
To rename(2) directory may return EXDEV even if both of src and tgt are on the same aufs. When the rename-src dir exists on multiple branches and the lower dir has child(ren), aufs has to copyup all his children. It can be recursive copyup. Current aufs does not support such huge copyup operation at one time in kernel space, instead produces a warning and returns EXDEV. Generally, mv(1) detects this error and tries mkdir(2) and rename(2) or copy/unlink recursively. So the result is harmless. If your application which issues rename(2) for a directory does not support EXDEV, it will not work on aufs. Also this specification is applied to the case when the src directroy exists on the lower readonly branch and it has child(ren).
---8<---
Comment 3 Steffen 2017-06-13 09:11:05 UTC
What may help here, is to first do all copying, then eventually do all removals.