wsql 发表于 2013-1-31 02:16:24

GmailFS

原文链接:

http://www.eygle.com/unix/GmailFS-Gmail.Filesystem.Config.htm

Google推出了1G的Gmail,随后很多邮件提供商都开始提供1G的Gmail,Google再一次领导了潮流.有了1G的Mail以后,怎么使用这么大的存储空间也成了一个问题:)
于是有人写出了GmailFS,Gmail Filesystem---Gmail文件系统.
你可以在以下链接找到相关内容:
http://richard.jones.name/google-hacks/gmail-filesystem/gmail-filesystem.html

我引用一下richard的说明:
GmailFS provides a mountable Linux filesystem which uses your Gmail account as its storage medium.
GmailFS提供可装载的Linux文件系统,使用Gmail帐号你可以使用Gmail作为存储介质使用.
GmailFS is a Python application and uses the FUSE userland filesystem infrastructure to help provide the filesystem, and libgmail to communicate with Gmail.
GmailFS是使用Python技术开发的应用,使用FUSE作为文件系统的基础架构,使用libgmail和Gmail通讯.
GmailFS supports most file operations such as read, write, open, close, stat, symlink, link, unlink, truncate and rename. This means that you can use all your favourite unix command line tools to operate on files stored on Gmail (e.g. cp, ls, mv, rm, ln, grep etc. etc.).
Please be gentle on the code. This is my first foray into Python and I'm sure the code is far from elegant. I'm particularly concerned with my attempts to manipulate mutable byte arrays. I'm sure that there must be a less clumsy way of doing it than the nasty list -> array -> string path I'm currently using. Python has a reputation as an excellent language choice for rapid prototyping.
The first working version of GmailFS took about 2 days of coding. There was an additional 1.5 days spent on performance tuning and bugfixing.
第一个可以使用的GmailFS版本大约花了2天时间编码,然后用了1.5天进行性能调整和Bug修正.
Given that this includes language learning curve, the reputation seems well deserved. A special mention should go to libgmail and FUSE, both greatly contributed to the short development time.
<div class="left style25">然后关注了一下Python:
Guido van Rossum于1990年开始开发Python,最初的目的无非是一个自娱的项目。作为Monty Python的飞行马戏团节目的爱好者,他给自己开发的这种编程语言起了现在这个古怪的名字,中文意思就是大蟒。Python最初设计为一种取代 Amoeba分布式操作系统ABC的脚本语言,但不久这种新型编程语言很快就发展成可以解决相当多问题的利器,现在更引入到了多种平台。
想一想,国外的开发者往往可以开发出功能强大的语言及工具.而我们国内就缺少这样的开发人员和这样的成绩.我们不缺少程序员和聪明人,我们缺少的是富于开创的天才.
言归正传,我们一起来看一下GmailFS的安装及配置.
这里涉及的所有软件的当前版本都可以从本地下载.
1.安装Python 2.3版本
How To Install Python 2.3 On Linux
然后作一个符号链接:
# ln -s /usr/bin/python2.3 /usr/bin/python# ls -l pythonlrwxrwxrwx    1 root   root         18 Sep 24 23:35 python -> /usr/bin/python2.3                      2.安装FUSE version 1.3
在以下地址可以下载: FUSE's SourceForge download page
安装步骤如下:

# tar zxf fuse-1.3.tar.gz# cd fuse-1.3# ./configure# make # make install安装日志参考: FUSE Install LOG
3.安装python FUSE module
安装步骤如下:
# tar zxf fuse-python.tar.gz
# cd fuse-python
# python setup.py build
# python setup.py install
安装日志参考如下:
# cd fuse-python# lsbuildcode.leoCVS_fusemodule.cfuse.pyINSTALLMakefileREADMEsetup.pyxmp.py# python setup.py buildrunning buildrunning build_pyrunning build_extbuilding '_fusemodule' extensiongcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.3 -c _fusemodule.c -o
build/temp.linux-i686-2.3/_fusemodule.ogcc -pthread -shared build/temp.linux-i686-2.3/_fusemodule.o -L../lib -lfuse -o build/lib.linux-i686-2.3/_fusemodule.so# python setup.py installrunning installrunning buildrunning build_pyrunning build_extrunning install_libcopying build/lib.linux-i686-2.3/fuse.py -> /usr/lib/python2.3/site-packagescopying build/lib.linux-i686-2.3/_fusemodule.so -> /usr/lib/python2.3/site-packagesbyte-compiling /usr/lib/python2.3/site-packages/fuse.py to fuse.pyc
4.安装libgmail
在这里下载,注意这里下载的文件格式为gz,但实际上是个tgz文件.
安装步骤为:

# tar zxf libgmail-0.0.8.gz
# cd libgmail-0.0.8
# cp libgmail.py constants.py /usr/lib/python2.3/site-packages

5.安装gmailfs
gmailfs可以在这里下载
安装步骤为:

# tar zxf gmailfs.tar.gz
# cd gmailfs
# cp gmailfs.py /usr/local/bin
# cp mount.gmailfs /sbin
# ln -s /sbin/mount.gmailfs /sbin/mount.fuse



6.开始使用gmailfs文件系统
你可以使用如下命令mount你的GmailFS:

mount -t gmailfs /usr/local/bin/gmailfs.py /mount_point -o username=gmailuser, password=gmailpass, sname=zOlRRa


在使用之前,你可以修改 /usr/local/bin/gmailfs.py 中的 DefaultUsername, DefaultPassword,以便可以简化gmailfs的使用.
<blockquote># mkdir gmail# mount -t gmailfs /usr/local/bin/gmailfs.py /gmail -o fsname=eygle# mount: warning, should mount with username=gmailuser option, using defaultmount: warning, should mount with password=gmailpass option, using default# df -k
Filesystem         1K-blocks      Used Available Use% Mounted on
/dev/sda1            5154852   3421812   147118470% /
/dev/sda7               101089   66140   2973069% /home
/dev/sda5            4127076   3347860    56957286% /opt
none                  515296         0    515296   0% /dev/shm
/dev/sda2            4127108   2268464   164899658% /usr
/dev/sda6            2063504    138360   1820324   8% /var
gmailfs                1024000   17408   1006592   2% /gmail
页: [1]
查看完整版本: GmailFS