DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 4AO7WmhA1135720
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 4AO7WmhA1135720
Authentication-Results: delorie.com;
	dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=JtAl5bhR
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA6003858D29
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1732433567;
	bh=7ATpI1r/8QI8zJC4WX1yzwLu1pekzxXKHu/a/qB8LxM=;
	h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=JtAl5bhRdBpYNWbJNpffZrBjx/Lpa815JYNZ7CY0csY1TL5yXV4pZqqZhldKC+Yas
	 Kk5GZDnMTu571QU10Iavti4E0o+P5JPOznNIj5fxFDTr8mMk4LcqCWT4iVwKetvRey
	 4pP+3Pxi8Gp2YpAL9Szp76w5Jo4KuFcC9SAMKheg=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EDCCA3858D29
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EDCCA3858D29
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732433539; cv=none;
 b=SD8EZJRKUogJ/1t++oR99VNwd3XM35cxx1dAYqeMhM7qTj4vOnASRfeo+hlK4QcCHw79eZjM9j5qNW9axXH+9nJaD9ExlPKlu6vLhMlLJncNrTVUPJ5oZmPZMR/jtlLWNeXUgCNN6Hp3nSRAQSfSd6cnbrAlan4pT8AYhhIHK0s=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1732433539; c=relaxed/simple;
 bh=2p7Ad+81/j10nsoH/o5Tvz8qK/KGtyjHHd15lqnl9jg=;
 h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;
 b=sjWITXE9VCpX9mVPp9tfSMpMuO1DhvnxRoSnOLgIlG7Jpvp53wdpMYCTkYf57LJcc+wgzyf4R20AOSWmM1XZrgJ5xQ2g/n4Tv2StYwNuVYDcBiYFO6MTkxyAgxiw74kpgov1yGZVUp7tpIZeRrPiy67zgqYNz4MvMmxoToBzOA0=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EDCCA3858D29
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1732433537; x=1733038337;
 h=to:subject:message-id:date:from:in-reply-to:references:mime-version
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=jTegpbYlmjGN01rWEjBhBxLjlnyb5xNARCUZufyl0Fw=;
 b=TlDK1wAqlqow0ZazI5gLRzBNjq83ie/oAFD6NiIR++umXDtPXU4TcLY+5ZIiqIZ68q
 VY33LkTFjk3aPHvkOCbzEfwnAytpOD+vVZWiKUQh+8oI2HpMqjixLHs9iNymkIBnf6Ze
 xXi38bxa+Q+9WgR/danh4piqgxeHzqreQkcaqXpLsapNdJ4MSLmDzrsd7oNYvi+lSsZQ
 x6VkCrXMGXE8+IyxCEmaZhLFQNCwARx+fhSbU+h6UmaVTEU716lkhlg2uAuzxPuilfa+
 mOMbcV92fA1wNrdkW2oNib0IS8tz0sK4yPGq9P2Ag42HeAWbJ+aq4l/hiwArJ1MC1x7B
 eVBA==
X-Gm-Message-State: AOJu0YyQUxuPJFB5PJoGF8cP1DTo6dy3JVB97Fu/ZclVsdMBZhzfyxX2
 Ghw+top3VeSMrU0GQ8aRVsxFFdS69w+Jh7REiHNh+Q/77stTz6XmpXIaWEFSBHzQIXAEFonbzLW
 iT4hsbo2/+SIE3bD3nuWV/MkxuwB/o0P4
X-Gm-Gg: ASbGncvUQGd1ghlGQcyXtWCe2Kreqhq/KHj0ErJ0BSFT1pWzqx3y267XVgtG/xBJW7k
 mZ7rGPIcudVuKK3OVLo0W3KTADZYPMKz6
X-Google-Smtp-Source: AGHT+IEHIk4YZTlRCOD7EFNPA08i8EgjI1vgYc/2j4AlGFIqD05BLZY/tz02eqAwVn2WBVEaNn4uvf1ahCDgbZAgkzI=
X-Received: by 2002:a05:6402:50d2:b0:5cf:71ba:fc79 with SMTP id
 4fb4d7f45d1cf-5d01d41a166mr8933932a12.10.1732433536670; Sat, 23 Nov 2024
 23:32:16 -0800 (PST)
MIME-Version: 1.0
References: <CALXu0Uc=wOUbEaTzpfrYdn3Q8rXcaR-if84ZWXPgFJ1qxQbizQ@mail.gmail.com>
 <08d6a039-215c-c8e8-0280-15bc0ce28a43@jdrake.com>
In-Reply-To: <08d6a039-215c-c8e8-0280-15bc0ce28a43@jdrake.com>
Date: Sun, 24 Nov 2024 08:32:00 +0100
Message-ID: <CALXu0Ud1ne0F-K5fkHh_Ujp0BvZc6GUMmH3JTSAY_V+sCq8DsQ@mail.gmail.com>
Subject: Re: Corrupted file name in Cygwin - does Cygwin do a silly rename if
 a file is open?
To: cygwin@cygwin.com, ms-nfs41-client-devel@lists.sourceforge.net
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Cedric Blancher via Cygwin <cygwin@cygwin.com>
Reply-To: Cedric Blancher <cedric.blancher@gmail.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie.com@cygwin.com>

On Sat, 23 Nov 2024 at 17:47, Jeremy Drake <cygwin@jdrake.com> wrote:
>
> On Sat, 23 Nov 2024, Cedric Blancher via Cygwin wrote:
>
> > Good afternoon!
> >
> > Does Cygwin do a silly rename if a Cygwin file is open but gets
> > /bin/rm at the same time?
>
> Yes!  See function try_to_bin in winsup/cygwin/syscalls.cc:
>       /* Create unique filename.  Start with a dot, followed by "cyg"
>          transposed into the Unicode low surrogate area (U+dc00) on file
>          systems supporting Unicode (except Samba), followed by the inode
>          number in hex, followed by a path hash in hex.  The combination
>          allows to remove multiple hardlinks to the same file. */

That code is wrong.

bash -c 'printf ".\udc63\udc79\udc67#\n"' | iconv -f UTF-8
.iconv: illegal input sequence at position 1

334 RtlAppendUnicodeToString (&recycler,
335 (pc.fs_flags () & FILE_UNICODE_ON_DISK
336 && !pc.fs_is_samba ())
337 ? L".\xdc63\xdc79\xdc67" : L".cyg");

SAMBA is right to reject L".\xdc63\xdc79\xdc67", because it is not a
valid UTF-16 sequence. ReFS with validation, OpenZFS and so on will
all REJECT such file names, and neither can NFSv4 because file names
must be valid Unicode (even if nfsd would not validate then filesystem
being shared via nfsd will reject that).
So this can only work on ntfs, and only if it is not validating the
input UTF.16 sequence.

AFAIK FILE_UNICODE_ON_DISK means that the wchar_t sequences must be
valid UTF-16, and not just be a random sequence of 16bit values.

@Corinna Vinschen Could this sequence please be changed to a VALID
UTF-8 sequence, such as \u[fffc]\u[fffc]\u[fffc]? That might work with
SAMBA, ReFS, OpenZFS NFSv4, ...

Ced
-- 
Cedric Blancher <cedric.blancher@gmail.com>
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
