Posted in Embedded System, Kernel, Linux on Dec 27th, 2010
Linux Kernel 2.6.16 之後加入了 drop caches 的機制,可以讓系統清出多餘的記憶體,這對於搞嵌入式系統相當重要阿,Memory 不夠就不能 upgrade firmware,我們只要利用讀寫 proc 檔案就可以清除 cache 記憶體檔案,底下是操作步驟: 1. 釋放 pagecache:捨棄一般沒使用的 cache echo 1 > /proc/sys/vm/drop_caches 2. 釋放 dentries and inodes: echo 2 > /proc/sys/vm/drop_caches 3. 釋放 pagecache, dentries and inodes:(效果等同於1+2) echo 3 > /proc/sys/vm/drop_caches Reference: Drop Caches 觀察 Linux 的虛擬記憶體
Read Full Post »
Posted in C/C++, Embedded System, Linux on Dec 27th, 2010
玩過嵌入式系統的使用者,一定都會知道 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 [...]
Read Full Post »
Posted in Linux, www on Dec 18th, 2010
昨天在下班前看到 Linode VPS 送出這個訊息: Linode $100,000 Giveaway!,只要在美國時間2010年12月17日早上九點開放名額1000名購買 VPS Linode 任何一種,就可以獨享 100 元美金的優惠,原本我已經有買一台 Linode 512 方案,我現在又加購一台,省下不少錢呢,到月底就不續約,然後再用新帳號繼續使用 Linode 512 服務,沒圖沒證據,底下附上我購買相關圖片 另外 VPS Linode 也提供了香港主機的服務,以及新的 Ubuntu OS 也上線了 Arch Linux 2010.05 (i386 and x86_64) CentOS 5.5 (i386 and x86_64) Debian 5.0 (i386 and x86_64) Fedora 14 (i386 and x86_64) Slackware 13.1 (i386 and x86_64) Ubuntu 10.04 LTS (i386 [...]
Read Full Post »
Posted in MySQL, sql on Dec 17th, 2010
先來說明為什麼有時候需要用到轉換 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 [...]
Read Full Post »
Posted in C/C++ on Dec 8th, 2010
在 PHP 函式裡面,有直接 file_exists 可以使用,相當方便: <?php if(file_exists("files/appleboy.c")) { echo "File found!"; } ?> 在 C 裡面該如何實做?有兩種方式如下: 1. 直接開檔 bool file_exists(const char * filename) { if (FILE * file = fopen(filename, "r")) { fclose(file); return true; } return [...]
Read Full Post »
Posted in CodeIgniter on Dec 7th, 2010
剛出爐的新聞: 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 [...]
Read Full Post »
Posted in Ubuntu on Dec 4th, 2010
最近使用 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 直接按 Continue Anyway 完成 補上 [...]
Read Full Post »