12/30/2008

gcc 的问题?

最近我手头的项目代码编译报错,遇到两个问题,首先是出现以下错误:

include/mxdef.h:56: error ‘NULL’ was not declared in this scope

我的开发环境:
>gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.2.3/work/gcc-4.2.3/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.2.3 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.2.3/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.3/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.2.3/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --disable-libgcj --with-arch=i686 --enable-languages=c,c++,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.2.3 (Gentoo 4.2.3 p1.0)

>gcc-config -l
[1] i686-pc-linux-gnu-3.3.6
[2] i686-pc-linux-gnu-4.1.2
[3] i686-pc-linux-gnu-4.2.3 *
[4] i686-pc-linux-gnu-4.3.1

以前可以编译通过的,估计是更新 Gentoo 后带来的问题,我也不知道具体是哪里的问题,于是尝试用其它版本的 gcc 编译,用 gcc-4.1.2 编译结果和上面是一样的,而用gcc-4.3.1 编译之后,出现以下错误:

include/cdc.h:116: error: multiple parameters named ‘r’

头文件 cdc.h 第116行为:

static gal_pixel RGB2Pixel (int r, int g, int b, int r=255);

gcc-4.2.3以及4.1.2 都忽略这个了阿,这样可以声明的函数有没有问题?待确认。

第一个问题已经解决了,在头文件 mxdef.h 中增加
#include <string.h> 就可以了。

12/15/2008

用 Python 写了个脚本

最近完成了一个简单的脚本,写的过程中对 Python 有了进一步的了解。脚本的目的是把一个文本文件中的数据进行拆分,然后把结果存为 Excel 文件。其中拆分的过程中主要用到了正则表达式,写Excel 文件用的是 pyExcelerator,如果Excel 文件已经打开,写的时候会失败的,要加异常处理。

11/21/2008

Gmail 的主题

Gmail 可换主题了,好像是昨天推出的吧,Google 的产品每次出手都让人从心底里叫好,这次虽然只是一个功能的完善,但还觉得很不错,主题换了几个,还是觉得默认的好,另外那个终端的主题很受同事欢迎 :)
现在对 Google 的产品越发依赖了,每天必须去的地方:Google reader、Groups 和 Gmail等,偶尔打开 Blogger 发个帖,当然搜索必定是 Google 了。
另外,我也申请了 Google app engine,简单写了点东西,但一直没时间完善它,主要是自己想做点有新意的东西,苦于还没好的点子。。。

11/19/2008

好冷阿

再一次迎来了降温,仿佛一夜之间就进入了严冬,最低温度达到零下四度了,今天早上看到马路两边都是一地的落叶,估计象这样持续一周就该下雪了。
早上公交车上播着全球经济危机、国内不少商场打折促销之类的新闻,虽然自己还没明显的感觉,但还是“配合一下”────勒紧裤腰带过日子

11/12/2008

miniGUI 自定义控件

公司的新产品是触摸屏的,要使用软键盘,小头把这个任务安排给了我,于是上周几乎都在忙活这事,还好已经写得差不多了,对 miniGUI 自定义控件有了更深的体会,那就是“乱”。在 miniGUI 中添加自定义控件需要改 *.in 等一些文件,如果改的文件少一个了,编译也看不出来,但测试的时候就郁闷了,到头来只好回去检查 miniGUI 库的问题,总之比较麻烦,我是没办法,据说公司还掏了钱。其实很更好的解决办法,比如把涉及修改的地方都放到配置文件里面,至少不会改的晕头转向吧。
题外话:把图片直接通过 framebuffer 显示到的屏幕上(我们的产品屏幕为 800x480),挺漂亮的 :)

11/08/2008

北京的又一个冬天

窝在床上在网上逛着,虽然在房间里面,但还是觉得很冷,冬天到了哦,下周末就应该开暖气了吧,那时就好过多了,不过在公司一直觉得闷热,还穿短袖 @_^
明天继续打羽毛球,感觉水平提高的比较慢阿,主要是没有志同道合的人一起练习,嗯,自己多努力吧

10/10/2008

升级系统后进不了 X

