From owner-freebsd-current Mon Jun 8 01:22:50 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA20869 for freebsd-current-outgoing; Mon, 8 Jun 1998 01:22:50 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from antipodes.cdrom.com (castles177.castles.com [208.214.165.177]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA20864 for ; Mon, 8 Jun 1998 01:22:48 -0700 (PDT) (envelope-from mike@antipodes.cdrom.com) Received: from antipodes.cdrom.com (localhost [127.0.0.1]) by antipodes.cdrom.com (8.8.8/8.8.5) with ESMTP id AAA09778; Mon, 8 Jun 1998 00:18:04 -0700 (PDT) Message-Id: <199806080718.AAA09778@antipodes.cdrom.com> X-Mailer: exmh version 2.0zeta 7/24/97 To: Mike Smith cc: Willem Jan Withagen , current@FreeBSD.ORG Subject: Re: Variant Link implementation (Was: Re: lorder problem: ....... ) In-reply-to: Your message of "Mon, 08 Jun 1998 00:12:57 PDT." <199806080712.AAA09745@antipodes.cdrom.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 08 Jun 1998 00:18:04 -0700 From: Mike Smith Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > buf = zalloc(namei_zone); > si = 0, ci = 0, di = 0; > while (si < linklen) { > /* component leader? */ > if ((cp[si] == '$') && > (si < (linklen - 2)) && > (cp[si + 1] == '{')) { > ci = si + 2; > while (ci < linklen) { > if (cp[si] == '}') { > cp[ci] = 0; > switch (vlink_xlate(cp + si + 2, > buf, &di)) { > case 0: /* OK */ > si = ci + 1; > di += k; > continue; > case 1: /* no room to expand */ > return ENAMETOOLONG; > default:/* not found */ > break; > } > } > } > } > buf[di++] = cp[si++]; > } > linklen = di; > if (ndp->ni_pathlen > 1) > zfree(cp); > } > cp = buf; > > Note that the memory management here is actually bogus; you should > *always* zalloc the buffer for the VOP_READLINK, and assign buf based > on ndp->ni_pathlen as is currently done for cp. Once you hand it over, > the management for cp as it currently is is fine. (remember to dispose > of buf as well as cp in the error case). > > The vlink_xlate function is where the lookup is done; you will probably > want to pass p (current proc) to it as well at some stage. Whoops; just to clarify; vlink_xlate(tok, dbuf, &dbofs) copies the value of the token at (tok) into (dbuf) at (dbofs) presuming that (dbofs) would not exceed the allowed size, updates (dbofs) and returns 0 (all OK), 1 (not enough room) or 2 (no translation for tok available). -- \\ Sometimes you're ahead, \\ Mike Smith \\ sometimes you're behind. \\ mike@smith.net.au \\ The race is long, and in the \\ msmith@freebsd.org \\ end it's only with yourself. \\ msmith@cdrom.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message