in reply to Simple Path Cleanup
Using cd/cwd will follow soft links in the path and yield a path without soft links. As you say, there are other ways to deterime such path without changing the current working directory, but it is not clear that they will be any faster as the same underlying operations will be required. You may find that the system functions are as fast as any available.
Hard links are not so easily dealt with. Any path through hard links is equally valid and there will be no easy way to distinguish between a seemingly innocuous path (e.g. /some/irrelevant/file ) and the path of a critical file (e.g. /etc/passwd or / ). With hard links, you do have the certainty that they do not traverse file systems, so you can at least reliably determine what file system a path refers to. This might be adequate if, for example, all the paths you are checking should be on a file system that contains non-critical data only. Otherwise, it is hard to imagine any certain solution other than comparing the inode number of your subject path with the inode numbers of all critical files and directories on the same file system.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Simple Path Cleanup
by almut (Canon) on May 10, 2009 at 09:41 UTC | |
by ig (Vicar) on May 10, 2009 at 10:34 UTC |