Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: pathconf() again
- X-seq: zsh-workers 12537
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Clint Adams <schizo@xxxxxxxxxx>
- Subject: Re: PATCH: pathconf() again
- Date: Fri, 4 Aug 2000 11:15:49 -0700
- Cc: zsh-workers@xxxxxxxxxxxxxx
- In-reply-to: <20000804091955.A4368@xxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <1000804070216.ZM23696@xxxxxxxxxxxxxxxxxxxxxxx> <20000804091955.A4368@xxxxxxxx>
On Aug 4, 9:19am, Clint Adams wrote:
> Subject: Re: PATCH: pathconf() again
> > Random questions: Can someone explain how one is supposed to determine a
> > useful buffer size for e.g. readlink() if pathconf() returns `unlimited'?
>
> What I was told is that one should malloc an arbitrary amount, say 512
> bytes, then realloc to double the buffer size if it's too small. Rinse
> and repeat.
But ... readlink() doesn't have any provision to "read more of the link"
and doesn't tell you if it truncated what it did read.
In that specific instance, I suppose you could allocate space based on
the st_size returned by lstat(), but the general solution feels sloppy
at best.
> > For that matter, how does one even know what directory name to pass into
> > pathconf() in that case?
>
> I assume you want the PATH_MAX of the filesystem where the link lives,
> and not the psychically-determined filesystem to which it's pointing.
Only if it's a relative rather than absolute link.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author