Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: tail-dropping in files module mkdir



> It doesn't really matter whether it has any significance for absolute paths.

It does when we're trying to predict whether or not the entirety of mkdir -p
will fail.

Of course, it seems as though other mkdir implementations will mkdir()
all elements up to the failure point and happily leave them there, so
we'd be compatible if we removed the check.

> The primary use of the PATH_MAX constant in zsh is to determine the size of
> a buffer to allocate for copying a path name.  Even if we use realpath() or
> the equivalent to find the actual directory whose pathmax vaue we want, the
> actual string that is going to be copied into the resulting buffer does not
> change.

Agreed.  This is why I only touched the two places where PATH_MAX wasn't
being used for buffers.
 
> What this seems to imply is that we should always arbitrarily grow any
> buffer that will hold a path name -- not even attempt to determine a
> maximum size in advance -- and simply let the system calls fail when they
> will.

I wonder if performance will suffer significantly from this.

>            5.   If path or fildes refers to a directory, the value returned
>                 is the maximum length of a relative path name when the
>                 specified directory is the working directory.
> 
> Does this imply that (zpathmax("/") - 4 == zpathmax("/tmp")) is possible?

I believe it does.

> If so, we're wrong ever to compare strlen(dir) to zpathmax(dir).

Not if 'dir' is a relative, multi-directory path being passed to
mkdir -p.  That could conceivably fail if strlen(dir) > zpathmax(dir).
It could also conceivably fail if any of the directories to be made
have strlen(dirpart) > pathconf(dirpart,_PC_NAME_MAX), or if the
library is answering incorrectly on behalf of the kernel or other
limiting entities.

> You're assuming an implementation that restricts the size of a symlink to

I was merely throwing out possibilities.

Anyway, I assume that we can throw out the pathmax checks in the files module.
I'd think we can do the same with the parameter module, since _PC_PATH_MAX
is essentially useless there too.

That just leaves buffers to be dynamically grown, AFAICT.



Messages sorted by: Reverse Date, Date, Thread, Author