?

Log in

No account? Create an account
megaadm -- getting cleaner - brad's life — LiveJournal [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

megaadm -- getting cleaner [Nov. 13th, 2004|06:29 pm]
Brad Fitzpatrick
[Tags|, ]

Cleaned it up, and started making it fetch adapter info:

http://www.bradfitz.com/hacks/megaadm/megaadm-0.01.pl
LinkReply

Comments:
[User Picture]From: scosol
2004-11-14 04:18 am (UTC)
hahaha you japh :p
(Reply) (Thread)
From: (Anonymous)
2004-11-14 05:11 am (UTC)

get_c_pointer()

I thought you could obtain pointers by using the 'P' format argument to pack? Then again, I obviously don't do as much of the perl voodoo as you...
(Reply) (Thread)
[User Picture]From: brad
2004-11-14 05:38 am (UTC)

Re: get_c_pointer()

Oh wow ... I never knew about that. Thanks!
(Reply) (Parent) (Thread)
[User Picture]From: edm
2004-11-14 07:01 am (UTC)

Re: get_c_pointer()

Some experimenting with pack("p") (and pack("P") -- it seems to make no difference on the pack() side) suggests that it generates a value which could feasibly be a pointer to the structure. I say feasibly because Programming Perl doesn't seem to confirm it does what we think, and I can't get your get_c_pointer() example to work with Perl 5.6.1 on i386 or Perl 5.8.4 on sparc (the two 32-bit test platforms I've got easy access to).

Hopefully pack("p") works for you, as it'll allow you to fix both a security bug (write into fixed filename without checking if it's a symlink) and a reliability bug (redirect stderr to a file, never close the file, never restore the original stderr). (And yes I know it's a hack-in-progress, but it's never too early to fix security problems :-) )

I admire your mission to develop an open source management tool for the raid cards (in general the management tools for raid cards are either non existant or suck -- I have several wrappers around the supplied tools to make them do something vaguely sensible). But I have to wonder if Perl is the right language to use... (and at the design of the kernel API for the cards).

Ewen
(Reply) (Parent) (Thread)
[User Picture]From: brad
2004-11-14 07:19 am (UTC)

Re: get_c_pointer()

I replaced it with pack("P") and it's working fine. Both "P" and "p" did the same from what I could tell, too, but "P" sounded closer to what I want. I'll investigate the Perl source later.

(and yeah, I was aware my tempfile and stderr-losing... just didn't care... I had planned to save/restore stderr and use File::Temp)

If I hit serious roadblocks w/ Perl I'll do it in C, but so far I'm just not seeing the point... things are cruising along with the Perl implementation, now that the major issues have been overcome.
(Reply) (Parent) (Thread)