From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27101 invoked from network); 4 Aug 2000 18:16:15 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 4 Aug 2000 18:16:15 -0000 Received: (qmail 8216 invoked by alias); 4 Aug 2000 18:16:02 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12537 Received: (qmail 8207 invoked from network); 4 Aug 2000 18:16:01 -0000 From: "Bart Schaefer" Message-Id: <000804111549.ZM28988@candle.brasslantern.com> Date: Fri, 4 Aug 2000 11:15:49 -0700 In-Reply-To: <20000804091955.A4368@dman.com> Comments: In reply to Clint Adams "Re: PATCH: pathconf() again" (Aug 4, 9:19am) References: <1000804070216.ZM23696@candle.brasslantern.com> <20000804091955.A4368@dman.com> X-Mailer: Z-Mail Lite (5.0.0 30July97) To: Clint Adams Subject: Re: PATCH: pathconf() again Cc: zsh-workers@sunsite.auc.dk MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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.