Monday, June 27, 2011

how to mount flash drive in Redhat

A security policy in place prevents this sender from sending this message to this recipient, see message bus configuration file (rejected message had interface “org.freedesktop.Hal.Device.Volume” member “Mount” error name “(unset)” destination “org.freedesktop.Hal”)

(1) gedit /etc/dbus-1/system.d/hal.conf
option 1:

option 2:

(3) restart

Tuesday, April 5, 2011

How to print a word (two bytes) in assembly

assume the data that need to be printed are in DX register. CX(CL) is the counter to be used to shift the bit of DX. At the end of the code, ascii 13 + ascii 10 are equivalent to "\r\n"

movb $16, %cl
subb $4, %cl
movw %dx, %ax
shr %cl, %ax
andw $0x000f, %ax
cmpb $10, %al
jl test_word_less
addb $7, %al #prepare for A,B,C...because 17+48=65(A)

addb $48, %al
movb $0xe, %ah
movw $7, %bx
int $0x10
cmpb $0, %cl
jne test_word_loop
movb $13, %al
int $0x10
movb $10, %al
int $0x10

Monday, April 4, 2011

How to print register value in assembly language

Here is the AT&T assembler function I came up with in order to print something during the Linux kernel debugging. Assuming the lower FOUR bits of CX (CL) are use as a value we want to print a HEX of, according to ascii table:

andb $0x0f, %cl #mask the higher four bits
cmpb $10, %cl #see if we need 1,2,3,4...or A,B,C,D...
jl test_less #if the value is less than 10, jump
subb $10, %cl #if the value if larger or equal to 10, offset it
addb $17, %cl #prepare for A,B,C...17+48=65, can use addb %3, %cl as well

addb $48, %cl #Then the result is stored in CL, call int 0x10 to print it

Monday, March 28, 2011

How to debug new Linux kernel (2.6.38) using Eclipse Helios and Qemu

(1) Make sure you have the latest QEMU from its official website and install SDL (Simple Directmedia Layer) and Eclipse Helios CDT package from Eclipse website.
(2) refer to the post
for basic setup.

Below are specific to Eclipse Helios (different from the post above):
(3) ON the menu "Run -> Debug configurations", double-click "C/C++ Application", on the right panel, make sure you got a name for this configuration. Then on the "Main" tab, click "Search project" and select "vmlinux", then NOTE: under the "vmlinux" subcategory, select the one that is NOT compressed, i.e., select "root_project_directory/vmlinux" NOT "root_project_directory/arch/x86/boot/compressed/vmlinux".

(4) Note that at the bottom of the "Main" tab, just above the "apply" and "revert" bottons, there is "Using GDB(DSF) create process launcher-select other..". We want to use another launcher because this GDB(DSF) one doesn't come with TCP connectivity. So click on "select other..", then tick "Use configuration specific setting" enabling the selection list below, then select "Standard create process launcher", then click "OK" to dismiss the "Select Preferred Launcher" dialog.

(5) Back to "Debug Configurations" dialog, click the "Debugger" tab, underneath it you will find the desired "Debugger" drawdown list, go with the post above and select "gdbserver", then pick your "Stop on startup at" (start_kernel in the post), click the "Connection", fill in "TCP", "1234", etc..then "Apply", "Close" the dialog.
(NOTE that here you have to disable the autobuild feature before debug of Eclipse. Else the debugger will NOT successfully stop execution at start_kernel(). The reason is: you first start Qemu to let the execution hang at the start point, then you turn to Eclipse to start the debugger. If you enable "autobuild", then when you try to start debugger, it will rebuild everything and the bzImage that you used to start Qemu will be replaced. That I guess will mess up the debugger. I notice this when Qemu seems to reload the kernel and flash the screen when the debugger is started)
(6) The rest steps are the same as the post. Enjoy, I know I'm thrilled..

Sunday, March 27, 2011

How to create a Linux Debian File System

(1) dd if=/dev/zero of=output.img bs=1M count=4096 //create 4G empty file
(2) mkfs -t ext4 output.img
(3) mount -o loop output.img /mnt/mount_point
(4) debootstrap sid /mnt/mount_point
(5) chroot /mnt/mount_point
(6) passwd root
(7) umount /mnt/mount_point

Using kernel and file system in QEMU

If prefer to using kernel and file system separately in QEMU, get an disk img ready and use:

qemu -hda disk.img -kernel your_kernel -append "root=/dev/sda"

work with QEMU Linux-0.2.img and kernel

Saturday, March 26, 2011

AT&T T-Mobile Merger

This merger just reminds me of the Chinese market where China Mobile and Unicom are the only two companies that offer wireless services (later China Telecom struggled to blend in). And all Chinese customers pay ridiculously high fee for every wireless service. Cannot believe this kind of thing will ever happen in the USA.

Wednesday, March 23, 2011

How to add google code as Maven remote repository

Tuesday, March 8, 2011

Set environment variable for sudo in Ubuntu

(1) edit /etc/environment
(2) edit /etc/bash.bashrc
(3) use sudo -E to use the user's variables

Saturday, February 12, 2011

Blank page before the title page in Latex

If after compiling, there is a blank page before the title page, it's mostly likely that the "\thanks" part is outside of the "\author".

Monday, January 10, 2011


Every creature has its own destiny to fulfill.
The path set for it is pre-determined by the universe.

it will desperately strive to blend in the groups that are out of its league,
but in vain.

Destiny will sometimes let it try and have some experience from those groups.
But in the end,
it will be reset to its own league,
living back to its own world.

How marvellous!

You will know it when you get what it takes,
luck will never be your side, not even occasionally.