Re: [PHP-DEV] Re: Current working directory and multi-threaded environments From: Andi Gutmans (andi <email protected>)
Date: 03/16/00

Guys,

I just commited a file php_virtual_chdir.c to our CVS. It has a main() in
it so you can compile it and run it.
I want to base the new virtual current working directory on this code,
which seems to work pretty well and normalizes the names of the
directories. Look at the main and see that it deals very nicely with all
sorts of scenarios.
There are two main issues with this code:
a) It doesn't *really* check if the directory exists.
b) strtok() isn't thread-safe in all machine's. I think we have the
necessary #define's to strtok_r for most platforms though. In any case, we
can either use something small we write ourselves.
c) Doesn't expand ~ yet.
d) No error handling yet.
e) no virtual_expand_filepath() yet, which is exactly the same as
the existing virtual_chdir. I think the real virtual_chdir() will probably
wrap this function and maybe do some other checks which chdir() requires.

I did this pretty quickly so don't flame me with optimizations etc..
I want to get the general idea accross (Although considering the ugliness
and complexity this kind of code usually has I think it's quite good).
Anyway, I hope you guys get the picture and I'd really want to move
forward this ASAP.

Andi

On Thu, 16 Mar 2000, Sascha Schumann wrote:

> On Thu, Mar 16, 2000 at 08:27:41AM -0500, rubys <email protected> wrote:
> >
> >
> > >> You are free to disagree with me, and I may have missed something or I
> > >> could very much be wrong. It just seems to me that unless more is done
> > >> than what you propose, examples such as the following will change
> > behavior:
> > >>
> > >> http://www.php.net/manual/html/function.readdir.html
> > >>
> > >> And that's an easy one. dl, ftp_get and others can be passed relative
> > >> paths. Fortunately, this list is finite. What would concern me most is
> > >> the extensions that interface to external code.
> > >
> > >Why does it change behaviour?
> > >
> > >The functions (not readdir, but opendir) will create an absolute path
> > >from the relative path passed to them.
> >
> > I must be missing something very obvious. Excerpts from
> > ext/standard/dir.c:
> >
> > PHP_FUNCTION(opendir):
> > _do_opendir(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
> >
> > static void _php_do_opendir:
> > dirp->dir = opendir((*arg)->value.str.val);
> >
> > >From what I can see, a relative path coded in the web page passes directly
> > through to a system call. That system call will be entirely unaware of
> > PHP's notion of a virtual (per request and/or thread) current directory,
> > and will proceed to use the "real" (per process) current directory.
>
> We are speaking about _future_ changes to the current source base,
> not about how it works today.
>
> - Sascha
>

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>