From owner-freebsd-dtrace@FreeBSD.ORG Wed Jun 4 05:16:21 2014 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E52B52CC; Wed, 4 Jun 2014 05:16:20 +0000 (UTC) Received: from nexus.ut.mephi.ru (nexus.ut.mephi.ru [85.143.112.92]) by mx1.freebsd.org (Postfix) with ESMTP id 68EAE2325; Wed, 4 Jun 2014 05:16:19 +0000 (UTC) Received: from [192.168.91.222] (sloan2.ut.mephi.ru [85.143.112.35]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: dyokunev@ut.mephi.ru) by nexus.ut.mephi.ru (Postfix) with ESMTPSA id 7FC3522E07A1; Wed, 4 Jun 2014 09:16:11 +0400 (MSK) Message-ID: <538EAAF1.1030005@ut.mephi.ru> Date: Wed, 04 Jun 2014 09:13:21 +0400 From: Dmitry Yu Okunev Organization: NRNU MEPhI User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: Mark Johnston Subject: Re: failed to resolve cwd: Unknown variable name References: <5388A227.7050805@ut.mephi.ru> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="WTcSU6j9kJi6KEoNeqsd4LqsOTug7NN08" X-LastMilter: passed X-LastMilter-Score: 0 Cc: "freebsd-dtrace@freebsd.org" X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jun 2014 05:16:21 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --WTcSU6j9kJi6KEoNeqsd4LqsOTug7NN08 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello. On 06/04/2014 06:28 AM, Mark Johnston wrote: > On Fri, May 30, 2014 at 11:22 AM, Dmitry Yu Okunev wrote: >> Hello. >> >> I cannot use dtrace in FreeBSD for my need due to next bug. >> >> It's said that there's a build-in variable "cwd" contains "the name of= >> the current working directory of the process associated with the curre= nt >> thread" [1] >> >> [1] http://docs.oracle.com/cd/E18752_01/html/819-5488/gcfpz.html >> >> 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 >=20 > Unfortunately, it looks like implementing this variable in FreeBSD > would be somewhat non-trivial. illumos (and presumably Solaris) caches > a full path to the file backing a given vnode, whereas FreeBSD only > caches file names and builds up a full path dynamically in > vn_fullpath1(). That's strange problem because audit already returns full paths in FreeBSD. It just uses "vn_fullpath*()"? > So one can get a bit of the way there with something ugly like >=20 > inline string cwd =3D > stringof(curthread->td_proc->p_fd->fd_cdir->v_cache_dst.tqh_first->nc_n= ame); >=20 > 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? >, so adding support for the cwd > variable would probably involve adding cache-only lookup code to > vfs_cache.c. That said, I'm not super familiar with this stuff, so I > could be missing something; this is just based on my previously > stymied efforts trying to get a full path for a vnode in a DTrace > probe, for example when trying to figure out which files are getting > fsync'ed. Ok. It's became much more clear. Thanks :) --=20 Best regards, Dmitry. --WTcSU6j9kJi6KEoNeqsd4LqsOTug7NN08 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJTjqr7AAoJEK2K5AyOMGeciQgP/0fdpNJ6OMvLFQvMKmTTL8U5 6UtL+RP3yciWdguzM1cgTGviMR3qIM7FGasmsG8hX0JzHjWjAtmrRvdpZoinRFqu sEJKq0Qm96AEqNrFTI++NobmXjQrod33WbFVmtiB/U34o4nRgjJqHLeSEUGiwIyo 8hK3Vrr8EmkEGmE2Q08J95I2qTqvJqSpyUZNRpX1FqqUSe6KYSc/NjccG+KwOe7g STSZ2REUhjVCzaaotnQmDYV5pHSeMSwARB+EgCTlyiv1pUfIuVMkvoRTMbpMpzOM kk+7LXl5h8Yz+l1Rxhr44mqRkikVCsWW7n6lSuLRElCzKCqeB+TuZRZta9S7PSFM fe+cxB01SAJId3LtIa2rYBj83KXe1oHp9bCcjCVHuR7Xz7y6qKrwrsoQYCaSsKAA r3mUbeeB47QzC75I8acYJ66qmn1yft+V0Lmgj7rRjKDn+Ij8uO8YLiRwU6920rBx 2eKIcQrN2RjH1Z4aPSDQk5ndbVnZsLuJkdfOEjM4DYYKfmbxU/5PTOxEeYn2xCIq J/xmz4ZKnlnIUZp2zev2ta8TJUWmZA3fVaLBpacUiLjDT+vBKpYXRPRi8B/Wk4s9 xMpUHyMmD2UDkp5RQnYNSag9UolUBq1WJj+iGu1ZG02OIR+DGWdQ7zMF7IjEhW/l x+gamePoQjtG1mD+htQm =F/W2 -----END PGP SIGNATURE----- --WTcSU6j9kJi6KEoNeqsd4LqsOTug7NN08--