failed to resolve cwd: Unknown variable name

Dmitry Yu Okunev dyokunev at ut.mephi.ru
Fri Jun 6 11:40:16 UTC 2014


On 06/04/2014 05:25 PM, Mark Johnston wrote:
> On Wed, Jun 4, 2014 at 1:13 AM, Dmitry Yu Okunev <dyokunev at ut.mephi.ru> wrote:
>> On 06/04/2014 06:28 AM, Mark Johnston wrote:
>>> On Fri, May 30, 2014 at 11:22 AM, Dmitry Yu Okunev <dyokunev at ut.mephi.ru> wrote:
>>>> But when I try to use the variable I get a failure:
>>>>> dtrace: invalid probe specifier syscall:::entry { printf("%s", cwd);
>>>> }: in action list: failed to resolve cwd: Unknown variable name
>>>>
>>>> You can get the same error by running a dtrace-script from official
>>>> FreeBSD distribution:
>>>>> /usr/share/dtrace/toolkit/opensnoop -c
>>> So one can get a bit of the way there with something ugly like
>>>
>>>     inline string cwd =
>>> stringof(curthread->td_proc->p_fd->fd_cdir->v_cache_dst.tqh_first->nc_name);
>>>
>>> to get the last component of a process' cwd (it needs a check for a
>>> missing cache entry), but I don't see any easy way to get at the full
>>> cwd. Calling vn_fullpath() in probe context would be a pretty bad idea
>>> since it may invoke VFS operations
>>
>> Hm. If it's performance problem only, then personally I can endure that.
>>
>> Can I use vn_fullpath*() in dtrace probes on current FreeBSD?
> 
> It's a safety thing. DTrace probes execute with interrupts disabled,
> so they're fairly limited in what they're allowed to do. Name
> resolution potentially requires the underlying filesystem code to read
> from disk or invoke an RPC, which cannot be done in probe context.

> Hence my suggestion of a cache-only lookup function that could be
> callable from within a probe.

Well. Here're two problems:
1. The solution returns only the last component of cwd. How to get the
rest? I can handle it myself (if it's possible), but if somebody already
have working solution that would be great :)
2. Is this solution steady to FreeBSD version updates? I think that this
headers can be changed with every major version.

-- 
Best regards, Dmitry,
head of UNIX-tech department NRNU MEPhI,
tel. 8 (495) 788-56-99, ext. 8255

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 880 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-dtrace/attachments/20140606/1c87c008/attachment.sig>


More information about the freebsd-dtrace mailing list