On a lighter note, I'd thought I post an "MDB puzzle" for the truly masochistic out there. I was going to post two, but the second one was just way too hard, and I was having a hard time finding a good test case in userland. You can check out how we hope to make this better over at the MDB community. Unfortunately I don't have anything cool to give away, other than my blessing as a truly elite MDB hacker. Of course, if you get this one right I might just have to post the second one I had in mind...
The rules are simple. You can only use a single line command in 'mdb -k'. You cannot use shell escapes (!). Your answer must be precise, without requiring post-processing through some other utility. Leaders of the MDB community and their relatives are ineligible, though other Sun employees are welcome to try. And now, the puzzle:
Print out the current working directory of every process with an effective user id of 0.
Should be simple, right? Well, make sure you go home and study your MDB pipelines, because you'll need some clever tricks to get this one just right...
Technorati Tags: OpenSolaris MDB
Posted by Bryan Cantrill on June 24, 2005 at 12:10 AM PDT #
Dammit, you ruined all my fun, and within the first hour too :-(
But you could've used a few more pointer dereferences to clean it up:
<tt>::walk proc p | ::print proc_t p_cred->cr_uid | ::grep .==0 | ::eval <=K | ::print proc_t p_user.u_cdir->v_path</tt>
Guess I will need the next puzzle (after I make you a community leader, of course).
Posted by Eric Schrock on June 24, 2005 at 12:25 AM PDT #
Posted by sitchai on June 24, 2005 at 02:42 AM PDT #
Posted by sitchai on June 24, 2005 at 02:53 AM PDT #
Posted by sitchai on June 24, 2005 at 02:59 AM PDT #
> ::walk proc p | ::print proc_t p_cred->cr_uid | ::grep .==0 | ::eval <lt;p=K fffffffffbc20a80 ffffffff8111f8f8 ffffffff81120520 ffffffff81121148 ffffffff84444c88 ffffffff835074b8Which are your pointers back to the relevant proc_t structures. <p /> Hopefully this explains it (and if I'm wrong I'm sure Eric can explain it properly).Posted by fintanr on June 24, 2005 at 04:28 AM PDT #
ffffffff81119528 ffffffff81116488 ffffffff81114010 ffffffff81117cd8 ffffffff8111bc30and the ::eval chunk should read ::eval <p=KPosted by fintanr on June 24, 2005 at 04:30 AM PDT #