[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] [REPOST] Simplily linux-user/path.c
From: |
Thiemo Seufer |
Subject: |
Re: [Qemu-devel] [PATCH] [REPOST] Simplily linux-user/path.c |
Date: |
Fri, 23 Feb 2007 16:58:56 +0000 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Kirill A. Shutemov wrote:
> Fixed version of the patch in the attacment. Please, comment.
[snip]
> /* Look for path in emulation dir, otherwise return name. */
> const char *path(const char *name)
> {
> + char *newname = (char *) alloca(strlen(pref)+strlen(name)+1);
> + struct stat buf;
> /* Only do absolute paths: quick and dirty, but should mostly be OK.
> Could do relative by tracking cwd. */
> - if (!base || name[0] != '/')
> - return name;
> + if (!pref || name[0] != '/')
> + return name;
> +
> + strcpy(newname,pref);
> + strcat(newname,name);
>
> - return follow_path(base, name) ?: name;
> + return stat(newname,&buf) ? name : strdup(newname);
> }
This leaks memory allocated by strdup(). Also, the old code tries to
avoid syscalls by memorizing the paths. AFAICS we should do some
caching here.
Thiemo