工作用的台式机好久没更新了,于是前两天在下班前升级了系统
emerge sync
emerge -uDpv world
由于需要更新的包太多,就选了几个比较重要的包升级了,比如:xorg-x11, vim, gnome等等。结果第二天上班开机后进不了 X,赶紧查看 Xorg.0.log :(EE) Failed to load /usr/lib/xorg/modules/drivers/intel_drv.so ... (EE) No devices detected 很容易想到是显卡驱动的问题,在 emerge -au xf86-video-i810 之后上面的错误没了,但还是进不去 X,报“No devices detected” 的错误,重新 emerge xorg-x11、xorg-server 问题依旧。
怎么办?上班时间,容不得我瞎折腾。。。开始怀疑 xorg.conf 配置的问题,虽然之前用着好好的。
先备份 xorg.conf,然后运行 X -configure 让它自动生成一份 xorg.conf,最后 copy 新的文件到 /etc/X11/xorg.conf 下, /etc/init.d/xdm restart,great! 熟悉的登录界面出现了!
估计原来用着没问题的 xorg.conf在升级之后的 xorg 下有些不兼容吧,以后升级 xorg 一定要小心。

9/16/2008

ubiquity 真的是“无处不在”

也许是被 Google 的 Chrome 抢了风头,ubiquity 的发布似乎没引起人的注意,但是用过才知道它真的太强大了,感觉 Chrome 多余了:) 网上介绍 ubiquity 已经很多了,就不多说了,在这里说说它的自定义命令,也就是我们可以添加新的命令到 ubiquity 中。

可以打开ubiquity 的命令编译器(chrome://ubiquity/content/editor.html),然后输入:
function cmd_hello_world() {
displayMessage( "Hello, World!");
}
这个编译器是自动保存的,输入以上代码后,调出 ubiquity 界面,输入 hello_world 并回车,就能看到效果了,如果觉得不错可以和大家分享

详细的说明请参考教程:https://wiki.mozilla.org/Labs/Ubiquity/Ubiquity_0.1_Author_Tutorial#The_Ubiquity_0.1_Command_Tutorial

9/09/2008

北京地铁还有隐藏路线?

是的,我是今天才知道。网上是这么描述的:
总共只有3个:福寿岭、高井、54号,都修建于1965年,当时是为了战备,是防范空袭和运送物资的。

现在福寿岭站已经对地铁技校学生开放,高井站对北京军区家属开放,但都尚未对社会开放。54号站为地上车站,已经基本废弃。

每天有早晚各有两班地铁列车经停福寿岭、高井两站。

9/03/2008

试用 Google 浏览器 Chrome

得知Google 推出了自己的浏览器了,虽然暂时还没Linux 版,但我迫不及待想看看它的样子,于是特意切换到Windows 下试用了一把 :D 果然。。。又是如此地简洁,那么地清爽,速度也很快,没有让人失望。对了,about:memory 可以查看内存使用、浏览器进程等情况(Chrome 是多进程的) ,从内到外都让人眼前一亮阿。
不过有一点比较奇怪,我头一次用 IE下载的程序装不了(点击没反应),后来用firefox 下载的安装程序就没问题(大小一样的)

8/28/2008

好用的工具

今天找到两个比较好的工具 devtodo, conky

下班了,回家慢慢补充 :D

(续)
我最后用的 devtodo,感觉不错 :)

8/25/2008

育儿

1.当不让孩子做不该做的事情(如要不该要的东西)哭闹打滚时,父母要视而不见,不要去哄,除非孩子做危险的事情,时间一长孩子自己就不哭了
2.当孩子做错事请时,不要把他自己关在房子里待着,要多交流
3.下班回家后,要大声叫孩子的名字,并说我回来了,然后和孩子一起玩至少20分钟
4.父母每周至少陪孩子外出游玩半天

(以后陆续补充)

安全解决 blocking 问题

[blocks B ] sys-apps/setarch (is blocking sys-apps/util-linux-2.13.1.1)
[blocks B ] sys-apps/mktemp (is blocking sys-apps/coreutils-6.10-r2)
[blocks B ] >=sys-apps/coreutils-6.10 (is blocking sys-apps/mktemp-1.5)

类似上面的问题,在gentoo 系统中是经常遇到问题,一般情况下可以先删除(emerge -C)再安装,但这样做不太安全,特别是对于一些重要的 packages,再安装时会找不到需要用的命令),可以采用下面的方法解决:

emerge --buildpkgonly --nodeps util-linux && emerge -C setarch && emerge --usepkgonly util-linux
emerge --buildpkgonly --nodeps coreutils && emerge -C mktemp && emerge --usepkgonly coreutils

也可以把 package 加到 package.mask 中,然后在 emerge,如下:

