VFP on Linux – 與 Wine 共舞的樂章

寫在前面
========
老實說,這篇文章充其量,祇能說是整理而已.
純粹去網路找文章,實作,遇到與文章不符的地方,就自己動手找資料,實驗,找答案,就這樣而已.
我想,大概有百分之五十是參考資料,百分之四十是翻譯;剩下百分之十,才是我的心得與實作過程.
Wine 的歷史
===========
請直接參考 2003/08/15 的 Wine Traffic
http://kt.zork.net/wine/wn20030815_183.html#5
安裝,from tarball
=================
以 tar xzf 解開之後,進行 patch, patch 檔網址在此:
http://www.paulmcnett.com/vfp/wine/vfpwinepatchwinsize
這個 patch 檔主要是修正 WAIT WINDOW 和 TooltipText window 無法正確顯示的問題.
Patch 方法:
cat vfpwinepatchwinsize | patch -p1
也可以手動編輯 wine/dlls/x11drv/winpos.c
在約 887 行的地方,找到
BOOL
X11DRV_SetWindowPos( WINDOWPOS *winpos )
這個 function,並在裡面的
TRACE(
“hwnd %p ……
之前加上
/* This is needed to flush pending X ConfigureNotify events on this window */
MsgWaitForMultipleObjectsEx( 0, NULL, 0, 0, 0 );
存檔以後即可.
執行 ./tools/wineinstall
它會出現訊息,建議不要以 root 身分來安裝
如果你堅持要以 root 身分來安裝, 請修改此 script,讓他忽略此訊息
(178~184 行,前面加上’#’ )
再執行此 script.
當然如果要用別的身分來安裝,請用 su 指令切換到其他 user 帳號
或重新以其他 user 帳號登入即可.
此 script會執行 ./configure,設置必要的設定檔以及路徑.
然後再執行
make depend && make && make install
進行編譯及安裝工作.
若以其他user進行安裝的話,就依照 script指示即可
wine 最後會以 SUID 形式存在.
RPM 安裝
========
請到官方網站下載符合你 Linux distribution 的 RPM 版本
然後執行 rpm -ivh wine-2003xxxx.ix86.rpm
即可~
但要注意的是,不保證可以用,建議還是以 tarball 安裝較佳.這樣也可加上 patch.
Usage
=====
winhelp, notepad, regsvr32, regedit 這幾個不用說明,就跟Windows 上的一樣~
progman 的話就跟 Windows 3.1 上的 Progman 一樣,執行以後,
有用過 Windows 3.1 的人,大概會很懷念~
winefile 則是檔案總管
wcmd 是”命令提示字元”
uninstaller 則是”新增/移除程式”
winecfg 則是調校 wine 設定的程式
執行軟體時,以 wine 執行之,假設你複製了小算盤(calc.exe)進去
那麼就輸入 wine calc.exe 即可~
安裝軟體,也一樣,執行 setup 即可: wine setup.exe
Configuration
=============
“Version”Section 的 Windows key 值改為 win2k
“DllOverrides” Section 中所有 key 值改為 “native, builtin”
此外把你自己 Winnt\system32 或 Windows\system 下的
OLEAUT32.DLL
COMMDLG.DLL
COMDLG32.DLL
SHELL.DLL
SHELL32.DLL
SHFOLDER.DLL
SHLWAPI.DLL
SHDOCVW.DLL
ADVAPI32.DLL
MSVCRT*.DLL
VFP6*.DLL
ODBC32.DLL
ODBC32GT.DLL
ODBC16GT.DLL
ODBCINT.DLL
ODBCCONF.DLL
都複製到 ~/c/windows/system 下
此外,OLE32.DLL, ADVAPI32.DLL, NTDLL.DLL 是不需要複製的,因為會造成無法執行.
REGEDIT.EXE 也請複製到 ~/c/windows 下,因為我們要把 ODBC 的 Registry import 進去.
你也許會問 wine 不是提供了 regedit.exe 嗎?可是根據我自己的試驗,它並無法匯入.
請在 Windows 下執行 regedit.exe 將
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers
以及
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Microsoft Visual FoxPro Driver
這兩個機碼都匯出.分別存為 ODBCDrivers.reg 及 VFPDriver.reg
然後編輯 ODBCDrivers.reg ,將其他 Driver 都刪掉,只留下 Microsoft Visual FoxPro Driver 即可
接著就拿到 Linux 上,執行 regedit.exe 匯入囉.
開始使用 VFP
============
我自己是建議不要用 setup 安裝,網路上的一些狐友也這樣說
就是用 copy 的方式把 Program Files 目錄下的 VFP 目錄直接複製到 ~/c/Program Files 下
再參考上面的 Configuration 一節作修正.
接著就可以執行 wine VFP6.EXE 啦~~
進入以後,你會發現 command window 無法顯示游標,請用 Alt+TAB 切到別的視窗, 再按一次 Alt+TAB 切回 VFP,即可.
Issue
=====
Declare DLL ok
大部分函數都已經實作出來了~
可能會發生的問題,多半是路徑問題,此問題可以藉著修改 ~/.wine/config 來解決.
Record locking
20030318 版之前是有問題的,但之後的版本就都可以了
ActiveX
有些 ActiveX 會無法使用,那是因為有些 function 還沒實作出來的原因.
中文
對我們來說,這是最大的問題了
Linux 中雖然已經支援中文,可是 wine 看來是還未支援,也因此,文字無法輸入到 VFP 視窗中.
此外,字型名稱也是一大問題,由於小弟對中文字型設定這部分還不是很熟
再加上目前 X 組織又提出一個新的技術 Xft 要解決字型名稱問題,所以請期待吧~
其他
沒有 HTML Help.
在 Class Designer/Form Designer 裡面無法 copy/paste 物件.
Undocked windows 需要被設定為 undockable (在Title band 按下滑鼠右鍵) 或他們無法取得 focus.
EULA(End User Licence Aggreement) – Microsoft 的阻撓
====================================================
以下大致從 http://www.linuxtransfer.com/h/misc_vfplinuxjackofhearts.htm 譯出.
僅將大意譯出,如果譯的不好,還請見諒.
事情是這樣開始的,就在今年的四月左右,Ken Levy,Whil Hentzen在展示一個關於 VFP on Linux 的 Demo 之後,他接到一通來自微軟的電話,告知他說,這樣的一個 Demo 將可能會與 VFP EULA 衝突.後來這件事情就慢慢的擴散….
什麼是 EULA ?? EULA 就是 End User Licence Aggreement 的縮寫.
以下就是與 VFP on Linux 有關的 VFP8 EULA條款:
3.1 General Distribution Requirements.
(a) If you choose to redistribute Sample Code, or Redistributable Code (collectively, the “Redistributables”) as described in Section 2, you agree:
(i) except as otherwise noted in Section 2.1 (Sample Code), to distribute the Redistributables only in object code form and in conjunction with and as a part of a software application product developed by you that adds significant and primary functionality to the Redistributables (“Licensee Software”);
(ii) that the Redistributables only operate in conjunction with Microsoft Windows platforms;
在 VFP 社群要求微軟作進一步說明的一星期後,這是微軟的說明(澄清):
Visual FoxPro was designed and tested for use in creating applications that run on the Microsoft Windows platform; the same applies to the components that are provided to developers for redistribution with Visual FoxPro-based applications. If a developer wishes to distribute the Visual FoxPro runtime with an application, the runtime may only operate in conjunction with a Microsoft Windows platform. As with any contract, you should seek your own legal counsel’s advice when interpreting your rights and obligations under the Visual FoxPro End User License Agreement.
大意是,VFP本身是在 Windows 平台上發展及測試的,和VFP一起提供給開發者散佈的元件也是.如果開發者想要將VFP runtime和應用程式一起發佈,runtime 應該只能(may only)在Microsoft Windows 平台上運行.如同任何的合約,你應該尋求你的法律顧問的建議.
在這篇文章中,http://www.linuxtransfer.com/h/misc_vfplinuxjackofhearts.htm
提出了三點疑問,
1.Running the VFP Development Environment on Linux
VFP 開發者想要在一台 Linux 機器上將 VFP 當作一個開發環境.
這個企圖正是 McNett’s FoxTalk 文章的主旨,而且是Levy舉辦該活動的主題,卻又宣告他是與VFP7 和 VFP8 的 EULA 衝突,不允許公開展示.
2.Deploying custom VFP applications on Linux workstations
VFP 如同大家所知的,AP都是要與 runtime 一同包裝,並安裝到客戶那兒.以前很簡單,都只要幾個DLL檔案就行了,現在,最後一版的VFP,都是以MSM 形式給Installer tool使用.只有這些 MSM 檔案列在 REDIST.TXT 中,卻沒有明確的指定是哪些VFP DLL 檔案.
所以只要用這個方法是不是就可以避免了呢?
第一個問題是,如果發布自訂的VFP DLLs 在 EULA 裡是不被允許的,那麼
(1)如果不用 Windows Installer 技術的話,那麼市場上還有許多不使用 Windows Installer 技術的安裝工具,這些工具是不是就與 VFP EULA 衝突了呢??
(2)為什麼從6.0 到7.0,這樣的一個改變,卻沒有任何公告??就正常來說,一個產品的改變應該會被公告於 “Read Me” 或 “What’s New” 檔案中.可是這卻被放到 EULA 中,而缺乏任何說明.
ok,假設VFP EULA 禁止散佈 VFP DLLs,只能使用 Windows Installer 技術.
總之,看起來,Microsoft 就是想把它們的應用程式綁在他們的 OS 上.
3.The Business Issues
Microsoft 之所以需要 VFP, FoxBase 和 FoxPro, 主要就是為了要打擊Desktop database市場上其他的對手.那個時候,幾乎所有產品都不需要 runtime license,就這樣,一直延續到現在.Microsoft長期忽略 VFP,大概與Business Model有關,他們寧可開發者用VB 和 SQL Server,這樣就可從 SQL Server 那兒收到 licenses 費用.
VFP 可以在 Linux 上執行是非常吸引人的,想想一套便宜(或免費)的作業系統加上一個不貴又有威力的開發工具,和一個便宜(或免費)的後端資料庫,是多麼的不錯.很簡單的可以看出來為什麼 Microsoft 要試著去對抗他,並強加了和以往不一樣的的授權限制.
參考網址: (謝謝Ruey提供部份資料)
===============================
安裝:
http://www.pinpub.com/FT/FTmag.nsf/0/843B563D8FB169F485256D6700710C3A
http://www.paulmcnett.com/vfp/vfp7wine.html (安裝)
http://www.paulmcnett.com/vfp/wine/foxtalk1.html
相關資料收集:
http://fox.wikis.com/wc.dll?Wiki~VFPandLinux~VFP
http://www.associateddata.co.uk/VFPLinux.htm
微軟的恫嚇與EULA的相關討論:
http://www.linuxworld.com/story/32665.htm
http://mail.linux.ie/pipermail/ilug/2003-April/002197.html
http://www.linuxtransfer.com/h/misc_vfplinuxjackofhearts.htm
http://www.linuxjournal.com/article.php?sid=6869&mode=thread&order=0
Wine 官方網站 Guide:
http://www.winehq.com/Docs/wine-user/
Wine 應用程式相容性:
http://appdb.winehq.com/
http://frankscorner.org/
Wine 所收錄的 VFP Profile:
http://appdb.winehq.com/appview.php?appId=296;PHPSESSID=9e9d479fa55fb6c759ad092fd5aa3184

CD Writing HOWTO 讀後心得

原文:http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/CD-Writing-HOWTO.html
可以用 cdrecord -scanbus 來檢閱可用的裝置
Linux kernel 版本需高於 2.0.36 或 2.2.11
需要檢查 /dev/ 下是否有 sg device
若沒有,可以用 mknod sg0 c 21 0 來建立
若有多個,則 mknod sg1 c 21 1, mknod sg2 c 21 2 ….
需要以下 modules
scsi_mod
sg
sr_mod
loop
iso9660
ide-scsi
需要調整 cd-writer 所掛入的 driver(module)
– 若是 built-in, 在 lilo, kernel 啟動參數的地方加上 hdx=ide-scsi
– 若是 module, 則在 /etc/modules.conf 中加上
options ide-cd ignore=hdx
alias scd0 sr_mod
pre-install sg modprobe ide-scsi
pre-install sr_mod modprobe ide-scsi
pre-install ide-scsi modprobe ide-cd
假設 /dev/scd0 為 cd-writer
也可為 /dev/scd0 建立 symbolic link 到 /dev/cdrom 下
ln -s /dev/scd0 /dev/cdrom
工具軟體:
1.mkisofs
2.cdrecord
3.cdrdao
4.VCD
(進度顯示則可參考一些 GUI 的工具: xcdroast, BurnIT, cdtux )
一般來說 620MB on disk 約等同於 650MB on CDROM
製作 image 的方法:
mkisofs -r -o cd_image 目錄/
燒錄的方法:
cd-r 的指令是,
cdrecord -v speed=n dev=scsi_bus,scsi_id,scsi_lun -data cd_image
cd-rw 則再多加上 blank=… 以清除原先內容.
一般都是先 mkisofs, 再呼叫 cdrecord.
以下指令則是先確認來源的大小之後,再行燒錄:
#IMG_SIZE=`mkisofs -R -q -print-size 目錄/ 2>&1 | sed -e “s/.*=//”`
#echo $IMG_SIZE
[ “0$IMG_SIZE” -ne 0 ] && mkisofs -r 目錄/ | cdrecord speed=n dev=0,6,0 tsize=${IMG_SIZE}s -data –
音樂:
可先用 sox 把 wav 轉為 cdr,亦可直接燒錄:
cdrecord -v speed=n dev=0,6,0 -audio 1.cdr 2.cdr …
cdrecord -v speed=n dev=0,6,0 -audio 1.wav 2.wav …
cdrecord -v speed=n dev=0,6,0 -audio 1.au 2.au …
燒 mp3, 建議用 speed=1,避免燒太快,而使得 mpg321 來不及轉換資料.另外一個原因則是 mpg321 佔用CPU資源太多.
for I in *.mp3
do
mpg321 -cdr – “$I” | cdrecord -audio -pad -nofix –
done
cdrecord -fix
對燒:
cdrecord -v dev=0,6,0 speed=2 -isosize /dev/scd0
先放為 image 的話
dd if=/dev/scd0 of=cd_image
cdrecord -v dev=0,6,0 speed=2 -isosize cd_image
UDF 不知是否好用??
燒錄 cd-rw 時,可以用 blank=fast, 等同於快速抹除 CDRW.
續燒的方法(multi-session)
NEXT_TRACK=`cdrecord -msinfo dev=0,6,0`
echo $NEXT_TRACK
mkisofs -R -o cd_image2 -C $NEXT_TRACK -M /dev/scd0 目錄/

rsync HOWTO

Server
======
Put rsyncd.conf to /etc/xinetd.d/ .
Put rsyncd.secrets to /etc.
Then turn on rsync service: chkconfig rsync on
Client
======
Edit a text file contained your password and named “password”.
Then,
export RSYNC_RSH=/usr/bin/ssh
Run this to get the source from rsync server:
rsync -vzrtopg –progress –delete root@172.16.97.212::cpp . –password-file=/root/password
If you modified some thing, want to put them to rsync, run this command:
rsync -vzrtopg –progress –delete . root@172.16.97.212::cpp –password-file=/root/password
Notice
======
1. Server: The owner and permission of secret file must be correct! (0600)
2. Client: The owner and permission of password file must be correct, too!! (0600)
3. You may refer the log file to find why error happened.
rsyncd.conf
===========
uid = root
gid = root
use chroot = no
max connections = 4
syslog facility = local5
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
lock file = /var/run/rsync.lock
[cpp]
path = /root/cpp
comment = root
ignore errors
read only = no
list = yes
auth users = root
secrets file = /etc/rsyncd.secrets
rsyncd.secrets
==============
root:your-password
rsyncd usual syntax
===================
rsync -a srcdir remotehost:/destdir # Local -> Remote
rsync -a remotehost:/srcdir destdir # Remote -> Local
rsync -a -e ssh srcdir user@remotehost:/destidr # via SSH
rsyncd switchs
==============
-n Dry-Run, only simulate rsyncing.
-v,-vv,-vvv verbose.
–delete Remote all files in destination that doesn’t appear in source.
–delete-exclude Like –delete, but exclude specified files.
-z With compression.
-s Efficient with sparse files.
-b Append ‘~’ for existed files in destication.
–backup-dir=DIR Move existed files in destincation to DIR.
–exclude FILE Exclude specified files.

Remote syslogging

1.確定 /etc/services 裡面有 syslog 514/udp 這一行.
2.執行 /sbin/syslogd -r 啟動 syslogd daemon.
-r 是告訴 syslogd 開始傾聽 UDP port 514.
3.如果你有使用 iptables 或 ipchain 把某些 port 關掉的話,記得要作必要設定.
以下的指令表示只允許某個網段的機器才能使用 UDP port 514,而其他所有的網段則完全不能.
以保障這台用來作為 syslog 機器的安全.
iptables -A INPUT -p udp -s 192.168.2.0/24 -d 0/0 –destination-port 514 -j ACCEPT
iptables -A INPUT -p udp -s 0/0 -d 0/0 –destination-port 514 -j REJECT 或
ipchains -A INPUT -p UDP -s 192.168.2.0/24 -d 0/0 514 -j ACEEPT
ipchains -A INPUT -p UDP -s 0/0 -d 0/0 514 -j REJECT
4.在每台要 log 的機器上,編輯 /etc/hosts, 把 syslog 機器的 ip 加進去
192.168.2.23 parent.somedomain.com parent
5.同樣在每台要 log 的機器上,編輯 /etc/syslog.conf, 將目的檔由原本的
/var/log/messages, /var/log/….. 等改為 @parent
6.重新啟動或用 kill -HUP 讓 syslog 重讀設定,就完成了!!

mono Overview & xsp-0.2

今天心血來潮,連上Mono 官方網站(http://www.go-mono.net/)一看,版本已經是 0.19 ,然後又加了許多新玩意兒~Debugger, asp.net, ado.net…已經快要把 M$ 的 .NET Framework 實作完成了呢 🙂
Mono 簡單的說就是 Linux 上的 .NET Framework.
安裝方法很簡單,現在網站上有提供各種 Package: rpm, deb…都有,所以只要找到適合你版本的 Package, 下載回去安裝就行了.
我用的是 Red Hat 7.3 的版本
所以用
rpm -ivh libgc-6.1-1.i386.rpm libgc-devel-6.1-1.i386.rpm mono-0.19-1.i386.rpm mon-devel-0.19-1.i386.rpm
就完成安裝了~~
mono 的編譯:
當你寫好一個 .cs (c#的 source)以後,就可以用
mcs your-source.cs
進行編譯.
mono 的執行是比較特別的一點
雖然它實作 .NET Framework ,但執行的方法卻不是跟 .NET 一樣,直接執行就好
而是比較類似 java, 用 mono hello.exe 來執行.
接著是 xsp, xsp 等同於是 asp.net 的實作,只是他還包含了一個小的 Web Server,不過還沒有完全實作好~也暫時沒辦法把她掛到 Apache ,當作一個 module. 🙁
令我驚訝的是,它是用.NET 寫的.想了解 asp.net 內部如何實作的人,這是一個很好的途徑.
安裝方法很簡單,執行 make, make install 就行了
她會把檔案都安裝到 Makefile 所在目錄的 server/test 下.
不過,這一版 0.2 還有一些缺陷,所以依照他的 INSTALL 去做以後,還是不能順利的執行
據我明察暗訪之後,發現要:
1.必須先切換到 server/test 下,執行 ln -s server.exe xsp.exe
2.用 browser 瀏覽的時候,必須確實指定路徑,假設你把 xsp 解在 /root/xsp-0.2 ,也安裝在 /root/xsp-0.2 下的話,那麼,你在 browser 上應該要打 http://localhost:8080/root/xsp-0.2/server/test/index.aspx
這樣子就可以執行了~~
蠻令人驚訝的~
與資料庫連結的部份,我沒有去仔細測這部份,不過我想應該是可以執行的!
嗯~~
希望大家用力多多測試,並且把 bug 回報回去~
這樣子,大家才會有好東西可以用啦 🙂

bacula Overview

Bacula 一個提供備份 Solution 的 Open Source Project
http://www.bacula.org/
裡面主要分成五個部份:
– Director 負責 Backup/Restore/Verify 和 Archive 這幾個動作,它是 Daemon.
– Console 用來跟 Director 溝通的 Interface
– Files Client Program,也是一個 Daemon, 負責提供檔案屬性跟 Director所需的資料.
– Storage 負責讀/寫你的 Tape 或其他媒體.
– Catalog 維護索引或 Volume Database.
架構圖:
bacula.jpg
安裝請依照慣例的 ./configure, make, make install 三部曲即可
安裝完成以後,測試 conf 檔案是否有問題:
#bacula-dir -t
#bacula-fd -t
#bacula-sd -t
#console -t
如果想讓 bacula daemon 在開機時自行啟動的話:
#make install-autostart
只裝 File Daemon(Client) 的話,用:
#make install-autostart-fd
主要設定都在 bacula-dir.conf 裡面
可以定義 Storage, Schedule, Job….等等資訊.
bacula-sd.conf 主要定義 Storage, Device 相關資訊.此處需要跟 bacula-dir.conf 中的 Storage 相配合.
bacula-dir.conf
FileSet{} 定義需要備份的目錄或檔案.
Storage{}表示要放Archive 的地方.
Schedule{} 定義執行的排程.
Job{} 則定義工作,裡面則會用到前面所提到的 FileSet, Storage, Schedule 等設定.也可以在執行的前後先執行 Script或程式(RunAfterJob, RunBeforeJob).
還可以設定 Job, Volume …等的保留時間( Retention ).
另外也支援自動換片的 Device, 只要在 Device {} 裡面指定 Change Command = /sbin/xxxx
換片的指令即可.
提供的 PDF 文檔非常詳盡,有兩百多頁~~
也支援 Windows 的 File Daemon(Client Program)
看完以後
覺得整個架構很清晰
也蠻便於管理的~
只是很多東西都必須在 conf 檔中定義好
而無法利用 Client 程式動態的指定Job, Schedule, FileSet …等~

rpm-update

網址:http://www.kleemann.org/rpm-update/
如果你因為不想去 Red Hat 而不使用 up2date,那麼,你可以試試這個程式.
目前最新的版本是 20030102 這個版本.
網站除了 Source 之外,也提供 rpm 可以下載.
(其實也沒有什麼 Source 不 Source 的,因為它是用 Python 寫的)
下載之後,使用 rpm -ivh rpm-update-1-20030102.noarch.rpm 安裝~
安裝應該會很順利,rpm檔裡面只有一個檔案而已.
ok~那麼怎麼使用呢??
先建立此目錄 /var/cache/rpm-update, 因為後面其實會用到此目錄.
但作者可能忘記了.
用 rpm-update -l 列出所有的站台,它是到 Red Hat 網站把 mirror 的網頁抓下來,然後把所有的ftp位址都 grep 出來.
知道位址之後,就可以下載啦~
用 rpm-update -d –host linux.sinica.edu.tw –single 下載
-d 是指 download
–host 是指定位址
–single 則是請 rpm-update 依據目前電腦的 ix86 去抓檔案,如 i386, i686…等等~
用 rpm-update -r –single 進行分析,並列出報告
-r 是指 report
最後,當然就是用 rpm-update -i –single 進行安裝啦.
如果你懶得打那麼多指令
你也可以編輯 ~/.rpm-update/default 這個檔案
把選項都放進去,如:
host = linux.sinica.edu.tw
single
version = 7.3
以後 rpm-update 的時候,就不需要打 –host, –single,直接打 rpm-update -d, rpm-update -r…就行了
安裝完了,不想保留那些 rpm 檔案的話
可以用 rpm-update -c 把 rpm 檔案清除掉.
要讓它自動定期去尋找更新的 rpm,當然也可以放在 crontab 裡面
作者提供了一個不錯的用法:
(rpm-update -d && rpm-update -r) | mail -s “RPM Update” yourname@yourdomain.com
這樣子就行了.

Journaling File Systems

原文出自http://www.linux-mag.com/2002-10/jfs_01.html,本文僅做筆記摘錄,並翻譯摘錄部分.
Linux now offers four alternatives to Ext2: Ext3, ReiserFS, XFS, and JFS.
Linux 現在提供四種不同於 Ext2 的選擇: Ext3, ReiserFS, XFS, and JFS.
They supports journaling, a feature certainly demanded by enterprise, can simplify restarts, reduce fragmentation, and accelerate I/O.
她們都支援日誌(journaling),一個企業級所需的特色,它可以簡單的重新啟動,減少碎裂(fragmentation)和加速I/O.
Some vernacular of file systems:
一些關於 file systems 的常用語:
A “logical block” is the smallest unit of storage, measured in bytes, and it may take several blocks to store a single file.
一個 “logical block” 是 Storage 中最小的單位,以bytes作單位,而通常一個檔案會花好幾個 block 來存放.
A “logical volume” can be a physical disk or some subset of the physical disk space.
一個 “logical volume” 可以是一個邏輯磁碟或實體磁碟空間的集合.
“Block allocation” is a method of allocating blocks where the file system allocates one block at a time.
“Block allocation”:索取 block 的方法.
“Internal fragmentation” occurs when a file does not a fill a block completely.
“Internal fragmentation” 內部碎列,當有很多 block, 而每個 block 都沒有完全塞滿時.
“External fragmentation” occurs when the logical blocks that make up a file are scattered all over the disk.
“External fragmentation” 外部碎列,當一個檔案分散在很多且不同的 block 上時.
An “extent” is a large number of contiguous blocks. described by a triple, consisting of (file offset, starting block number, length), where file offset is the offset of the extent’s first block from the beginning of the file, starting block number is the first block in the extent, and length is the number of blocks in the extent. For large files, extent allocation is a much more efficient technique than block allocation.
“extent” 一堆連續的 blocks, 包含 file offset, starting block number, length. file offset 就是相對於檔案的位址, starting block number 就是起始的 block 號碼, length 就是 block 的數目.
“meta-data” is the file system’s internal data structures. Meta-data includes date and time stamps, ownership information, file access permissions, other security information such as access control lists (if they exist), the file’s size and the storage location or locations on disk.
“meta-data” 就是 file system 的內部資料結構. 包含日期和時間戳記,擁有者,存取權限以及其他安全性資訊,檔案長度,和位置…
An “inode” stores all of the information about a file except the data itself. as a “bookkeeping” file for a file. An inode contains file permissions, file types, and the number of links to the file. It can also contain some direct pointers to file data blocks; pointers to blocks that contain pointers to file data bocks (so-called indirect pointers); and even double- and triple-indirect pointers. Every inode has a unique inode number.
“inode” 儲存檔案除了資料以外的所有資訊. 每個 inode 都有一個獨一無二的號碼.
A “directory” is a special kind of file that simply contains pointers to other files. Specifically, the inode for a directory file simply contains the inode numbers of its contents, plus permissions, etc.
“directory” 一種特殊的檔案,簡單的包含其他檔案的指標.當然也有 inode 和存取權限等資訊.
Corruption occurs because the logical operation of writing (or updating) a file is actually a sequence of I/O, and the entire operation may not be totally reflected on the media at any given point in time.
錯誤的發生是因為寫入(或更新)檔案的邏輯動作是循序的 I/O 動作,而這整個動作並未完全地反映到實際媒體上.
The magic of journaling file systems lies in transactions.
Journaling file system 的魔法是依賴於 transaction 之上.
treats a sequence of changes as a single, atomic operation.
就像是一個循序的改變,如同一個單一,極微的動作.
tracks changes to file system meta-data and/or user data.
追蹤 file system meta-data 和(或)使用者資料的變化.
The journal in a journaling file system is simply a list of transactions.
Journal 在 journaling file system 簡單的說就是一個 transaction 的列表.
In the event of a system failure, the file system is restored to a consistent state by replaying the journal.
在系統發生錯誤時,file system 就依照目前的狀態,回頭播放一次 journal.
inspects only those portions of the meta-data that have recently changed.
審查這些 meta-data 有被變動過的部份.
also address another significant problem: scalability.
但也有另外一個值得注意的問題: scalability 可靠性.
Features of modern file systems include:
現代檔案系統的特色:
– Faster allocation of free blocks. Extents (as described above) and B+ trees are used individually or together to find and allocate several free blocks, either by size or location, quickly.
快速地配置. Extents 和 B+ trees 被單獨(或一起)用來快速地尋找和配置數個閒置的 block.
– Large (or very large) numbers of files in a directory.
在一個目錄中能存在大量或很大量的檔案.
– Large files.
大量的檔案.
Ext3
designed to provide higher availability without impacting the robustness (at least the simplicity and reliability) of Ext2.
被設計來提供高可用度而使得 Ext2 不需面對太強的衝擊.
uses the same disk layout and data structures as Ext2, and it’s forward- and backward-compatible with Ext2
使用和 Ext2 相同的 disk 配置和資料結構, 而且它可以向前或向後相容於 Ext2.
limitations that Ext2 has. The fixed internal structures of Ext2 are simply too small (too few bits) to capture large file sizes, extremely large partition sizes, and enormous numbers of files in a single directory. Moreover, the bookkeeping techniques of Ext2, such as its linked-list directory implementation, do not scale well to large file systems (there is an upper limit of 32,768 subdirectories in a single directory, and a “soft” upper limit of 10,000-15,000 files in a single directory.)
限制和 Ext2 相同.固定的Ext2內部結構太小(太少bits),且使用的 Link list 在大磁碟環境下表現不佳.
Switching to Ext3
# tune2fs -j /dev/hdb3
Ext3 provides three data journaling modes that can be set at mount time: data=journal, data=writeback, and data=ordered. The data=journal mode provides both meta-data and data journaling. data=writeback mode provides only meta-data journaling. data=ordered mode, which is the default mode, provides meta-data journaling with increased integrity.
提供三種模式: data=journal(保護最完整), data=writeback(只保護 meta-data), data=ordered(預設,保護 meta-data之外,即較完整的journaling).
By the way, the 2.4 kernel has a limit of 2048 Gb for a single block device, so no file system larger than that can be created at this time (without patching the standard kernel). This restriction could be removed in the 2.5.x development kernel, and there are patches available to remove this limit, but as of 2.5.29, the patches haven’t been officially included yet.
目前 2.4 仍然有 2048Gb 的限制.
ReiserFS
One of the unique advantages of ReiserFS is support for small files — lots and lots of small files.
比較大的特色是支援小檔案,很多很多的小檔案.
ReiserFS is about eight to fifteen times faster than Ext2 at handling files smaller than 1K.
在處理很多小於1k的檔案時,它比 ext2 快七到八倍.
ReiserFS can actually store about 6% more data that Ext2 on the same physical file system.
在和 Ext2 相同的情況下,她也可以存比 Ext2 多 6% 的資料.
ReiserFS can allocate the exact space that’s needed. A B* tree manages all file system meta-data, and stores and compresses tails, portions of files smaller than a block.
只配置實際所需的空間. 使用了 B* tree 管理.
also has excellent performance for large files, but it’s especially adept at managing small files.
同時也對大檔案有很好的效能,但他特別適合用來處理小檔案.
JFS
JFS uses many advanced techniques to boost performance, provide for very large file systems,
使用了很多先進的技術來加速.
SGI’s XFS (described next) has many similar features. Some of the features of JFS include:
XFS 也用了相似的技術. 這些技術包含了:
– Extent-based addressing structures. along with aggressive block allocation policies to produce compact, efficient, and scalable structures for mapping logical offsets within files to physical addresses on disk. This feature yields excellent performance.
Extent-based 定址的資料結構.
– Dynamic inode allocation. JFS dynamically allocates space for disk inodes as required, freeing the space when it is no longer required. Additionally, this feature decouples disk inodes from fixed disk locations.
動態的 inode 配置.自動配置所需的空間,並釋放不需要的空間.
– Directory organization. Two different directory organizations are provided: one is used for small directories and the other for large directories.
目錄的組織,使用了不同的目錄組織來分別處理大的和小個檔案.
– 64-bits. JFS is a full 64-bit file system. This allows JFS to support large files and partitions.
64-bits. 完全的 64-bit file system.
– such as allocation groups (which speeds file access times by maximizing locality), and various block sizes ranging from 512-bytes to 4096-bytes (which can be tuned to avoid internal and external fragmentation).
還有,配置群組及可變動的 block-size.
XFS
A single XFS file system can be 18,000 petabytes (that’s 1015 bytes) and a single file can be 9,000 petabytes. XFS is also capable of delivering excellent I/O performance.
一個單一個 XFS file system 最大可以到 18,000 petabytes 和單一檔案可達 9,000 petabytes. 同時也有能力提供最好的I/O效能.
uses many of the same techniques found in JFS.
使用了許多和 JFS 相同的技術.

vsftpd Overview

網址: http://vsftpd.beasts.org
vsftpd 她是目前號稱最安全的 FTP Server.
也是目前 Red Hat 8, Open BSD, Suse 所採用的 ftp server.
最新的版本是 1.1.3.
下載 tarball 以後,解開~
她不需要特別 configure, 只需要 make, make install 就可以了
make會自動安裝到 /usr/local/sbin 下面去~
而 conf 檔,則需要自行把 tarball 內附的 vsftpd.conf 複製到 /etc 去才行.
預設的 Server Type 是 inetd, 而不是 Standalone 型態~
所以你需要用 kill -HUP xinetd-pid
來請求 xinetd 重新載入 configuration.
預設的 Configuration 也很安全,完全不讓人登入,也不讓你寫入….非常的…嗯…安全~
你需要在 vsftpd.conf 裡面修改這幾個設定才能讓一般的使用者能登入並擁有寫入的權限:
local_enable=YES
write_enable=YES
如果要讓他以 Standalone 型態起來,則可以在設定裡面置入
listen=YES
並在 /etc/rc.d/init.d 裡面放 script 就行了
至於其他的設定,可以自行用 man vsftpd.conf 來找到用法.
和 proftpd 比較起來
設定是簡單了許多
蠻有那種樸實無華的味道~
再加上檔案又小~
沒什麼可以挑剔的~
期待 2.0 吧
2.0 的 beta 已經 release 了~
相信正式版應該很快就會 Release.

CVS 簡易說明

我們先假設 192.168.0.1 有安裝 cvs server
並且有三個專案在上面
怎麼用??
0. 確定自己電腦上有安裝 cvs
一般來說,如果是 Red Hat 或 Mandrake,那麼預設會有安裝
如果是其他的,我就不知道了
請到 www.cvsroot.org 去下載套件並安裝之
1. 設定
#當然你如果習慣用 vi, 這邊的 EDITOR 就設為 vi 的路徑
export EDITOR=/usr/bin/vim
#此處的 username, 要替換為自己的 username
export CVSROOT=:pserver:username@192.168.0.1:/home/cvsroot
export CVSREAD=yes
你可以把這些敘述放到 /etc/profile 或 /root/.bash_profile 裡面
免得以後每次用的時候還要再打一次
2. login
輸入
cvs lgin
cvs 會要求你輸入密碼,此密碼就是你在 192.168.0.1 上的密碼
3. checkout 將專案下載到你的電腦上
所以你可以打
cvs checkout clockd
cvs checkout helloworld
cvs checkout qt
把專案下載到自己的電腦上
4.
做完 checkout 後,你可以看到自己的電腦上出現了專案
先輸入 cvs edit xxxx
然後就可以做編輯了,你可以試著亂改, 加上一些註解或無聊的程式碼
做完修改後,當然要放回 server 囉
你可以用
cvs commit [檔案名稱]
指令來更新回 server, 更新之前, cvs 會打開 editor 讓你輸入一些文字,為這次的修改作一些說明
對了,如果別人在你修改之前修改了這個檔案,那麼 cvs 會自動將檔案作合併,讓你再去做編輯,請務必玩一玩
5.
如果要看目前的狀況,就打
cvs status [檔案名稱]
cvs diff [檔案名稱]
cvs history [檔案名稱]
來查看各種狀況
6.
不想要這個檔案加入版本管理的話,得先刪除該檔案後,再使用
cvs remove [檔案名稱]
來移除
7.若要登出 cvs server,則輸入 cvs logout 即可