In <[EMAIL PROTECTED]>, Reko Turja <[EMAIL PROTECTED]> typed:
> I've been playing with Open Watcom for a bit in FreeBSD and for a 
> while there's been one stumblim block for further advancement. Watcom 
> uses a method for storing program messages etc. where these messages 
> are stored as a "resource file" inside the executable itself. As the 
> commands are usually invoked without the canonical path, the tools 
> cannot find the resource portion stored inside.
> 
> This far I've been looking for some solutions from which none seem to 
> work too well. vn_fullpath (9) is running only inside kernel I think, 
> and with the approach using kvm_openfiles and kvm_getprocs I can only 
> get the command without the path (there are vnode etc. structures 
> inside the kinfo_proc structure, but those seem to be unavailable from 
> user space). Of course /proc might help in here, but I rather kept the 
> code compilable on very vanilla system.
> 
> Any pointers on how to proceed would be welcome.

In general, what you're asking can't be done on Unix.  The vn_fullpath
man page notes this by pointing out that it makes a "best effort", and
giving a list of reasons why it isn't reliable. Many of those apply in
your case as well.

However, you can also make a best effort. Check argv[0] to see if you
have an absolute path. If not, do what the shell would do to find the
executable - look for it on $PATH. Once you've found it, call
realpath(3) to canonicalize the path.

        <mike
-- 
Mike Meyer <[EMAIL PROTECTED]>          http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to