今天要把 MAC address 由字串轉成 16 進制數字時,才發現很麻煩。因為它是 6 個 bytes,太長了。尋找解決的過程經歷了一些故事,所以來記錄一下。
其實之前有碰到 memory address 的部份,由使用者輸進來的是字串,但運算時常常需要把它轉成 16 進制數字。在我手上的程式一般是使用 simple_strtoul 這個函式,但是它的傳回值是 unsigned long ,只有 4 個 bytes,所以長度不夠。
2014年1月28日 星期二
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()
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()
訂閱:
文章 (Atom)