GmailFS - Gmail Filesystem Install and Config

Saturday, 2004-09-25 1:07 Eygle
    

 

 

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.

然后关注了一下Python:
Guido van Rossum于1990年开始开发Python,最初的目的无非是一个自娱的项目。作为Monty Python的飞行马戏团节目的爱好者,他给自己开发的这种编程语言起了现在这个古怪的名字,中文意思就是大蟒。Python最初设计为一种取代 Amoeba分布式操作系统ABC的脚本语言,但不久这种新型编程语言很快就发展成可以解决相当多问题的利器,现在更引入到了多种平台。

想一想,国外的开发者往往可以开发出功能强大的语言及工具.而我们国内就缺少这样的开发人员和这样的成绩.我们不缺少程序员和聪明人,我们缺少的是富于开创的天才.

言归正传,我们一起来看一下GmailFS的安装及配置.

这里涉及的所有软件的当前版本都可以从本地下载.

1.安装Python 2.3版本

How To Install Python 2.3 On Linux

然后作一个符号链接:


[root@eygle bin]# ln -s /usr/bin/python2.3 /usr/bin/python
[root@eygle bin]# ls -l python
lrwxrwxrwx    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

安装日志参考如下:

 
[root@eygle soft]# cd fuse-python
[root@eygle fuse-python]# ls
build  code.leo  CVS  _fusemodule.c  fuse.py  INSTALL  Makefile  README  setup.py  xmp.py
[root@eygle fuse-python]# python setup.py build
running build
running build_py
running build_ext
building '_fusemodule' extension
gcc -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.o gcc -pthread -shared build/temp.linux-i686-2.3/_fusemodule.o -L../lib -lfuse -o build/lib.linux-i686-2.3/_fusemodule.so [root@eygle fuse-python]# python setup.py install running install running build running build_py running build_ext running install_lib copying build/lib.linux-i686-2.3/fuse.py -> /usr/lib/python2.3/site-packages copying build/lib.linux-i686-2.3/_fusemodule.so -> /usr/lib/python2.3/site-packages byte-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的使用.

 
[root@eygle /]# mkdir gmail
[root@eygle /]# mount -t gmailfs /usr/local/bin/gmailfs.py /gmail -o fsname=eygle
[root@eygle /]# mount: warning, should mount with username=gmailuser option, using default
mount: warning, should mount with password=gmailpass option, using default
[root@eygle /]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 5154852 3421812 1471184 70% /
/dev/sda7 101089 66140 29730 69% /home
/dev/sda5 4127076 3347860 569572 86% /opt
none 515296 0 515296 0% /dev/shm
/dev/sda2 4127108 2268464 1648996 58% /usr
/dev/sda6 2063504 138360 1820324 8% /var
gmailfs 1024000 17408 1006592 2% /gmail

接下来我们就可以使用GmailFS了:

 
[root@eygle /]# cd /home/gqgai/soft
[root@eygle soft]# ls -l
total 10929
-rw-r--r--    1 root     root      1480750 Sep 24 18:40 db4-4.1.25-14.i386.rpm
drwxrwxrwx    8 1001     1001         1024 Sep 24 23:48 fuse-1.3
-rw-r--r--    1 gqgai    gqgai      563200 Sep 24 17:35 fuse-1.3.tar
drwxr-xr-x    4 1002     1002         1024 Sep 24 19:06 fuse-python
-rw-r--r--    1 gqgai    gqgai       71680 Sep 24 17:35 fuse-python.tar
drwxr-xr-x    2 1002     1002         1024 Aug 30 08:24 gmailfs
-rw-r--r--    1 gqgai    gqgai       61440 Sep 24 17:35 gmailfs.tar
drwxr-xr-x    3 root     root         1024 Sep 25 00:14 libgmail-0.0.8
-rw-r--r--    1 gqgai    gqgai       18803 Sep 24 19:37 libgmail-0.0.8.gz
-rw-r--r--    1 root     root      7565683 Jul 23 10:59 python2.3-2.3.4-3pydotorg.i386.rpm
-rw-r--r--    1 root     root       678130 Jul 23 11:00 python2.3-devel-2.3.4-3pydotorg.i386.rpm
-rw-r--r--    1 root     root       690451 Jul 23 11:00 python2.3-tools-2.3.4-3pydotorg.i386.rpm
[root@eygle soft]# cp libgmail-0.0.8.gz /gmail
[root@eygle soft]# cd /gmail
[root@eygle gmail]# ls -l
total 19
-rw-r--r--    0 root     root        18803 Sep 25 00:32 libgmail-0.0.8.gz
[root@eygle gmail]# 

7.其他

在网上这个问题引起了广泛的讨论,参考这里.

有人认为既然有人可以用2天时间就开发出这样的程序,那么自然可以很轻易的把更多的Gmail连接起来作为网络存储.如果Google认为有必要来解决这个问题
那么所有的连接都可能被马上中断.那么这种技术就不具有稳定及可靠性.

也有人认为,这对于Google未尝不是一件好事,他们可以有更多的数据用以分析.

有人从实际观点出发,认为由于网络的问题,不具有实际价值.

这些都不是我关心的,我想说的是,这才是我们应该学习的专业精神.

 


如欲转载,请注明作者与出处.并请保留本文的连接.

回首页