in the name of zero

April 6, 2006

fun with linux device parameters

Filed under: hermetic studies

well i think i had a good start with this one. never really did any real interaction with linux device files in assembly. so i decided i’d try some experiments today. my list included doing something with regards to the linux framebuffer, virtual terminals and sound/dsp devices. it seems though that they require considerable effort to learn. after reading some man pages and header files, i decided to begin yet another chapter in my assembly adventure by manipulating the cd rom device in linux. this afternoon, i made my own version on the linux eject command. it only has two functions, that is, to open the cdrom tray, and close it. pretty basic huh? i want to get comfortable with the whole idea of device control first before doing any of the activities i mentioned a while ago.

[ introduction ]

from ioctl(2) manual…

DESCRIPTION
The ioctl function manipulates the underlying device parameters of special files. In particular, many operating characteristics of character special files (e.g. terminals) may be controlled with ioctl requests. The argument d must be an open file descriptor.

i started out knowing only that /dev/cdrom is a symlink to /dev/hdc which is consequently, my cdrom drive. and that sys_ioctl is the linux system call responsible for interfacing with character and device files. eventually, i reached the ioctl_list(2) manual page after going thu the ioctl(2) manual a few times over. specially since the later doesn’t have any examples in it.

so now i have something to work with.

a) open a cdrom device (/dev/cdrom) so i can have a file descriptor for it.
b) use the new file descriptor when calling ioctl with the appropriate request and the appropriate structure (if necessary).

i confirmed the those steps above by running /usr/bin/eject under strace. it looked doable so i fired up vim and what do you know? the eject thingy i did works! -t flag closes the tray.

(more…)

to the dork in irc i chatted the other day

dude,

lighten up. xorg bug wrangling is taking it’s toll on you huh? strange, i’ve always had the impression that you were an irritable kinda dork from the start though. and somewhere in my mind, i knew sooner or later you’d get ticked off. your wife, if you even have one must be a saint. i pity her. she chose and married you over all other countless choices out there. that must be killing her inside slowly and painfully. i hope she cheats on you real soon. that way, you can have more time writing docs no one will read, while the rest of us happy and interesting people move on with our lives enjoying the talks and company of each other, oblivious of the authoritative aura you try so much to assert.

oh high and mighty dev! jack off and drink your own semen.

tidings

Get free blog up and running in minutes with Blogsome | Theme designs available here