comp.unix.programmer
Re: [GNU/Linux] obtaining a filesystem-relative filename
Ivan Shmakov <ivan_at_gray.siamics.net> writes:
> Do I understand it correctly that to obtain a
> filesystem-relative filename (such as: jrh/foo for /home/jrh/foo
> when /home is on a separate filesystem), I need to resolve all
> the symbolic links first, and then to check /etc/mtab for a
> prefix matching the filename in question? The filename is then
> stripped of the prefix found.
Having resolved links you could work backwards through the list of path
components stating each to find the point at which st_dev changes,
thereby eliminating the dependency on mtab - the same technique as
traditional getcwd().
--
http://www.greenend.org.uk/rjk/
Written by Richard Kettlewell
19/10/2011 11.39.55
Check some pics on this site!
23/05/2012 22.32.49