Re: [PATCH -V18 05/13] vfs: Support null pathname in readlink

Neil Brown
2010-08-20T10:04:19Z

On Fri, 20 Aug 2010 04:32:13 -0400
Christoph Hellwig <hch@infradead.org> wrote:

> Changing the interfaces of existing system calls to accept a NULL name
> which previously wasn't acceptable is not valid. Even for new system
> calls I think it's a bad idea. utimensat already has the most ugly
> code of all fs related system calls because of that.

Again, you have made an assertion without justifying it.
I disagree, I think it is perfectly valid.

The function would still return an error in every case that it previously
returned an error, because in every previous case the fd would not have
referred to a symlink so the new version will have nothing to perform a
readlink on when NULL is passed. The error would probably be EINVAL rather
than EFAULT but even that difference could be avoided if it was really
important (I doubt it is).

You only get different behaviour if the path name is NULL and the fd refers
to a symlink. This is a completely new situation for which there is no
precedent for how the syscall should behave. We are free to create whatever
behaviour is most consistent. I believe the proposed behaviour is the
correct one.

The code may be ugly, but I'm sure it can be tidied up, particularly if
several system-calls adopted the same calling convention.

NeilBrown