2013年12月26日 星期四

Trace fdisk source in busybox 心得

When you use "fdisk /dev/sda", fdisk will set disk_device(this is an global) to "/dev/sda".
Then into the main loop.
If you enter "n" it will call new_partition().
The key point of new_partition() is add_partition(index, type);
The size is set in the read_int() of add_partition()

2013年12月25日 星期三

printf 印出 IP address

最近 trace code(u-boot) 時發現,printf 現在可以印出 IP 及 MAC 之類的 address 型態。
%pI4:印出IPv4位址,變數型態為 unsigned long 的指標。
%pI6:印出IPv6位址,變數型態為 unsigned ling 的指標。
%pM:印出MAC位址,變數型態為 unsigned char 的指標。

這樣它就可以直接把 IP, MAC address 印出來。

EX:
typedef ulong IPaddr_t;
IPaddr_t NetOurSubnetMask;
printf("NetOurSubnetMask : %pI4\n", &NetOurSubnetMask);

unsigned char env_enetaddr[6];
printf("Address in environment is  %pM\n", env_enetaddr);

而變數裡面的值,IP的部份就是16進制的值直接連在一起。
例如:
192.168.10.100 => C0A80A64
192 = C0
168 = A8
 10 = 0A
100 = 64

MAC 的部份也是一樣是16進制的值,所以用 %s、%c會印不出來。
反而直接用%x一個一個去印是印得出來的。


這功能原本可能來自新版的 Linux Kernel 的 printk
參考:
https://www.kernel.org/doc/Documentation/printk-formats.txt

2013年12月20日 星期五

Linux 提示字元

前幾天失心瘋,玩起了 Git ,在網路上亂找一些關於 Git 的資料,像是一些參數設定,GUI工具之類的。因為現在的專案管理用的是 Git ,但它強大的功能也帶來了複雜的操作,雖然不見得什麼都用得到,但有得用,不學一學,用來耍酷一下就覺得很難過。

結果其中找了一項是,在 .bash_profile 裡加入:
PS1="[\[\033[1;32m\]\w\[\033[0m\]]\[\033[1;36m\]\$(git_branch)\[\033[0;33m\]\$(git_since_last_commit)\[\033[0m\]$ "

2013年12月17日 星期二

GUI Git Client

git 雖然功能強大,不過也因為功能太強大,branch 很容易會開很多。當 branch 一多,要使用 command line 來看各 branch 之類的差異、每個 branch 的進度之類的,就不是那麼的方便了。所以開始尋找有 GUI 的 git client。