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

From: Neil Brown
Date: Fri Aug 20 2010 - 06:04:23 EST


On Fri, 20 Aug 2010 04:32:13 -0400
Christoph Hellwig <hch@xxxxxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/