把 bash 先加到 /etc/portage/package.mask 中,这样 emerge portage 就不会报错了,然后再把 /etc/portage/package.mask 中的 =app-shells/bash-3.2_p33 拿掉,再 emerge bash

8/22/2008

GDB 技巧

比较有用的命令:

1.p(print) Print value of expression EXP
p/x Print value of variable and format it are x(hex)
2.ptype Print definition of type TYPE
3.whatis Print data type of expression EXP
4.display Print value of expression EXP each time the program stops
5.define Define a new command name
6.layout Change the layout of windows. Layout names are: src/asm/split/regs

举例如下:

获取struct page结构的大小
(gdb) p mem_map
$80 = (struct page *) 0xc1000000
(gdb) p mem_map+1
$81 = (struct page *) 0xc1000020
(gdb) p/x 0xc1000020 - 0xc1000000
$82 = 0×20

p *array@len


自定义函数
(gdb) define nbt
Type commands for definition of “nbt”.
End with a line saying just “end”.
>next
>bt
>end
(gdb) nbt

TUI模式
layout src 仅显示源代码窗口
layout asm 仅显示汇编代码窗口
layout split 显示源代码和汇编代码窗口
layout regs 显示寄存器和源代码窗口,或者寄存器和汇编代码窗口
layout next , layout prev 切换窗口
C+l 刷新屏幕
C-x 1 只用一个窗口
C-x 2 用两个窗口,按多次会有不同两个窗口的组合形式
C-x o active 窗口转移
C-x s 进入和退出TUI SingleKey 模式
C-x a 退出TUI模式,回到传统模式

7/23/2008

暂时告一段落

前段时间比较忙,周六都要加班,一切都是为了公司的新产品,应该是今年的“重头戏”了。昨天总监已经拿着产品到美国做 DEMO了, 现在可以喘口气了 :)

6/17/2008

常用的英语单词缩写及常用口语表达

常用的英语单词缩写

4ever = forever
ASL = Age/Sex/Location 年龄、性别、住址
ASAP = As soon as possible尽快
ATST = At The Same Time同时
B4 = Before前面,以前
BTW = By the way 随便说一下
BBN = Bye Bye Now再见
BBL = Be back later 稍后回来
BRB =Be right back 很快回来
Biz = Business交易
BR = Bathroom浴室
BRT = Be Right There马上到
BS = Big Smile笑脸
BWDIK = But What Do I Know?我怎么知道
CU = See you 再见
CUL = See you later 下次再会
CIO = Check It Out算出来,解决
CSL = Can’t Stop Laughing忍不住笑
CWYL = Chat With You Later一会儿再聊

============================

