Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: zasprintf



Bart Schaefer wrote:
>The last, special case is to create a "big enough" buffer for use by
>readlink().  In this case I think we could use lstat() to read the size
>of the link itself, and use that to allocate a buffer.  Does anyone
>know of an operating system where that would fail?

$ uname -sr
Linux 2.2.12-20
$ ls -l /proc/self/cwd
lrwx------   1 zefram   zefram          0 Sep 17 13:17 /proc/self/cwd -> /home/zefram
$

Some other bits of /proc do this too.  And on any system, a link could
be replaced between the lstat() and the readlink().  I think it would
be reasonable to use lstat() for a first guess, but we have to fall back
on an algorithm of increasing the buffer size until it's big enough.

-zefram



Messages sorted by: Reverse Date, Date, Thread, Author