Whoever wrote the tsearch/tfind/tdelete/twalk functions for libc clearly
stopped thinking about how it would be used. The only way I can see to iterate
the tree is to use twalk, which doesn't let you pass any extra arguments to
your provided action method.
This sucks if, for example, you wanted to get a list of all entries in the tree in a threadsafe or multiplicity-safe way.
Some workarounds include:
- Every time you insert, add the same structure to an array.
- Use something that supports sane iteration (bdb, for example).
I looked into using bdb for some things, but the tree I wanted to iterate over
most was a structure that held, among other things, a function pointer.
Function pointers are magical and special and are held in a place in memory you
can't simply make a copy of. If you try to store a function pointer in an
in-memory BDB database, the value that comes out of your query will be
different than the function pointer.
This bdb code sample attempts to store a function pointer in bdb. The output is:
stored: 607a70
actual: 4005e8
The value changed because copying a function pointer doesn't work.
There's a workaround here that might be useful - dlopen(). Any functions I want
to store in bdb, I would store by string name and fetch the function pointer
with dlsym().
This
dlopen example shows how to dlopen yourself and fetch a function by string
name.
Fun with pointers.
Comments: 0 (view comments)
Tags: libc, tsearch, bdb, function pointers, c
Permalink: /geekery/libc-tsearch-bdb-and-function-pointers
posted at: 03:47
I spent some time putting love into cgrok (uses libpcre) tonight.
- Logging facility to help in debugging. Lets you choose what features you
want logging (instead of lame warn/info/number log levels)
- Added string and number comparison predicates
- Wrote a few more tests which uncovered some bugs
I also broke 2000 revisions in subversion. Yay.
Sending test/Makefile
Transmitting file data .
Committed revision 2001.
Comments: 0 (view comments)
Tags: subversion, progress, grok, cgrok, pcre, libpcre
Permalink: /geekery/svn-two-thousand
posted at: 07:02
I was happily moving along doing windows automation tonight, when suddenly
sysprep broke. I'm sure I killed it by accident, or something. Googling around
for the error found this
knowledgebase article explaining that there is no way to recover and,
quote, "When you experience this error, you must re-create the image. You
cannot correct the problem with the image."
Fuck that.
If you read the docs on using sysprep/wsim/windows aik/whatever, they all point
you at building a 'reference computer' which entails lots of manual work
modifying settings and installing things. Sysprep can make useless all of your
precious work? Sweet!
I'm just glad most of the things I've done to this system were automated so I
can just reinstall and rerun the scripts.
Comments: 0 (view comments)
Tags: wtf, sysprep, microsoft, vista
Permalink: /geekery/sysprep-might-cause-early-balding
posted at: 07:28
jls(~) % sudo yum install subversion
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Package subversion-1.4.6-7.x86_64 already installed and latest version
I had hoped (hope is not a strategy) Fedora would have given me svn 1.5 by now. Nope.
To get svn 1.5, rather than ask fedora or google, I just built it myself. I
needed to 'yum install neon-devel' and used './configure --with-neon=/usr
--with-ssl --with-zlib=/usr/lib' to configure subversion. Otherwise the
build/install went fine.
Huzzah!
Comments: 2 (view comments)
Tags: fedora, svn, subversion, linux, hope is not a strategy
Permalink: /geekery/fedora-9-subversion-1.5
posted at: 21:21
I have a confession: I actually like Vista. It has some nice new features.
Vista beats the pants off of XP. Both my work laptop and a recently-purchased
workstation at home run Vista (business and home premium, respectively) and
I've never looked back. I can't tell you if it's slower, or if it eats more memory, because I haven't thought about it (because it's not a problem).
I didn't like it at first. They moved everything. Normal control panel
operations were totally moved around, icons changed, start->run went away. It
took me atleast a week to stop looking for folders like "My Computer" or "My
Documents" which had been renamed simply "Computer" and "Documents".
The two best things so far are search related: the start menu search box and
the search box in the control panel are both awesome. Forget futzing around
with %PATH%, the start menu search box will just search for things in the start
menu as you type (and perhaps other areas); certainly a nice touch.
The control panel search is awesome, and actually helped me stop asking "Where
the F is network configuration?"-type questions. I type 'disable uac' and get this result - so useful.
Aero is meh, but it's not displeasing. The task switcher showing a thumbnail of
the actual window is kind of neat and slightly helpful, too. I installed virtuawin to give me multiple
desktops and everything's been peachy.
Comments: 0 (view comments)
Tags: microsoft, vista, os, operating systems
Permalink: /geekery/vista
posted at: 19:12
Woot. Another Yahoo! Hackday :)
Same basic structure as the one held 2 years ago at the same location (Y!'s
Sunnyvale campus): free concert, free api tutorial sessions, and a 24-hour idea-to-implementation challenge.
The only bad part, which was the only bad part about the last hackday, was the
presence of startup companies presenting their product as their 'hack'.
This year's overall winner was Xoopit which won simply on not a hack but on
Xoopit's product, which has been around for a while. Maybe I was already
annoyed at Xoopit for plastering their stickers all over Yahoo's cafeteria.
Big frownyface to all the companies who used hackday submissions as an
advertising feature.
Ignoring those silly people, the rest of the hackday festivities were quite
good. The concert was a bit strange but still very entertaining - Girl Talk
puts on quite a show. My favorite hacks, mostly because of the entertainment value of the presentation and the hacks, were iHeater and Moshpit.
My hack, as listed on hackday.org:
* hack: SnackUpon
* url: http://pipes.yahoo.com/jordansissel/snackupon
* people: Jordan Sissel
* comments: Get StumbleUpon-like behavior trained automatically from your
own tags in delicious. Sources are BOSS news and web search, your
Delicious network, recent Delicious posts, and your own recent posts.
Slides are here
Super huge thanks to Yahoo! for hosting another hackday near me; it was
fantastic.
Comments: 1 (view comments)
Tags: yahoo, hackday, hackday08, openhackday
Permalink: /geekery/yahoo-hackday-08
posted at: 22:00
Last year had some strange badges at Defcon, but they were fun. This year, they're even more full of technology (mini sd card reader, infrared stuff, and what looks like a usb mount point) and much less fun.
Although it is foolish for me to think another conference badge could be as
awesome as the
Shmoocon 2007 badge,
I think it's safe to conclude that Defcon's badges have jumped the shark,
because this year's badges are kind of stupid.
Comments: 3 (view comments)
Tags: defcon, defcon16
Permalink: /geekery/defcon-16-1
posted at: 15:58
Another year, another Defcon.
I'm heading up a day early for my bachelor party (woo!) and then it'll be the
Con all weekend. If you're going, email me and let me know where you are.
I'm eager to watch Kaminsky talk about how awesome he is for [insert reason].
He's deliciously full of himself (not that he doesn't release interesting
things). Lots of other talks look interesting, so it should be a good weekend
full of booze and geeking.
Comments: 0 (view comments)
Tags: defcon, travel, defcon16
Permalink: /geekery/defcon-16-pre
posted at: 04:19
I have a host (let's call it filer) that is only accessible through a bastion
server. Here's how to rsync directly do that host:
rsync -e 'ssh bastion ssh' somefile.tar.gz filer:
I haven't posted much recently due to my wedding coming soon and being
extremely busy with work. I've been learning a great deal of new tools recently, so expect some brain dumps about some of the following:
Comments: 1 (view comments)
Tags: rsync, firewall bypass, ssh
Permalink: /geekery/rsync-ssh-trick
posted at: 01:06
When you create a loop device from a disk image with losetup, it doesn't bother
reading the partition table from the disk image so you don't get the nice and
easy access to, for example, /dev/loop0p1 for partition 1.
FreeBSD seems to get this right, as I recall, but Linux does not.
fdisk outputs these devices, but they don't exist:
% sudo fdisk -l /dev/loop0 | grep '^/'
/dev/loop0p1 * 1 1043 8377866 7 HPFS/NTFS
/dev/loop0p2 1044 2088 8393962+ 7 HPFS/NTFS
Linux's mount(8) command gives you the '-o offset=XXX' option. The offset is a
byte offset, and lets you decide how far into your disk image you want to
start. However, fdisk doesn't output in bytes, it outputs in cylinders or sectors.
Not to worry, it helpfully outputs the conversion between the units and bytes:
% sudo fdisk -l /dev/loop0 | grep Units
Units = cylinders of 16065 * 512 = 8225280 bytes
Knowing this, let's use awk to generate the offsets for us:
% sudo fdisk -l /dev/loop0
| awk '/^Units/ { bytes=$(NF-1) } /^\// { print $1 "[" $NF "]: mount -o offset=" $3 * bytes }'
/dev/loop0p1[HPFS/NTFS]: mount -o offset=8225280
/dev/loop0p2[HPFS/NTFS]: mount -o offset=17174384640
Now simply mount them with 'mount -t ntfs -o loop,offset=XXXX mydiskimage /mnt' or whatever you want :)
Comments: 2 (view comments)
Tags: linux, losetup, mount, loop, dd
Permalink: /geekery/mounting-partitions-within-a-disk-image-in-linux
posted at: 02:21
|
Search this site
Navigation
Metadata
Home
About
Resume
My Code (SVN)
ARP Security
Dynamic DNS with DHCP
OpenLDAP+Kerberos+SASL
PPP over SSH
SSH Security: /bin/false
Week of Unix Tools
Work Efficiency
fex
firefox tabsearch
firefox urledit
grok
keynav
liboverride
newpsm (FreeBSD)
nis2ldap
pam_captcha
poor man's backup
Solaris audio utility
xboxproxy
xdotool
xmlpresenter
xpathtool
misc scripts
Presentations
Yahoo! Hack Day '06
Unix Essentials
Vi/Vim Essentials
Tag Cloud
Calendar
| < |
October 2008 |
|
| | | | 1 | 2 | 3 | 4 |
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |
Friends
BarCamp
Kent Brewster
Tantek Çelik
John Resig
Wesley Shields
Tyler Shields
Technorati
|