Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jDrs9-0001c6-24 for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2020 15:41:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDrs7-0003vR-QB for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2020 15:41:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jDrs7-0003vK-AC for pgsql-hackers@lists.postgresql.org; Mon, 16 Mar 2020 15:41:43 +0000 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jDrs4-0004fl-Fs for pgsql-hackers@postgresql.org; Mon, 16 Mar 2020 15:41:42 +0000 Received: by mail-qk1-x744.google.com with SMTP id q17so2263860qki.0 for ; Mon, 16 Mar 2020 08:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=OqjMQONz659QPIbe9PlkwC0OUM++IiKoNHgp2f/i+5A=; b=wV/WnA/oyUOw9pVD2pewjYJaCTB89UbmHXVVU0P08hZSKhDmQMfb2BqJjBTTU/Lr9R 4IF+ylIZM/mm6cH9D2nj+T3e0XR0wNgTzMczF+wUwRlc/IeDWqUeymi6znEvTVoJ9clm ZDOjs3Gti69MBt44VPhlIEGMtkzB54qpRZNGCIlHNCPxK+dGGpPmwxLaJB0/7ZYh6H8q xxfrhnyp9LOWd9nGJlBQFFe2ehQWbPV2vMzihe+JWHcB2QzawCtD4r3C3IfqV7wNUf0J k+fm49SekKYniCi4gQUwXGexhN6p/z+CcKUG7yy3GTG8LHqJc3wlSHfsRIfqUgKwzbRE 84LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=OqjMQONz659QPIbe9PlkwC0OUM++IiKoNHgp2f/i+5A=; b=Qv33YrDgURzEjhnsh6VtluJIQDyzEjpQN3adwx8PcqqlOiPm1IGBh++ZcQCvEbpM0p To4h7t/aEAejqC0wfkPPN0wXmelFLDU8aZnfCB8QzV5M6i7a8nEDv0Xs9m1CUosSLqnp sH/pCYps+gv8eGGqg77u0BxkMzT2r0CtjkpqJ71JGtXUzeeP0rG2sGQPK7Meu3Qsem3r OSKb/Z2hvEkRjqjxIF1E780sHc5VRNvhBvFbiAVtauthbWMUh2kruBfpzDm9+xtGaJ3D oexOCroP2+sy6O4Gr7lVdFaHnzY8auVifext/kXxyyvqVZunpF/lugmEUxSiJEYJ0SZd 9MXQ== X-Gm-Message-State: ANhLgQ1H4kkIg7zJ4ST3S1+9GIxyR5zdyLLUfahwvZdie0XuruBJFMlF fSDKdFzA8wiCwfVBiv6oqzIZuA== X-Google-Smtp-Source: ADFU+vtyYmcXU7ok7NqFygzVsqZccwS98su1aoMZ4iXFVdUHPEC19gICGXZ9IGTcD7qcHc+gFXGwbg== X-Received: by 2002:a37:a4d6:: with SMTP id n205mr297509qke.352.1584373299150; Mon, 16 Mar 2020 08:41:39 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id n74sm13846419qke.125.2020.03.16.08.41.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Mar 2020 08:41:37 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 61305800DFD; Mon, 16 Mar 2020 10:41:36 -0500 (CDT) Date: Mon, 16 Mar 2020 10:41:36 -0500 From: Justin Pryzby To: Fabien COELHO Cc: Alvaro Herrera , David Steele , pgsql-hackers@postgresql.org, "Bossart, Nathan" , Thomas Munro , Tom Lane Subject: Re: pg_ls_tmpdir to show directories and shared filesets (and pg_ls_*) Message-ID: <20200316154136.GK26184@telsasoft.com> References: <20200303202313.GA28076@alvherre.pgsql> <20200305161838.GJ684@telsasoft.com> <20200306233507.GN684@telsasoft.com> <20200307214010.GB1357@telsasoft.com> <20200310183037.GA29065@telsasoft.com> <20200313131232.GO29065@telsasoft.com> <20200315212729.GC26184@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Mar 16, 2020 at 04:20:21PM +0100, Fabien COELHO wrote: > > About v11, ISTM that the recursive function should check for symbolic links > and possibly avoid them: > > sh> cd data/base > sh> ln -s .. foo > > psql> SELECT * FROM pg_ls_dir_recurse('.'); > ERROR: could not stat file "./base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo/base/foo": Too many levels of symbolic links > CONTEXT: SQL function "pg_ls_dir_recurse" statement 1 > > This probably means using lstat instead of (in supplement to?) stat, and > probably tell if something is a link, and if so not recurse in them. Thanks for looking. I think that opens up a can of worms. I don't want to go into the business of re-implementing all of find(1) - I count ~128 flags (most of which take arguments). You're referring to find -L vs find -P, and some people would want one and some would want another. And don't forget about find -H... pg_stat_file doesn't expose the file type (I guess because it's not portable?), and I think it's outside the scope of this patch to change that. Maybe it suggests that the pg_ls_dir_recurse patch should be excluded. ISTM if someone wants to recursively list a directory, they should avoid putting cycles there, or permission errors, or similar. Or they should write their own C extension that borrows from pg_ls_dir_files but handles more arguments. -- Justin