gdb: source indicator goes out of order

If program is compiled with option "-O2", gdb might not recognize order of source lines correctly and the current statement  would point to incorrect line.

Change "-O2" to "-O0"



Dual boot: windows 7 & centos

menuentry "Windows 7" {
	set root=(hd0,1)
	chainloader +1
grub2-mkconfig -o /boot/grub2/grub.cfg


C pointer variable

What is the difference between int* n and int *n

If int *n, that is a fallacy that there are 2 type of variables. In fact, variable is a place holder of data only, the variant is the type of data it holds.

int is data structure of 4 bytes while int* is the one of 8 bytes (for 64 bit system).

#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#include <netinet/in.h>
#include <errno.h>
#include <string.h>

int main(int argc, char* argv[]){
 int fd = socket(AF_INET, SOCK_DGRAM, 0);
 unsigned int zero = 300;
 // building address structure 
 struct in_addr* ipaddr = malloc(sizeof(struct in_addr));
 if(ipaddr == NULL){

 zero = *((unsigned int*)ipaddr);
 printf("size of struct in_addr*: %d\n", sizeof(struct in_addr*));
 printf("size of int*: %d\n",sizeof(int*));
 printf("ipaddr = %x",*((int*)(ipaddr)));
 return 0;


Populate a whole-root directory structure

Using yum utility, we can populate a directory structure that holds bunch of software utilities. This structure could be later used as changed root environment (jail). The following command ran on Centos 6:

$ yum install --releasever=6  --installroot=/absolute/path/to/dir <package_name>


Linux software RAID-1

Recover RAID-1 from the disk that survived disaster

$ mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdc 

where /dev/sdc is the surviving disk