From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162443AbbKTJ7X (ORCPT ); Fri, 20 Nov 2015 04:59:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47496 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751007AbbKTJ7P (ORCPT ); Fri, 20 Nov 2015 04:59:15 -0500 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20151119232635.GI22011@ZenIV.linux.org.uk> References: <20151119232635.GI22011@ZenIV.linux.org.uk> To: Al Viro Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , linux-security-module@vger.kernel.org, miklos@szeredi.hu Subject: Re: [RFC] readlink()-related oddities MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <22312.1448013545.1@warthog.procyon.org.uk> Date: Fri, 20 Nov 2015 09:59:05 +0000 Message-ID: <22313.1448013545@warthog.procyon.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Al Viro wrote: > 3) normally, readlink(2) fails for non-symlinks. Moreover, according to > POSIX it should do so (with -EINVAL). There is a pathological case when > it succeeds for a directory, though. Namely, one of the kinds of AFS > "mountpoints". All AFS mountpoints are magic symlinks that are specially interpreted by the client as far as I'm aware. I'm not sure why the designers didn't just select a different file type for them, but they didn't. Unfortunately, it means that iget has to read the contents of the symlinks :-/ > stat(2) reports those as directories, stepping into them leads to > automounting a directory there (why do we have ->open() for them, BTW?). I think I put that in to make sure the open() syscall returned EREMOTE rather than another error if you tried to open it. It can probably be removed because with the d_automount code you can't ever get there I think - unless you can pass AT_NO_AUTOMOUNT to openat(). > How the hell is userland supposed to guess to call readlink(2) on those > suckers to get the information of what'll get automounted there if we step > upon them? There's an AFS userspace command that could be used to query a mountpoint that was going to use it. However, I suspect readlink() will now always trigger the automount. This is one of the things OpenAFS uses pioctl() for - but since I'm not allowed to add that to the kernel, I have to find some other way of doing it. > And could we please get rid of that kludge? David? Sure. David