Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Jun 1998 00:18:04 -0700
From:      Mike Smith <mike@smith.net.au>
To:        Mike Smith <mike@smith.net.au>
Cc:        Willem Jan Withagen <wjw@surf.IAEhv.nl>, current@FreeBSD.ORG
Subject:   Re: Variant Link implementation (Was: Re: lorder problem: ....... ) 
Message-ID:  <199806080718.AAA09778@antipodes.cdrom.com>
In-Reply-To: Your message of "Mon, 08 Jun 1998 00:12:57 PDT." <199806080712.AAA09745@antipodes.cdrom.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> 	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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806080718.AAA09778>