[Linux] 釋放虛擬記憶體 (cache)
Linux Kernel 2.6.16 之後加入了 drop caches 的機制,可以讓系統清出多餘的記憶體,這對於搞嵌入式系統相當重要阿,Memory 不夠就不能 upgrade firmware,我們只要利用讀寫 proc 檔案就可以清除 cache 記憶體檔案,底下是操作步驟:
釋放 pagecache:捨棄一般沒使用的 cache
echo 1 > /proc/sys/vm/drop_caches
釋放 dentries and inodes
echo 2 > /proc/sys/vm/drop_caches
釋放 pagecache, dentries and inodes
echo 3 > /proc/sys/vm/drop_caches
Reference: Drop Caches 觀察 Linux 的虛擬記憶體
[Linux] 嵌入式系統不可或缺的工具 – busybox 分析 ifconfig command

玩過嵌入式系統的使用者,一定都會知道 Busybox,它提供一些小型 Linux command,方便在 console 端使用,以及一些 C 語言或者是 shell script 裡面,大家都知道 ifconfig 這指令,為了從 Kernel 2.6.15 轉換到 2.6.34.7 版本,原本的 Busybox 版本只有 1.0.1,現在已經到 1.18.1,轉換過程改了 Kernel netfilter 部份,以及 user space 部份 iptables extension。ifconfig 是 Busybox 其中一個指令用來查看目前有多少網路介面(network interface),來看看他是如何得到這些 interface 資訊,包含介面名稱、type、IP Adress、IP network mask、HW address 等….。
要讀取 interface 相關資訊可以透過兩種方式,一種是讀取 (IPv6 是 /proc/net/if_inet6),另一種透過 Socket 連接SOCK_DGRAM,最後用 iotcl 方式讀取 interface 相關資料,busybox 會先偵測檔案 /proc/net/dev 是否存在,如果 Kernel 有支援,就會讀取此檔案,如果不存在,則利用 socket 讀取資料。
if_readlist_proc 函式裡面:
看一下 /proc/net/dev 內容
[虛擬主機] VPS Linode 贈送 $100,000 美元給新註冊會員
[資料庫] 如何轉換 Mysql varchar type 到 int type
先來說明為什麼有時候需要用到轉換 varchar 到 int 型態,就是因為 order by 的問題,幫學校修改 Mysql 錯誤排序,前人設計全部都用 varchar 型態去存資料,當然包含了學生入學年度,以前不會遇到這問題,但是到了民國100年,就會發生排序錯誤,底下來講個例子,這樣大家就可以瞭解了。 建立 test 資料表,並且先增兩個欄位分別是 a(varchar) 跟 b(int),個別輸入 100, 90 兩列資料
mysql> select * from test; +------+------+ | a | b | +------+------+ | 100 | 100 | | 90 | 90 | +------+------+先針對 varchar 排序 order by a DESC
mysql> select * from test order by a desc; +------+------+ | a | b | +------+------+ | 90 | 90 | | 100 | 100 | +------+------+再來針對 int 排序 order by b DESC
mysql> select * from test order by b desc; +------+------+ | a | b | +------+------+ | 100 | 100 | | 90 | 90 | +------+------+[Read More]
[C/C++] 判斷檔案是否存在 file_exists
[新聞] PHP Framework Codeigniter 1.7.3 釋出 Release

CodeIgniter 1.7.3 Released,1.7.3 版本的出來,最主要是修正了 Upload class 的安全性,在上一次公告就有 Upload Class Patch,只是 1.7.3 就把它納入進來,還有修正在某些情況下可能出現所有檔案,除此之外沒有其他重大修正了,看起來是為了過不久的 2.0 所準備,目前團隊都朝 2.0 發展了。 原文:
Version 1.7.3 is a security maintenance release, including a previously patched file Upload class, and a new security fix to prevent possible directory traversal in certain circumstances (back ported from a fix made to CodeIgniter 2.0 at BitBucket). There are no other significant changes. 搶先版: 下載 Codeigniter 1.7.3
[Linux] VirtualBox + Ubuntu 10.10 編譯嵌入式系統
Ubuntu 來編譯嵌入式的環境,由於個人比較不喜歡 Fedora 的系統,所以自己用了 VirtualBox 來搭配 10.10 的 Ubuntu 系統,在這裡提醒一下,請安裝最新版的 VirtualBox 3.2.12 for Windows hosts,否則在安裝 Ubuntu 之後,繼續安裝 Guest Addition 的時候會當機喔,重開機之後可以看到桌面多出一個光碟,是要您繼續安裝 Additions
切換到該光碟目錄
cd /media/VBOXADDITIONS_3.2.12_68302/直接執行
sh VBoxLinuxAdditions-x86.run重新開機就完成了,可以直接切換視窗大小...等,編譯 gcc 必須要一些 Cross tool,利用 apt-get 方式安裝:
apt-get install build-essential安裝額外 USB 裝置: 視窗上面 Devices -> USB Devices 選擇你要的外接硬碟,會跳出 Windows 安裝額外 Driver




