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

From: Sudhip Nashi <[email-masked]>
Date: Mon, 15 Nov 2021 21:14:44 -0600

Sure, here’s the dtruss output:

SYSCALL(args) 		 = return
access("/AppleInternal/XBS/.isChrooted\0", 0x0, 0x0)		 = -1 Err#2
bsdthread_register(0x1AEC802C8, 0x1AEC802BC, 0x4000)		 = 1073742303 0
shm_open(0x1AEB48F55, 0x0, 0xDD8000)		 = 3 0
fstat64(0x3, 0x16F0260D0, 0x0)		 = 0 0
mmap(0x0, 0x4000, 0x1, 0x40001, 0x3, 0x0)		 = 0x100F18000 0
close(0x3)		 = 0 0
ioctl(0x2, 0x4004667A, 0x16F02617C)		 = -1 Err#25
ioctl(0x2, 0x40487413, 0x16F026180)		 = -1 Err#25
mprotect(0x100F24000, 0x4000, 0x0)		 = 0 0
mprotect(0x100F30000, 0x4000, 0x0)		 = 0 0
mprotect(0x100F34000, 0x4000, 0x0)		 = 0 0
mprotect(0x100F40000, 0x4000, 0x0)		 = 0 0
mprotect(0x100F44000, 0x4000, 0x0)		 = 0 0
mprotect(0x100F50000, 0x4000, 0x0)		 = 0 0
mprotect(0x100F1C000, 0x90, 0x1)		 = 0 0
mprotect(0x100F1C000, 0x90, 0x3)		 = 0 0
mprotect(0x100F1C000, 0x90, 0x1)		 = 0 0
mprotect(0x100F54000, 0x4000, 0x1)		 = 0 0
mprotect(0x100F58000, 0x90, 0x1)		 = 0 0
mprotect(0x100F58000, 0x90, 0x3)		 = 0 0
mprotect(0x100F58000, 0x90, 0x1)		 = 0 0
mprotect(0x100F1C000, 0x90, 0x3)		 = 0 0
mprotect(0x100F1C000, 0x90, 0x1)		 = 0 0
mprotect(0x100F54000, 0x4000, 0x3)		 = 0 0
mprotect(0x100F54000, 0x4000, 0x1)		 = 0 0
objc_bp_assist_cfg_np(0x1AEB103C0, 0x8000000000201048, 0x0)		 = -1 Err#5
issetugid(0x0, 0x0, 0x0)		 = 0 0
getentropy(0x16F025F98, 0x20, 0x0)		 = 0 0
getentropy(0x16F025FE8, 0x40, 0x0)		 = 0 0
getpid(0x0, 0x0, 0x0)		 = 45930 0
stat64("/AppleInternal\0", 0x16F0266E0, 0x0)		 = -1 Err#2
csops_audittoken(0xB36A, 0x7, 0x16F026210)		 = 0 0
proc_info(0x2, 0xB36A, 0xD)		 = 64 0
csops_audittoken(0xB36A, 0x7, 0x16F0262D0)		 = 0 0
sysctlbyname(kern.osvariant_status, 0x15, 0x16F026748, 0x16F026740, 0x0)		 = 0 0
csops(0xB36A, 0x0, 0x16F02676C)		 = 0 0
mprotect(0x100E10000, 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, 0x16F027118, 0x0)		 = 0 0
fstat64(0x3, 0x16F027090, 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, 0x16F0271C0, 0x0)		 = 0 0
fstat64(0x3, 0x16F026FB0, 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, 0x16F0271E0, 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, 0x16F0271E0, 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, 0x16F0271F0, 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, 0x16F0271F0, 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/filetest\0", 0x16F0276C0, 0x0)		 = -1 Err#2
fstatat64(0xFFFFFFFFFFFFFFFE, 0x16F027BDD, 0x16F027390)		 = 0 0
fstatat64(0xFFFFFFFFFFFFFFFE, 0x16F027C0B, 0x16F027300)		 = -1 Err#2
open("/System/Library/dyld/dyld_shared_cache_arm64e\0", 0x0, 0x0)		 = 3 0
fstat64(0x3, 0x16F027430, 0x0)		 = 0 0
open("/tmp/filetest\0", 0xA01, 0x1ED)		 = 4 0
fstat64(0x4, 0x16F027560, 0x0)		 = 0 0
sysctl([CTL_HW, 7, 0, 0, 0, 0] (2), 0x207EC4068, 0x16F027220, 0x0, 0x0)		 = 0 0
lseek(0x3, 0x0, 0x3)		 = -1 Err#6
ftruncate(0x4, 0x59C68000, 0x0)		 = 0 0
close(0x4)		 = 0 0
close(0x3)		 = 0 0
lseek(0x0, 0x0, 0x1)		 = 21373 0
lseek(0x0, 0x0, 0x1)		 = 21373 0
lseek(0x0, 0x537D, 0x0)		 = 21373 0
close_nocancel(0x0)		 = 0 0
close_nocancel(0x1)		 = 0 0
close_nocancel(0x2)		 = 0 0

> On Nov 15, 2021, at 8:10 PM, Paul Eggert <[email-masked]> wrote:
> 
> On 11/15/21 16:02, Sudhip Nashi wrote:
>> It doesn’t seem like this patch works. I compiled from the tarball you provided, but the destination file is still filled with NULL chars.
> 
> Too bad. Can you do a dtruss or at least a ktrace/kdump for the failing program? I'd like to see what lseek is doing with SEEK_HOLE and SEEK_DATA. Thanks.