Solaris Dynamic Tracing Guide

cleanpath()

string cleanpath(char *str)

cleanpath() creates a string that consists of a copy of the path indicated by str, but with certain redundant elements eliminated. In particular “/./” elements in the path are removed, and “/../” elements are collapsed. The collapsing of /../ elements in the path occurs without regard to symbolic links. Therefore, it is possible that cleanpath() could take a valid path and return a shorter, invalid one.

For example, if str were “/foo/../bar” and /foo were a symbolic link to /net/foo/export, cleanpath() would return the string “/bar” even though bar might only be in /net/foo not /. This limitation is due to the fact that cleanpath() is called in the context of a firing probe, where full symbolic link resolution or arbitrary names is not possible. The returned string is allocated out of scratch memory, and is therefore valid only for the duration of the clause. If insufficient scratch space is available, cleanpath does not execute and an error is generated.