美国人平时所用的许多短语,看似普通,但有的会有特殊意义,究竟是俚语、口语或俗语,没有绝对的定义。其实名称不重要,最重要的是懂得意义和用法,不是吗?

  1. to have(many) irons in the fire: to have a lot of activities going on at the same time(同时有许多事,想马上全部做完,但又不知从何开始,似乎忙得不可开交)

  Don't bother him because he has many irons in the fire.

  别打扰他,他事情太多,忙得很!

  Some people even like to have many irons in the fire.

  有些人喜欢有很多事忙忙碌碌。

  2. to talk over (one's) head(s): to use large or big words so that audience will not understand exact meaning(指所谈论的内容过于专业或高深,非一般人可以理解;也指有人为了表?F自己才学非凡,故意谈些高深理论或用些难字,吓唬?e人)

  Dr. Lee's lecture was so specialized that he almost talked over our heads.

  李博士的演讲太专业了,几乎使我们无法理解。

  In order to show his profound knowledge he talks over my head.

  为了表?F他的学问高深,他故弄玄虚。

  3. to put (something) back into (in) its cage: to put something under control (可以控制某件事情,多半指政治、健康等)

  We are trying to put inflation back into its cage and our economy is on the mend.

  我们正在设法控制通货膨胀,同时改善我们得经济。

  Diplomats and politicians need to put aggression and hostility back into its cage.

  外交官和政客应该收敛攻击和敌对的行为。

  4. to keep (one's) fingers crossed: to hope something good will happen (祝福某人好运或一切顺利。把食指与中指交叉,祈求好运,是老外的迷信,但在写信或正式场合,多半是用"I wish you best (good) luck!"或"Good (best) luck to you!")

  He keeps his fingers crossed hoping his father will send him more money.

  他盼望有好运,老爸能多寄点钱给他。

  Many people have been keeping their fingers crossed that we can live in a peaceful world.

  许多人都在祈求好运,盼能在和平的世界里生活。

  5. to stretch (one's) legs:to relax or to take a short break (久坐后,把腿舒展一下,或稍微休息一下)

  Let's take ten minutes to stretch our legs.

  让我们先休息十分钟。

  May I take a break so that I can stretch my legs?

  我可以休息一会儿伸伸腿吗?

  During the a long flight from the US to Taiwan, I normally stretch my legs every two hours.

  在从美国到台湾的长途飞行中,我通常每两个小时起身走走。

  6. to read between the lines:to interpret the hidden meaning or a hidden message; to discern the true fact (从字里行间体会隐含的意义;领会言外之意或能了解其中的真正意义)

  As you look at this poem, be sure to read between the lines.

  读这首诗的时候,要从字里行间去体会它的含义。

  After he re-read the love letter between the lines, he realized that he was dumped by his sweetheart.

  重读情书之后,他终于明白他已经被情人抛弃了。

  7. to let off steam:to give vent to one's anger(发泄、出气,像放掉蒸汽以减少压力似的。这与"to fly off the handle"意思相近,但比"to lose temper"委婉客气些)

  What will you do if your wife lets off steam?

  假如你太太大发脾气的话,你该怎么办呢?

  (因为谈论的对象使对方的太太,所以语气要委婉客气些)。

  但是谈到第三者,就可不必太委婉,可用lose temper:

  What will you do if one of your staff lose temper?

  如果你的同事冲你发脾气你该怎么办呢?

  Occasionally we should be given a chance to let off steam.

  我们应该不时的发泄一下情绪。

  8. to pay through the nose:to pay too much for something or excessively expensive(花费太多,代价过高,与" to cost an arm and a leg"意义相近)

  Don't pay through the nose when you buy the furniture.

  不要花太多的钱买家具。

  Some women paid through the noses for their jewelry.

  有些女人花大把的钱购买珠宝首饰。

  9. to take center stage:to be in the spotlight (引人注目的中心人物;以某人为公众瞩目的对象)

  Mrs. Lin always takes center stage at a party.

  林太太总能成为宴会上的焦点。

  President Bush takes center stage wherever he goes.

  布什总统不论走到哪里,都是公众瞩目的焦点。

  His constant taking center stage could deprive him of his privacy.

  他好出风头的毛病让他毫无隐私可言。

  10. to drag(one's)feet:to procrastinate or postpone(慢慢的拖延,行动迟缓,拖拖拉拉)

  It is not a good idea to drag your feet when the work needs to be done.

  拖延工作是不好的。

  No employers like for their employees to drag their feet on any project.

  工作拖拖拉拉的员工总是不受欢迎的。

  11. to paint(someone or oneself)into a corner:to trap oneself or someone; to be in trouble(使自己或某人陷入困境,应该注意的是即使主语是复数形式,corner仍然用单数)

  Don't try to paint yourself into a corner.

  不要让自己身陷困境,无法脱身。

  After a heated debate with his boss, Mr. Chen has painted himself into a corner.

  和老板激烈的争辩之后,陈先生处境十分不妙。

  12. to ask (someone) for (one's) hand:to ask girl's parents for marriage approval(指男人请求女方家长应允将女儿嫁给他,这里的"someone"是指女方的家长,"one"则是指要求婚的对象,hand只能用单数形 式)

  Mr. Su asked me for my daughter's hand.

  苏先生到我家来向我女儿提亲。

  He has asked her parents for their daughter's hand.

  他请求她的父母应允他们的婚事。

  13. to move onward and upward:to be promoted;from good to better situation(情况得以改善,或往更好的情?r发展)

  He hopes to move onward and upward with his current company.

  他希望能在现在就职的公司里顺利发展,步步高升。

  Many young couples try to move onward and upward during their marriage.

  许多年轻夫妇都希望能够婚姻美满幸福。

  14. to call a spade a spade:to be honest, blunt or frank(直言不讳,有啥说啥)

  My wife always calls a spade a spade about her work situation.

  我妻子对别人谈起她的工作时,总是直言不讳。

  Calling a spade a spade on foreign affairs sometimes seems difficult for diplomats.

  外交官在处理外交事务的时候很难做到直言不讳。

  15. to play cat and mouse:to play games with aggressive and passive attitude

  玩猫戏老鼠的把戏,欲擒故纵

  In business negotiations, there are always cat-and-mouse games.

  在商业谈判中,常会有一些猫戏老鼠的把戏。

  The police have played cat and mouse with the murderer.

  警察对凶犯采用的是欲擒故纵的策略。

  16. to go on the dole:(of the unemployed) to live on public welfare(失业人员依靠政府救济金生活。)

  Thousands of Americans are out of jobs and may go on the dole.

  美国成千上万的失业者靠领取政局救济金生活。

  Some people have gone on the dole for years.

  有些人多年来就是靠政府救济生活的。

  17. to be in the hot seat:to be under lots of pressure or in a difficult position(处于困境,面对很多压力)

  He has resigned from his job because he has been in the hot seat for years.

  由于不堪多年的工作压力,他终于辞职了。

  When testifies before Congress, he will be in the hot seat.

  在国会作证的时候,他将面临巨大的压力。

  18. to make waves:to make trouble(惹是生非,与"rock the boat"意思相近)

  Many politicians like to make waves in order to be kept in the media.

  许多政客为了能在媒体上路脸儿而不惜哗众取宠。

  Teenagers tend to make waves with their parents and teachers.

  一些青少年总是会给父母和老师惹麻烦。

  19. to keep (one's)nose clean:to keep away from trouble(远离是非,少惹麻烦)

  The newly released inmates are trying to keep their noses clean.

  刚刚获释的犯人总是尽量少惹是非。

  A law-abiding person needs to keep his (her) nose clean.

  奉公守法的人应该避免制造麻烦。

  20. to drive (someone) up the wall:to annoy or upset someone(惹人生气或者不高兴)

  The boy is driving his mother up the wall because of his ill behavior.

  这个不听话的孩子让他妈妈大为头痛。

  If you ask too many questions, you may drive your boss up the wall.

  假如你的问题太多也会让你的老板很反感。

  21. to write(someone or something)off:to throw away or to discard(抛弃或者丢弃);to deduct a business loss(在经商失败时,也用于报销、注销或扣除损失的数额中)

  After a hot argument, she wrote off her boyfriend.

  她和男朋友大吵了一架之后,就把他甩了。

  He will write off the charitable contributions from his income taxes.

  他从所得税中扣除了慈善募捐的金额。

  22. to take up with (someone):to date someone or to fall in love with someone(对某人产生兴趣,或与某人开始亲密交往)

  After he met her at the bar, he took up with her.

  自从在酒吧见过一面之后,他对她产生了兴趣。

  As she is such a pretty woman, many men would like to take up with her.

  像她这么漂亮的女人,许多男人都对她有兴趣。

  24. to pave the way to (or for):to make the path or to lay a groundwork of something(为......铺平道路或为......做好准备)

  A good education will pave the way to finding a decent job.

  好的教育是好的工作的基础。

  Early space exploration has paved the way for the current space station.

  早期的太空探索为如今的太空站建设奠定了基础。

  25. to paint the town red:to enjoy oneself; to have a good time(尽情享受)

  He is going out tonight to paint the town red.

  他今天晚上要玩个痛快。

  Miss Chen really painted the town red last week with her friends.

  陈小姐上周和朋友玩得很尽兴。

4/18/2008

gentoo 技巧

使用 gentoo 一段时间了, 一些比较有用的命令总结在这里:

ufed - 修改 USE
qlist - 列出包中文件
equery - 查询已安装的包或包中包含的文件等
eix - 可代替 emerge 更新查询,速度快
euse - 命令行式的 USE 编辑器
emerge -fuDv world - 更新整个系统安装的包,但仅下载不编译
emerge -avuDN world - 更新整个系统安装的包,下载并编译
emerge -p --depclean - 删除未列入 world 中的包或垃圾文件
revdep-rebuild - 重新编译依赖
eselect profile list - 列出系统中所有的 profile 文件
eselect profile set * - 设定系统 profile

xdpyinfo | grep dimensions
1024 x 768
xdpyinfo | grep resolution
116 x 116 ?

history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
- 列出系统当前用户曾使用的命令及百分比

4/14/2008

辞职了

在这家公司待了两年多了,现在的公司已经物是人非,是该离开的时候了。辞职申请已经交上去了,已经得到上面的答复,也已经找我谈话了,但去意已决。这周应该是我在这家公司待了最后一周了,这段时间比较轻松了,我正整理着电脑里面的有用的和没用的资料,有些文件好久都没动过了,都“长毛”了吧 :P
昨天是周末,我去医院做了入职体检,能够当场得到结果的检查都正常,周二去拿另外两项检查结果,应该也没问题。
下周就要去新公司上班了,好好努力,希望自己能更上一层楼!

3/06/2008

curl 实现表单提交

curl -D "/client/GK.txt" -d "spcode=608511&sppassword=sohu332416" "lu.blog.com:80/sp/login.do"

-D 将JSESSIONID 等值放入 GK.txt 文件中

curl -b "JSESSIONID=EC0AE12D30BA57B10AB68E558067B765;" -d "tonetype=0.5" "http://lu.blog.com/sp/UploadServlet?tonetype=0.5"

-b 带入JSESSIONID
-d 以POST方式提交

curl -b "JSESSIONID=AAB5E9FBA659044518C09A18B2310271;" -F file1/childring_file/7/1/爱神厄洛斯的漫游.asf" "lu.blog.com/sp/UploadServlet"

-F 上传文件

把产生的cookie保存在fee.cookie文件里
curl -d "user=test&pass=111111&ip=192.168.1.1&type=2&type=1&action=%C1%AC%BD%D3%CD%F8%C2%E7" --cookie-jar fee.cookie 192.168.252.4/login.jsp

读取上一步产生的session cookie即fee.cookie文件。共享上一步操作的session cookie值
curl --cookie fee.cookie --referer -d "http://192.168.252.4/user/network/connect_action.jsp?ip=192.168.1.1&type=2"

2/25/2008

关于 subversion(svn)

简单讲一下 svn 从创建 repository 到 checkout 的步骤:

1) svnadmin create /home/dev/work/repository

2)修改 repository/conf 下配置文件
passwd 文件:
[users]
dev = dev

svnserve.conf 文件:
[general]
anon-access = read
auth-access = write
password-db = passwd

3)启动服务
svnserve -d -r /home/dev/work/repository

4)导入工作拷贝
import . svn://localhost/mytest --username=dev --password=dev -m"Init mytest directory"

5) 后续工作

svn checkout svn://localhost/mytest

svn add

svn commit -m""

svn ls svn://localhost

2/17/2008

拯救被删的文件

Linux 下误删文件后,怎么恢复呢?可以参考以下步骤:
  1. 第一时间将要拯救的 ext2 分区 (比如我的是挂到 /mnt/entertain 的 /dev/hda9) 挂载为只读模式:

    # umount /mnt/entertain
    # mount /dev/hda9 /mnt/entertain -o ro

  2. 运行 debugfs 里的 lsdel 获取最近被删的文件列表 (lsdel 命令运行会需要一点时间, 请耐心等等):

    # debugfs /dev/hda9
    debugfs 1.35 (28-Feb-2004)
    debugfs: lsdel

  3. 根据 lsdel 给出的列表中的时间, 想想自己是在什么时候删的, 这样可以找到相应的被删文件的 inode, 例如我是在昨晚 (01 月 22 日) 8 点多删的那个电影, 于是在 lsdel 列表里找到对应的这几个记录:

    311298 1000 100644 1136 1/ 1 Sat Jan 22 20:24:50 2005
    311299 1000 100644 62 1/ 1 Sat Jan 22 20:24:51 2005
    311300 1000 100644 730628096 178552/178552 Sat Jan 22 20:24:51 2005
    311297 1000 40755 0 1/ 1 Sat Jan 22 20:24:52 2005

  4. 使用 dump 命令恢复数据到另一分区. 很明显, 这几项记录就是被我删掉的那个电影 (包括它的文件夹, 它的两个文本信息文件, 它自己 (第三行, 大小为 730628096 那个)). 我只需要电影本身, 于是查到它的 inode 值 (第一列) 为 311300, 接着在 debugfs 的提示符里使用 dump 命令将它拯救到另一个分区里 (比如我的 /mnt/share/dump)

    # debugfs /dev/hda9
    debugfs 1.35 (28-Feb-2004)
    debugfs: lsdel
    debugfs: dump <311300> /mnt/share/dump/movie.avi

    留心括起 inode 值 311300 的那俩尖括号 <>, 这是必须的, 否则 debugfs 会告诉你找不到文件.
  5. 重复 dump /path/to/file 命令一个个恢复你还想拯救的文件