Overview
| Artifact ID: | f42130bad5793565e957d64526f819ada0f1f762 |
|---|---|
| Ticket: | 1064247fffffffffffffffffffffffffffffffff
filesystem-7.8 fails on darwin without NO_REALPATH |
| User & Date: | das on 2004-11-11 01:31:22 |
Changes
- assignee changed to: "vincentdarley"
- cmimetype changed to: "text/plain"
- comment changed to:
filesystem-7.8 fails on darwin when realpath() is used, and succeeds otherwise. The failure is that cd simplefs:/simpledir succeeds but does not change the current directory I've tracked this down to differing behaviour in TclpObjNormalizePath() when normalizing 'simplefs:/simpledir' depending on NO_REALPATH being defined: - with NO_REALPATH, the "slow way" of getting the subpath to be normalized at the start of TclpObjNormalizePath() fails at access() on the first path component 'simplefs:', which leads to the correct return value of 'simplefs:/simpledir' as expected. - without NO_REALPATH, the fast way of using realpath() to get the subpath to be normalized calls 'realpath("simplefs:")' which returns the absolute path "[pwd]/simplefs:", this leads to TclpObjNormalizePath() returning the incorrect value '[pwd]/ simplefs:/simpledir'. the result of this path normalization is used to identify the filesystem owning the path in question, this fails to find the simplefilesystem in the second case which ends up leading to the test failure the crux of the issue stems from the behaviour of realpath() on relative paths. The BSD spec says that realpath() always returns an absolute path, and that all except the last path component given must exist (c.f. manpage below). This is exactly what seems to happen in this case on darwin, so it looks like the design of TclpObjNormalizePath() didn't take BSD realpath into account? according to the caveats in the manpage, solaris realpath() doesn't behave in the same way, this may also be true on other platforms? as I've proposed in the past, maybe a compat/ implementation of realpath() is needed that behaves the same on all platforms? this would also solve the non-thread safeness issue of realpath() on darwin that requires NO_REALPATH to be defined in the threaded build. REALPATH(3) BSD Library Functions Manual REALPATH(3) NAME realpath - returns the canonicalized absolute pathname LIBRARY Standard C Library (libc, -lc) SYNOPSIS #include <sys/param.h> #include <stdlib.h> char * realpath(const char *pathname, char resolved_path[PATH_MAX]); DESCRIPTION The realpath() function resolves all symbolic links, extra ``/'' charac- ters and references to /./ and /../ in pathname, and copies the resulting absolute pathname into the memory referenced by resolved_path. The resolved_path argument must refer to a buffer capable of storing at least PATH_MAX characters. The realpath() function will resolve both absolute and relative paths and return the absolute pathname corresponding to pathname. All but the last component of pathname must exist when realpath() is called. RETURN VALUES The realpath() function returns resolved_path on success. If an error occurs, realpath() returns NULL, and resolved_path contains the pathname which caused the problem. ERRORS The function realpath() may fail and set the external variable errno for any of the errors specified for the library functions lstat(2), readlink(2) and getcwd(3). CAVEATS This implementation of realpath() differs slightly from the Solaris implementation. The 4.4BSD version always returns absolute pathnames, whereas the Solaris implementation will, under certain circumstances, return a relative resolved_path when given a relative pathname. SEE ALSO getcwd(3) HISTORY The realpath() function first appeared in 4.4BSD. BSD February 16, 1994 BSD - foundin changed to: "obsolete: 8.5a2"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "das"
- subsystem changed to: "37. File System"
- title changed to: "filesystem-7.8 fails on darwin without NO_REALPATH"
- type changed to: "Bug"