Hi folks,

Versions of coreutils cp from 9.1-9.5 have been failing with error message:

        "cp: cannot create regular file '/tmp/b/c': File exists"

to overwrite existing files even with -f under Cygwin.

I have been trying to run down how and where cp is missing a check that the file exists by tracing and with gdb without anything obvious grabbing my attention and raising suspicions.

Any advice for changing my approach, or where specifically to concentrate, could be helpful in progressing a new release.

A couple of Cygwin specific patches have been applied over many releases with rebases to root inode handling and allowing case insensitivity that do not appear to have had any other effect on the flow or operations.

--
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                -- Antoine de Saint-Exupéry
#!/bin/sh
# cp-9.1-fails-file-exists.sh

#set -vx

days=7
ver=9.1
ls_opt=-glo
rc=0

tmp=${TMPDIR:-${TMP:_${TEMP:-/tmp}}}
bin=coreutils-$ver-1.$(arch)/inst/usr/bin

for d in $tmp $bin
do
    [ ! -d $d/ ] && echo "${0##*/}: $d: not found" >&2 && rc=2
done

[ 0 -eq $rc ]   || exit $rc

export PATH="$PWD/$bin:$PATH"

for u in cp echo ls mkdir rm tee touch
do
    if [ ! -s $bin/$u ] || [ ! -x $bin/$u ]
    then
        echo "${0##*/}: $u: not found" >&2 && rc=2
    fi
done

[ 0 -eq $rc ]   || exit $rc

for dir in a b
do
    rm -fr $tmp/$dir/*
    mkdir -p $tmp/$dir/

    for f in c # dd eee f.fff gg.ggg hhh.hhh iiiiiii jjjjjjjj kkkkkkkkk
    do
        echo $f > $tmp/$dir/$f
    done

    days=$(($days+7))
done

for f in 0 y
do
    echo $f > $tmp/a/$f
done

for f in 1 z
do
    echo $f > $tmp/b/$f
done

ls $ls_opt $tmp/a/ $tmp/b/

for cp in $bin/cp /bin/cp
do
    for f in $tmp/a/*
    do
        for p in "echo run:" command strace
        do
            [ "strace" = "$p" ] && o=" -o cp-${f##*/}.strace" || o=''
            $p$o $cp -fv        $tmp/a/*        $tmp/b/
            [ 0 -eq $? ] && [ "command" = "$p" ] && break
        done
    done

    ls $ls_opt $tmp/b/
done

/tmp/a/:
total 3
-rw-r--r-- 1 2 Oct 18 10:26 0
-rw-r--r-- 1 2 Oct 18 10:26 c
-rw-r--r-- 1 2 Oct 18 10:26 y

/tmp/b/:
total 3
-rw-r--r-- 1 2 Oct 18 10:26 1
-rw-r--r-- 1 2 Oct 18 10:26 c
-rw-r--r-- 1 2 Oct 18 10:26 z
run: coreutils-9.1-1.x86_64/inst/usr/bin/cp -fv /tmp/a/0 /tmp/a/c /tmp/a/y 
/tmp/b/
'/tmp/a/0' -> '/tmp/b/0'
'/tmp/a/c' -> '/tmp/b/c'
coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create regular file '/tmp/b/c': 
File exists
'/tmp/a/y' -> '/tmp/b/y'
'/tmp/a/0' -> '/tmp/b/0'
/usr/src/coreutils/coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create 
regular file '/tmp/b/0': File exists
'/tmp/a/c' -> '/tmp/b/c'
/usr/src/coreutils/coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create 
regular file '/tmp/b/c': File exists
'/tmp/a/y' -> '/tmp/b/y'
/usr/src/coreutils/coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create 
regular file '/tmp/b/y': File exists
run: coreutils-9.1-1.x86_64/inst/usr/bin/cp -fv /tmp/a/0 /tmp/a/c /tmp/a/y 
/tmp/b/
'/tmp/a/0' -> '/tmp/b/0'
coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create regular file '/tmp/b/0': 
File exists
'/tmp/a/c' -> '/tmp/b/c'
coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create regular file '/tmp/b/c': 
File exists
'/tmp/a/y' -> '/tmp/b/y'
coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create regular file '/tmp/b/y': 
File exists
'/tmp/a/0' -> '/tmp/b/0'
/usr/src/coreutils/coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create 
regular file '/tmp/b/0': File exists
'/tmp/a/c' -> '/tmp/b/c'
/usr/src/coreutils/coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create 
regular file '/tmp/b/c': File exists
'/tmp/a/y' -> '/tmp/b/y'
/usr/src/coreutils/coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create 
regular file '/tmp/b/y': File exists
run: coreutils-9.1-1.x86_64/inst/usr/bin/cp -fv /tmp/a/0 /tmp/a/c /tmp/a/y 
/tmp/b/
'/tmp/a/0' -> '/tmp/b/0'
coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create regular file '/tmp/b/0': 
File exists
'/tmp/a/c' -> '/tmp/b/c'
coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create regular file '/tmp/b/c': 
File exists
'/tmp/a/y' -> '/tmp/b/y'
coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create regular file '/tmp/b/y': 
File exists
'/tmp/a/0' -> '/tmp/b/0'
/usr/src/coreutils/coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create 
regular file '/tmp/b/0': File exists
'/tmp/a/c' -> '/tmp/b/c'
/usr/src/coreutils/coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create 
regular file '/tmp/b/c': File exists
'/tmp/a/y' -> '/tmp/b/y'
/usr/src/coreutils/coreutils-9.1-1.x86_64/inst/usr/bin/cp: cannot create 
regular file '/tmp/b/y': File exists
total 5
-rw-r--r-- 1 2 Oct 18 10:26 0
-rw-r--r-- 1 2 Oct 18 10:26 1
-rw-r--r-- 1 2 Oct 18 10:26 c
-rw-r--r-- 1 2 Oct 18 10:26 y
-rw-r--r-- 1 2 Oct 18 10:26 z
run: /bin/cp -fv /tmp/a/0 /tmp/a/c /tmp/a/y /tmp/b/
'/tmp/a/0' -> '/tmp/b/0'
'/tmp/a/c' -> '/tmp/b/c'
'/tmp/a/y' -> '/tmp/b/y'
run: /bin/cp -fv /tmp/a/0 /tmp/a/c /tmp/a/y /tmp/b/
'/tmp/a/0' -> '/tmp/b/0'
'/tmp/a/c' -> '/tmp/b/c'
'/tmp/a/y' -> '/tmp/b/y'
run: /bin/cp -fv /tmp/a/0 /tmp/a/c /tmp/a/y /tmp/b/
'/tmp/a/0' -> '/tmp/b/0'
'/tmp/a/c' -> '/tmp/b/c'
'/tmp/a/y' -> '/tmp/b/y'
total 5
-rw-r--r-- 1 2 Oct 18 10:26 0
-rw-r--r-- 1 2 Oct 18 10:26 1
-rw-r--r-- 1 2 Oct 18 10:26 c
-rw-r--r-- 1 2 Oct 18 10:26 y
-rw-r--r-- 1 2 Oct 18 10:26 z

Reply via email to