Subject: Re: bug#51857: cross-filesystem copying broken on macOS with coreutils >= 9.0

From: Cameron Katri <[email-masked]>
Date: Mon, 15 Nov 2021 10:48:19 -0500

> On Nov 15, 2021, at 10:09 AM, Pádraig Brady <[email-masked]> wrote:
> 
> On 15/11/2021 04:02, Sudhip Nashi via GNU coreutils Bug Reports wrote:
>> Hello,
>> Cross-filesystem copying seems to have been broken in the latest coreutils release on macOS. Running a command like ‘cp /usr/bin/clear /tmp/test’ appears to return successfully, but if one analyzes /tmp/test, it’s filled with NULL characters. However, copying works fine when the source and destination file are on the same filesystem. Do you know what might be causing this?
>> Thanks in advance,
>> Sudhip Nashi
> 
> What are the source and dest file system types?
> Could you send the output of `sudo dtruss cp /usr/bin/clear /tmp/test`?
> I suspect SEEK_DATA may have issues on nacOS,
> as usage of that is new in coreutils 9.0.
> 
> thanks,
> Pádraig

Here yo go:

sudo dtruss ./src/cp /usr/bin/clear /tmp/test
SYSCALL(args) 		 = return
access("/AppleInternal/XBS/.isChrooted\0", 0x0, 0x0)		 = -1 Err#2
bsdthread_register(0x1AEC802C8, 0x1AEC802BC, 0x4000)		 = 1073742303 0
shm_open(0x1AEB48F55, 0x0, 0xFFFFFFFFB821D000)		 = 3 0
fstat64(0x3, 0x16DDC2070, 0x0)		 = 0 0
mmap(0x0, 0x4000, 0x1, 0x40001, 0x3, 0x0)		 = 0x102170000 0
close(0x3)		 = 0 0
ioctl(0x2, 0x4004667A, 0x16DDC211C)		 = 0 0
mprotect(0x1021A0000, 0x4000, 0x0)		 = 0 0
mprotect(0x1021AC000, 0x4000, 0x0)		 = 0 0
mprotect(0x1021B0000, 0x4000, 0x0)		 = 0 0
mprotect(0x1021BC000, 0x4000, 0x0)		 = 0 0
mprotect(0x1021C0000, 0x4000, 0x0)		 = 0 0
mprotect(0x1021CC000, 0x4000, 0x0)		 = 0 0
mprotect(0x102174000, 0x90, 0x1)		 = 0 0
mprotect(0x102174000, 0x90, 0x3)		 = 0 0
mprotect(0x102174000, 0x90, 0x1)		 = 0 0
mprotect(0x10217C000, 0x4000, 0x1)		 = 0 0
mprotect(0x1021D0000, 0x90, 0x1)		 = 0 0
mprotect(0x1021D0000, 0x90, 0x3)		 = 0 0
mprotect(0x1021D0000, 0x90, 0x1)		 = 0 0
mprotect(0x102174000, 0x90, 0x3)		 = 0 0
mprotect(0x102174000, 0x90, 0x1)		 = 0 0
mprotect(0x10217C000, 0x4000, 0x3)		 = 0 0
mprotect(0x10217C000, 0x4000, 0x1)		 = 0 0
objc_bp_assist_cfg_np(0x1AEB103C0, 0x8000000000201048, 0x0)		 = -1 Err#5
issetugid(0x0, 0x0, 0x0)		 = 0 0
getentropy(0x16DDC1EC8, 0x20, 0x0)		 = 0 0
getentropy(0x16DDC1F18, 0x40, 0x0)		 = 0 0
getpid(0x0, 0x0, 0x0)		 = 4661 0
stat64("/AppleInternal\0", 0x16DDC2680, 0x0)		 = -1 Err#2
csops_audittoken(0x1235, 0x7, 0x16DDC21B0)		 = 0 0
proc_info(0x2, 0x1235, 0xD)		 = 64 0
csops_audittoken(0x1235, 0x7, 0x16DDC2270)		 = 0 0
sysctlbyname(kern.osvariant_status, 0x15, 0x16DDC26E8, 0x16DDC26E0, 0x0)		 = 0 0
csops(0x1235, 0x0, 0x16DDC270C)		 = 0 0
geteuid(0x0, 0x0, 0x0)		 = 0 0
getuid(0x0, 0x0, 0x0)		 = 0 0
sysctl([CTL_KERN, 14, 1, 4661, 0, 0] (4), 0x16DDC0C00, 0x16DDC0BE8, 0x0, 0x0)		 = 0 0
gettid(0x16DDC0EE0, 0x16DDC0EE4, 0x0)		 = -1 Err#3
geteuid(0x0, 0x0, 0x0)		 = 0 0
getegid(0x0, 0x0, 0x0)		 = 0 0
csops(0x1235, 0x0, 0x16DDC1C24)		 = 0 0
gettid(0x16DDC0EB0, 0x16DDC0EB4, 0x0)		 = -1 Err#3
geteuid(0x0, 0x0, 0x0)		 = 0 0
getegid(0x0, 0x0, 0x0)		 = 0 0
mprotect(0x102068000, 0x100000, 0x1)		 = 0 0
open_nocancel("/usr/share/locale/en_US.UTF-8/LC_COLLATE\0", 0x0, 0x0)		 = 3 0
fcntl_nocancel(0x3, 0x3, 0x0)		 = 0 0
getrlimit(0x1008, 0x16DDC2F98, 0x0)		 = 0 0
fstat64(0x3, 0x16DDC2F10, 0x0)		 = 0 0
read_nocancel(0x3, "1.1A\n\0", 0x1000)		 = 2086 0
close_nocancel(0x3)		 = 0 0
open_nocancel("/usr/share/locale/en_US.UTF-8/LC_CTYPE\0", 0x0, 0x0)		 = 3 0
fcntl_nocancel(0x3, 0x3, 0x0)		 = 0 0
fstat64(0x3, 0x16DDC3040, 0x0)		 = 0 0
fstat64(0x3, 0x16DDC2E30, 0x0)		 = 0 0
lseek(0x3, 0x0, 0x1)		 = 0 0
lseek(0x3, 0x0, 0x0)		 = 0 0
read_nocancel(0x3, "RuneMagAUTF-8\0", 0x1000)		 = 4096 0
read_nocancel(0x3, "\0", 0x1000)		 = 4096 0
read_nocancel(0x3, "\0", 0x1000)		 = 4096 0
read_nocancel(0x3, "\0", 0x1000)		 = 4096 0
read_nocancel(0x3, "\0", 0x1000)		 = 4096 0
read_nocancel(0x3, "\0", 0x1000)		 = 4096 0
read_nocancel(0x3, "\0", 0x1000)		 = 4096 0
read_nocancel(0x3, "@\004\211\0", 0xF5D0)		 = 62928 0
close_nocancel(0x3)		 = 0 0
open_nocancel("/usr/share/locale/en_US.UTF-8/LC_MONETARY\0", 0x0, 0x0)		 = 3 0
fstat64(0x3, 0x16DDC3060, 0x0)		 = 0 0
read_nocancel(0x3, "USD \n$\n.\n,\n3;3\n\n-\n2\n2\n1\n0\n1\n0\n1\n1\n(\0", 0x22)		 = 34 0
close_nocancel(0x3)		 = 0 0
open_nocancel("/usr/share/locale/en_US.UTF-8/LC_NUMERIC\0", 0x0, 0x0)		 = 3 0
fstat64(0x3, 0x16DDC3060, 0x0)		 = 0 0
read_nocancel(0x3, ".\n,\n3;3\n@$\b\0", 0x8)		 = 8 0
close_nocancel(0x3)		 = 0 0
open_nocancel("/usr/share/locale/en_US.UTF-8/LC_TIME\0", 0x0, 0x0)		 = 3 0
fstat64(0x3, 0x16DDC3070, 0x0)		 = 0 0
read_nocancel(0x3, "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec\nJanuary\nFebruary\nMarch\nApril\nMay\nJune\nJuly\nAugust\nSeptember\nOctober\nNovember\nDecember\nSun\nMon\nTue\nWed\nThu\nFri\nSat\nSunday\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\n%H:%M:%S\n%m/%d/%Y\n%a %b %e %X %Y\nAM\nP", 0x179)		 = 377 0
close_nocancel(0x3)		 = 0 0
open_nocancel("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/LC_MESSAGES\0", 0x0, 0x0)		 = 3 0
fstat64(0x3, 0x16DDC3070, 0x0)		 = 0 0
read_nocancel(0x3, "^[yYsS].*\n^[nN].*\n(\0", 0x12)		 = 18 0
close_nocancel(0x3)		 = 0 0
geteuid(0x0, 0x0, 0x0)		 = 0 0
stat64("/tmp/test\0", 0x16DDC36C0, 0x0)		 = 0 0
fstatat64(0xFFFFFFFFFFFFFFFE, 0x16DDC3C21, 0x16DDC2BA0)		 = 0 0
fstatat64(0xFFFFFFFFFFFFFFFE, 0x16DDC3C30, 0x16DDC2B10)		 = 0 0
open("/usr/bin/clear\0", 0x0, 0x0)		 = 3 0
fstat64(0x3, 0x16DDC2C30, 0x0)		 = 0 0
open("/tmp/test\0", 0x401, 0x0)		 = 4 0
fstat64(0x4, 0x16DDC2CC0, 0x0)		 = 0 0
fstat64(0x4, 0x16DDC2D50, 0x0)		 = 0 0
fcntl(0x3, 0x32, 0x16DDC3200)		 = 0 0
fcntl(0x4, 0x32, 0x16DDC2E00)		 = 0 0
unlink("/private/tmp/test\0", 0x0, 0x0)		 = 0 0
clonefileat(0xFFFFFFFFFFFFFFFE, 0x16DDC3200, 0xFFFFFFFFFFFFFFFE)		 = -1 Err#18
open("/private/tmp/test\0", 0x601, 0x81ED)		 = 5 0
close(0x5)		 = 0 0
open("/private/tmp/test\0", 0x2, 0x0)		 = 5 0
dup2(0x5, 0x4, 0x0)		 = 4 0
close(0x5)		 = 0 0
fchmod(0x4, 0x81ED, 0x0)		 = 0 0
fchown(0x4, 0x0, 0x0)		 = 0 0
futimes(0x4, 0x16DDC2DE0, 0x0)		 = 0 0
sysctl([CTL_HW, 7, 0, 0, 0, 0] (2), 0x207EC4068, 0x16DDC2A30, 0x0, 0x0)		 = 0 0
lseek(0x3, 0x0, 0x4)		 = -1 Err#6
ftruncate(0x4, 0x1D770, 0x0)		 = 0 0
close(0x4)		 = 0 0
close(0x3)		 = 0 0
lseek(0x0, 0x0, 0x1)		 = 6741 0
lseek(0x0, 0x0, 0x1)		 = 6741 0
lseek(0x0, 0x1A55, 0x0)		 = 6741 0
close_nocancel(0x0)		 = 0 0
close_nocancel(0x1)		 = 0 0
close_nocancel(0x2)		 = 0 0