Monday, June 1, 2015

Truth in life

1、当你对某件事情抱着百分之一万的相信,它最后就会变成事实。


2、期望定律


期望定律告诉我们,

当我们怀着对某件事情非常强烈期

望的时候,我们所期望的事物就会出现。


3、情绪定律


情绪定律告诉我们,

人百分之百是情绪化的。

即使有人说某人很理性,其实当这个人很有"理性"地思考问题的时候,也是

受到他当时情绪状态的影响,"理性地思考"本身也是一种情绪状态。

所以人百分之百是情绪化的动物,

而且任何时候的决定都是情绪化的决定。


4、因果定律


任何事情的发生,都有其必然的原因。有因才有果。换句话说,当你看到任何现象的时
候,你不用觉得不可理解或者奇怪,因为任何事情的发生都必有其原因。你今天的现状
结果是你过去种下的因导致的结果。


5、吸引定律


当你的思想专注在某一领域的时候,跟这个领域相关的人、事、物就会被你吸引而来。


6、重复定律


任何的行为和思维,只要你不断的重复就会得到不断的加强。

在你的潜意识当中,只要你能够不断地重复一些人、事、物,它们都会在潜意识里变成
事实。

7、累积定律

很多年轻人都曾梦想做一番大事业,其实天下并没有什么大事可做,有的只是小事。一
件一件小事累积起来就形成了大事。任何大成就或者大灾难都是累积的结果。

8、辐射定律

当你做一件事情的时候,影响的并不只是这件事情的本身,它还会辐射到相关的其他领
域。任何事情都有辐射作用。


9、相关定律

相关定律告诉我们:这个世界上的每一件事情之间都有一定的联系,没有一件事情是完
全独立的。

要解决某个难题最好从其他相关的某个地方人手,而不只是专注在一个困难点上。


10、专精定律


专精定律告诉我们,只有专精在一个领域,这个领域才能有所发展。所以无论你做任何
的行业都要把做该行业的最顶尖为目标,

只有当你能够专精的时候,你所做的领域才会出类拔萃地成长。

11、替换定律

替换定律就是说,当我们有一项不想要的记忆或者是负面的习惯,我们是无法完全去除
掉,只能用一种新的记忆或新的习惯去替换他。

12、惯性定律

任何事情只要你能够持续不断去加强它,它终究会变成一种习惯。

13、显现定律

显现定律就是说,当我们持续寻找、追问答案的时候,它们最终都必将显现。


14、需求定律

任何人做任何事情都是带有一种需求。尊重并满足对方的需求,别人才会尊重我们的需求

Monday, June 27, 2011

how to mount flash drive in Redhat

error:
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”)

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












option 2:
groupadd
usermod/useradd











(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"


test_word:
movb $16, %cl
test_word_loop:
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)

test_word_less:
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
ret

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:

test_func:
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

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

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
http://issaris.blogspot.com/2007/12/download-linux-kernel-sourcecode-from.html
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 http://ftp.us.debian.org/debian/
(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 2.6.38.1 kernel