Square Galaxy

Tag: linux

atoi(getenv(”MYVAR”))

by Jacob on May.28, 2008, under Technical

These are mostly personal notes. I’m not sure if they will make sense to others.

I had a problem with a line of code like this:
int x = atoi(getenv("MYVAR"));

If this line was in daemon-ized code started at init level 2, it would segfault. (I’m not sure if these conditions are necessary, but those were my conditions).

getenv("UNKNOWN_VAR") == NULL
atoi(NULL) should == 0

But for some reason, things were segfaulting. I corrected the problem with:
if (getenv("MYVAR") == NULL) int x = 0;
else int x = atoi(getenv("MYVAR"));

2 Comments :c, linux, programming, Software more...

Death by writing files from the kernel

by Jacob on Mar.21, 2008, under Technical

I’ve written my first semi-major Linux device driver. I won’t say exactly what it does other than write data out to hardware.

Generally, it is well NOT accepted to write to files from the kernel. If you ask how, people will tell you “don’t.” I completely agree with all of the reasons provided, but I decided to do it anyway.

The hardware I’m writing data to isn’t readily available. I wanted to be able to test my code well without having to have the hardware available. So I wrote in some non-release, non-production code that writes data to a file instead of to hardware, but only for testing purposes. When in this simulation mode, the user can interact with the driver and data gets written to the file instead of to hardware, and then the file can be checked for accuracy.

User writes to driver -> kernel driver handles write -> driver writes to file

Easy enough? I thought so until I tried writing to the driver as a regular system user. I chmod’ed the driver so that the user had full privileges to read and write to the file. When root would write to the driver, everything worked, when the regular user would write to the driver, the kernel would crash.

The problem was that the user didn’t have write permissions to the test file that the driver was writing to. I thought the kernel level driver could write to any file it wanted, but apparently, the user’s permissions to the file permeated through the kernel driver. Changing the files permissions fixed things so they didn’t crash any more.

The caps lock and scroll lock lights blink on the keyboard when the kernel crashes. Not quite fireworks, but still kind of cool. Development in a virtual machine is key, so that you really don’t crash your computer, just the virtual machine.

Leave a Comment :linux, Software Engineering more...

AverTV Media on Ubuntu

by Jacob on Aug.25, 2007, under Technical

I have an old TV tuner card that I picked up in 2002. I can’t remember exactly what type of card it is, but after searching around the internet, I’m somewhat convinced that it is the AverTV Media (with FM tuner). The card identifies itself as an AverTV Phone something or another, but I know it isn’t any of their “phone” variety of cards.
(continue reading…)

Leave a Comment :Hardware, linux, tv more...

Keeping Linux under Ctrl-Ctrl

by Jacob on Jun.28, 2007, under Technical

Recently, Google released their Google Desktop product for Linux. I found out about it just this evening. Earlier today, I was searching through my home directory looking for some old files from a long time ago, and I though, “Wouldn’t it be great if Google Desktop Search was available for Linux?” About two hours later, my wish came true.
(continue reading…)

1 Comment :Google, linux more...

Upgrading operating systems

by Jacob on Apr.20, 2007, under Technical

How would you respond if I told you that all it would take is a few clicks to upgrade your Windows XP to Wndows Vista?  That it would be able to download and upgrade the entire system in a matter of hours (depending on the speed of your Internet connection).  What if I said it would also upgrade your word processor, web browser, and most of the other commonly used applications?  What if I said it wouldn’t even cost you a thing?

(continue reading…)

Leave a Comment :linux more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

 

November 2008
M T W T F S S
« Oct    
 12
3456789
10111213141516
17181920212223
24252627282930