From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 4E0sHi0ZT2LPgwAAgWs5BA (envelope-from ) for ; Thu, 07 Apr 2022 19:02:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id MKejGy0ZT2IqUAEA9RJhRA (envelope-from ) for ; Thu, 07 Apr 2022 19:02:37 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 249EE3DE05 for ; Thu, 7 Apr 2022 19:02:37 +0200 (CEST) Received: from localhost ([::1]:47596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncVWm-0008Vw-9t for larch@yhetil.org; Thu, 07 Apr 2022 13:02:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncVWE-0008SM-FG for guix-patches@gnu.org; Thu, 07 Apr 2022 13:02:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39366) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncVWE-0003ID-4s for guix-patches@gnu.org; Thu, 07 Apr 2022 13:02:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ncVWD-00076O-Nu for guix-patches@gnu.org; Thu, 07 Apr 2022 13:02:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54762] [PATCH] home: symlink-manager: Use no-follow version of file-exists?. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 07 Apr 2022 17:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54762 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxime Devos , 54762@debbugs.gnu.org Received: via spool by 54762-submit@debbugs.gnu.org id=B54762.164935089125712 (code B ref 54762); Thu, 07 Apr 2022 17:02:01 +0000 Received: (at 54762) by debbugs.gnu.org; 7 Apr 2022 17:01:31 +0000 Received: from localhost ([127.0.0.1]:33263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncVVj-0006gP-C4 for submit@debbugs.gnu.org; Thu, 07 Apr 2022 13:01:31 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:38563) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncVVh-0006Yc-0J for 54762@debbugs.gnu.org; Thu, 07 Apr 2022 13:01:29 -0400 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id 5DBD5FF803; Thu, 7 Apr 2022 17:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1649350882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Dau7WYvrcll1GIJv7Ml+rRhVRELc3EXwb2P+YCr3GbQ=; b=o2A2GseDrgR1yf2Kgiv6qjyxDewtKSJehfOBJMgj/rkYZIQCNQSkgjxzJsl1JCT7R7Jacs a4bs63s04ACHJo2GCK0uHjq6vhZj4uzwiirr3leMoOusJ+DzcRA/E3GwP4NZsK20DbJcMj WNvfu+nUxlGbtU3cuuNmtY9vraKLO9YuF5ZdHaZF5VdN1+mVfu1gMX0t7E+pTVc1rH4rsP Fu5Yf2um+ijqdqM8v56xrpgJF7aH2LNOPvtOIjeOQ1g5BDccZn/afeSEPWdAac8Ga2O91c Awx5a/toffZNOZGKII/3W2SpOEYVZHB+1gDLAVba3pU2oKXrKSTBwZ2RhjxcsQ== From: Andrew Tropin In-Reply-To: <67cab598e57ecf7cf930d4b2d0568fd2f2f6f95d.camel@telenet.be> References: <87zgkxxnvv.fsf@trop.in> <67cab598e57ecf7cf930d4b2d0568fd2f2f6f95d.camel@telenet.be> Date: Thu, 07 Apr 2022 20:01:18 +0300 Message-ID: <87bkxc6d5t.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1649350957; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=Dau7WYvrcll1GIJv7Ml+rRhVRELc3EXwb2P+YCr3GbQ=; b=u/xMQIpumhoHe/tJ0BpFj0GT2msIPL7VQHqTMrCv3L6/E35LintXccM8jb11I2RpBztWJV QKItz5Li38W9tEx2jA3+JyVElMhzUwsPQxDEUNM1if0mGICHbzrz47OfpfX7Ta15hubSKN Ixt/wh5ySRg3L9J3nBOdFbQXQOqISn0INh9NY2WP+eGLB2Rj/SSPPKSZhkF7QLzoIOQBom +aemGzYINJt57HKBp3oh+RPPMFAx5VrP6XXF8GVHLf3K7Oh4K5SoxfJlxx1IW7996r43Jy TxNQxpmcKSz1ro3R+ztkkLCLZCytDT1D6jobtBjr59wxqfnETRHApKuma0peLQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649350957; a=rsa-sha256; cv=none; b=iRB+R0l49oy9qgRDyJVx42YM+T0q1I1YKwOobUgCeOrQ9UJi3PG2SJAmR/KziD5kC9SuDV zcY7/YkUwhg3TJhGZQkQllaFV2YBn8FcflC8yGdJ/+IDtIhSzBYaXakdLPjeYyXMknNJ1c HLQf5oz/rpOlzNDNg6xc+5lBFiZALWkav0u7pSwt0Bc1DyiWehIASN9XGggNimMqy1qfbX 6ISf79fwrUjRm2H7q2nxF0wiq0Kdz5fXThB450DdGd6SYKId5kh+5L3YoGn32cirJ/4KW/ ZNQ9zZvSSk6j7I02K7p7jq5K++Pmr0s76tQU6UzzvllXL8J/pLmOMmCn/yaw0w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=o2A2GseD; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 0.24 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=o2A2GseD; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 249EE3DE05 X-Spam-Score: 0.24 X-Migadu-Scanner: scn1.migadu.com X-TUID: 23C3r2v1HXNO --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2022-04-07 14:28, Maxime Devos wrote: > Andrew Tropin schreef op do 07-04-2022 om 11:22 [+0300]: >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (define (no-follow-fil= e-exists? file)=20 >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "Return #t= if file exists, even if it's a dangling >> symlink." >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (or (file-= exists? file) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 (and=3D> (false-if-exception (lstat file)) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (lambda (x) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (equa= l? (stat:type x) 'symlink))))) > > Can't this be simplified to > > (define (no-follow-file-exists? file) > (false-if-exception (lstat file))) > Idk how file-exists? works internally, but still expect it to be more efficient than lstat. That's why I decided to use lstat only as a "fallback" option in `or` statement. > ? Also, do you want to ignore _all_ exceptions, or only the ENOENT and > maybe ENOTDIR system-error? > > (catch 'system-error > (lambda () (lstat file) #t) > (lambda e > (if its-a-ENOFILE > #f > (apply throw e)))) > > More concretely, why is ENOMEM, ENAMETOOLONG and EACCESS ignored here? You are right, we are interested only in ENOENT here. AFAIK, ENOMEM shouldn't happen here, but some other can, still we do not handle them and make function behave the same way as file-exists? do and just return #f in such cases. However, I'm not sure if file-exists? is a good example to follow. Anyway in current implementation handling other codes in no-follow-file-exists? will not save the day, in case of EACCESS it doesn't really matter if it will be thrown during the check of existence or during creation of symlink. But we probably can later rework the whole symlinking process: check that we have premissions to all files, we are interested in, and only after that cleanup, backup and symlink. > > Greetings, > Maxime. =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmJPGN4PHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6wXBcP/0qJyjIqMZKXH8LHqJoPD3pKz+IU0hClGyih dpY0/skz2+9JCESryNa4a1sxvYtXyQM0NttL2MWA9PMglQe9XNxcUAcclnkMH3BX 4NKQ/aOMR9vL6KwpIc0h8nPB3CPPyCnSLrSs/DbCbVGQuFP3S61V2p1d7zHpWqK8 i8+c3eYaYBwmzbqSezm57QcZOBZWzo8XISY0MM/K3iZNshf/KE84Gsujl3WJenqV ELYH4aJDpw+JMtgJhOjO4TTCnB+fxHjlcwwo1Nk8idq3d7iAwj6PyM2zxhTMcsZn 8nWiRXhjpVMWdkRQTuRjxU2af6TPD2tQPKDn/jupai2bl8wWQTRAlUfBDbdzm8M7 Ka6rjXllY9KVvld30IPrkqe1DKOKOPTJKMkfM8Ez5Brp5VbYHP0ubfiO+4FAKslt MdqHw6mgeFDPwRS5QtqDJgHALKoGKTncbMrSyQm3btWuccXSexqgIR/7C5/pGJz7 GTrg4nmKRprbyNXK1u7heTFrNG9UF0H9jUmXHwdSB8x3cIzYA6QVWXwDekIoMLTs jdngs3F6RqD/jgKstErE8D/0TjgA+bWNzCzcw3kad37hr86eJN3dkJcsNeb57Ejr ixCC1u56W6LEHsvAzNf5fweRGVam49nLQCuN+mJ5U4czMPyABUPfGJImihA+ZrFN gijd1Js6 =kTwY -----END PGP SIGNATURE----- --=-=-=--