MMM: My Mad Motivation

Stop up a hole of my memory

20 wonderful sights from Buzzfeed

without comments

  1. Amazon, South America
  2. Antelope Canyon, USA
  3. Uluru, Australia
  4. Bora Bora Island, Thaiti
  5. Victoria Falls, Zambia (or Zimbabwe)
  6. Fiord, Norway
  7. Santorini, Greece
  8. Iceland, North Atlantic Ocean
  9. Moraine Lake, Canada
  10. Petra, Jordan
  11. Machu Picchu, Peru
  12. Plitvice Lakes National Park, Croatia
  13. Great Barrier Reef, Australia
  14. Sistine Chapel, Rome
  15. Stone Henge, UK
  16. Taj Mahal, India
  17. Palace of Versailles, France
  18. Great Wall of China, China
  19. Angkor Wat, Cambodia
  20. Church of St. Mary of Zion, Ethiopia

Written by admin

March 21st, 2012 at 12:49 pm

Posted in tattoo in mind

HOWTO debug child process

without comments

On gdb prompt, type this.

(gdb) show follow-fork-mode

It may set parent mode. Then,

(gdb) set follow-fork-mode child

That’s it.
If you had a break point in the area of the child process, gdb automatically would switch to the child process.

For the further information, check THIS out.

Written by admin

February 7th, 2012 at 4:46 pm

Posted in C,Linux

Party Rock Anthem – [Walk off the Earth] + All About Maggie

without comments

It’s just awesome!! What a creative work!

Written by admin

January 31st, 2012 at 11:06 am

Posted in muttering

walk off the earth

without comments

I really admire you guys. You are geniuses.

Written by admin

January 31st, 2012 at 1:42 am

Posted in muttering

Get the absolute path of current shell script at runtime

without comments

I needed to know the absolute path of the shell script at runtime.
$PWD was not enough because the script could be executed from other directories
Thus, I googled and I got it.

# $SCRIPT_PATH is the absolute path of the directory in which the script is located.
     SCRIPT_FILE_NAME=$(readlink -f "$0")
     SCRIPT_PATH=`dirname "$SCRIPT_FILE_NAME"`

How simple it is!

Written by admin

January 18th, 2012 at 2:49 pm

Posted in Linux

Tagged with , , ,

How to replace words in multiple files automatically on linux

without comments

When you have bunch of files (may be over 100?), and want to replace words, you don’t want to handle them one by one. (If you have too much time, you can do one by one to spend time with some snacks and music.)

Here is the way automating the replace on command line.

find . -type f \( -iname "*" ! -iname ".svn" \) -exec egrep -l "$search_string" {} \; -print | sed -e ‘s/\ /\\ /’ | xargs -i perl -pi -e "s/$search_string/$replace_string/g" {}

$search_string is the words you want to change to $replace_string. If you have spaces in words, you shoud type space with backslash.

I had to replace “esp sha1 aes aes aes” to “esp null” in 255 configuration files whoes file names start with pol, so that I execute like below.

find . -type f \( -iname "pol*" \) -exec egrep -l "esp\ sha1\ aes\ aes\ aes" {} \; -print | sed -e ‘s/\ /\\ /’ | xargs -i perl -pi -e "s/esp\ sha1\ aes\ aes\ aes/esp\ null/g" {}

You’re welcome.

Written by admin

November 17th, 2011 at 10:09 am

Posted in Linux

Tagged with ,

Seven social sins – Mahatma Gandhi

without comments

I suddenly felt I should remember this.

Mahatma Gandhi said,

  • Politics without principles (신념없는 정치)
  • Wealth without work (노동없는 부)
  • Pleasure without conscience (양심없는 쾌락)
  • Knowledge without character (인격없는 지식)
  • Commerce without morality (윤리없는 비즈니스)
  • Science without humanity (인성없는 과학)
  • Worship without sacrifice (희생없는 종교)
are the “Seven social sins”.

Written by admin

October 31st, 2011 at 9:39 am

Posted in tattoo in mind

A Brilliant Commercial

without comments

How brilliant!!

Written by admin

October 28th, 2011 at 1:34 pm

Posted in muttering

When you want Floating Point instruction in Kernel module.

without comments

CPU has FPU (Floating Point Unit), and some registers and instructions are related to FPU.
These don’t have any problem when operations are performed in user space.

BUT!!! How about in kernel module?
The registers related to FPU are not saved and restored when context switching occurs in kernel mode, so that many people suggest not to use FPU in kernel mode.

Unfortunately, there is inevitable situation.
I wanted to use AES-NI (AES New Instructions) which use xmm registers (related to FPU I guess) in kernel module.
Every time I called the function implemented with AES-NI, the kernel crashed with “device_not_available” exception and “math_state_restore” exception.

I did not know what happens with xmm registers in kernel module. After I googled, the solution poped up.
Here is the solution. (Extremely Simple!!)

Wrap the statements related to FPU with kernel_fpu_begin() and kernel_fpu_end().

  	//
  	kernel_fpu_begin();
  	/* STATEMENTS (AES-NI related functions in my case); */
  	kernel_fpu_end();
  	//

How simple it is!!

Written by admin

October 20th, 2011 at 10:54 am

When is __attribute__ ((regparm(0))) needed?

without comments

I wanted to use some assembly code into both a kernel module and a user space application.
A user space application worked find, but the kernel module was always crashed. (Oooops!!)
When I inspected the register, the argument value was wired.
The argument was the pointer value of a structure. It was obvious that the kernel crash because of the wrong argument value.

The reason was this.
1. The function implemented in assembly is implemented with getting argument within stack. (__cdecl calling convention)
2. The module passed the argument into the register directly. (__fastcall)

The solution is this.
1. When the caller declare the function (implemented in assembly), __attribute__ ((regparm(0))) is attached the very first of the declaration.
For example, __attribute__ ((regparm(0))) void a_functions(void* arg);

What does __attribute__ ((regparm(0))) mean?
1. This statement decides how many arguments pass in register directly, so that __attribute__ ((regparm(0))) means I do not want to the arguments passing with registers.
If you attach __attribute__ ((regparm(3))), the arguments passed with registers up to 3 of them. 4th argument is passed with the stack.

Until here, this is all I understood.

Written by admin

October 20th, 2011 at 10:14 am