然后,我就在Linux-fans里面求助,在wall_john的的帮助下,得到了解决办法。(其实我之前就在wall_john的blog里面找到了这篇文章,但是因为懒得重编软件而没有使用——想找一个更加适合懒人的办法。:P)
今天,因为在学习使用ybuild,所以,顺便就弄一下那个软件包。经过一番努力,终于搞定了!呵呵。先说说方法吧:
1. 到wall_john的blog里下载gnome-mount-0.4-ntfs-mount.patch;
2. 到fedora下载服务器下载gnome-mount的src.rpm;
3. 安装源码包
# rpm -ivh gnome-mount-0.4-5.src.rpm
4. 修改spec文件
# vi /usr/src/redhat/SPECS/gnome-mount.spec
修改如下几处,添加行时不要包括行号:
(1)增加了第10行:Patch2: gnome-mount-0.4-ntfs-mount.patch
(2)增加了第33行:%patch2 -p0 -b .ntfs-mount
1 Summary: Mount replacement which uses HAL to do the mounting
2 Name: gnome-mount
3 Version: 0.4
4 Release: 5
5 License: GPL
6 Group: Applications/System
7 Source: %{name}-%{version}.tar.gz
8 Patch0: gnome-mount-0.4-drive-mount.patch
9 Patch1: gnome-mount-0.4-no-media.patch
10 Patch2: gnome-mount-0.4-ntfs-mount.patch
11 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
12 BuildRequires: hal-devel >= 0.5.5 gtk2-devel >= 2.8.0 dbus-devel >= 0.31
13 Requires: hal >= 0.5.7
14 Requires: dbus >= 0.60
15
16 %description
17 A replacement for the mount, umount and eject commands that
18 uses HAL to do all the heavy lifting.
19
20 %package devel
21 Summary: Development files for gnome-mount
22 Group: Development/Libraries
23
24 %description devel
25 Development files for gnome-mount
26
27 %prep
28 rm -rf $RPM_BUILD_ROOT
29
30 %setup -q
31 %patch0 -p0 -b .drive-mount
32 %patch1 -p0 -b .no-media
33 %patch2 -p0 -b .ntfs-mount
5. 修改patch文件
# cp gnome-mount-0.4-ntfs-mount.patch /usr/src/redhat/SOURCES/
# vi /usr/src/redhat/SOURCES/gnome-mount-0.4-ntfs-mount.patch
因为直接用于源代码的patch并不能直接用于rpm包的编译,所以我根据另外两个patch文件,小小的修改了一下。仅仅修改了头部几行。差别请自行对照原文件。
代码如下:
Index: src/gnome-mount.c
===================================================================
RCS file: /cvs/gnome/gnome-mount/src/gnome-mount.c,v
retrieving revision 1.17.0
diff -u -r1.17.0 gnome-mount.c
--- src/gnome-mount.c Jul 11 2006 14:28:51 -0000 1.17.0
+++ src/gnome-mount.c Jul 11 2006 14:50:25 -0000
@@ -587,6 +587,8 @@ volume_mount (const char *udi, LibHalVol
char *key;
gboolean ret;
const char *fstype;
+ char umaskbuf[64];
+ char *umask;
ret = FALSE;
@@ -637,7 +639,7 @@ volume_mount (const char *udi, LibHalVol
snprintf (uidbuf, sizeof (uidbuf) - 1, "uid=%u", getuid ());
g_ptr_array_add (options, uidbuf);
- } else if (strcmp (fstype, "vfat") == 0) {
+ } else if (strcmp (fstype, "vfat") == 0 || strcmp (fstype, "ntfs") == 0) {
/*
* Ugh, flush is not upstream yet.. better not add it...
*
@@ -651,6 +653,14 @@ volume_mount (const char *udi, LibHalVol
snprintf (uidbuf, sizeof (uidbuf) - 1, "uid=%u", getuid ());
g_ptr_array_add (options, uidbuf);
}
+
+ /*if (opts & MOUNT_UMASK)*/ {
+ if (umask = libhal_device_get_property_string(hal_ctx, udi,
+ "volume.policy.mount_option.umask", NULL)) {
+ snprintf(umaskbuf, sizeof (umaskbuf) - 1, "umask=%s", umask);
+ g_ptr_array_add (options, umaskbuf);
+ }
+ }
} else if (strcmp (fstype, "iso9660") == 0) {
if (opts & MOUNT_UID) {
snprintf (uidbuf, sizeof (uidbuf) - 1, "uid=%u", getuid ());
6. 开始build RPM包
# cd /usr/src/redhat/SPECS/
# rpmbuild -ba gnome-mount.spec
如果你的开发工具和devel包比较全的话,编译是不会有问题的。编译结束后可以在 /usr/src/redhat/RPMS/i386/ 目录下找到编译好的rpm,在 /usr/src/redhat/SRPMS/ 下可以找到src.rpm包。
7. 安装rpm
# rpm -ivh gnome-mount-0.4-5.i386.rpm --force
8. 配置gnome-mount
配置很简单,wall_john大侠已经帮我们把脚本都写好了:
# mkdir /usr/share/hal/fdi/policy/95userpolicy/
# vi 10-storage-methods.fdi
添加如下内容,并保存:
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->
<deviceinfo version="0.2">
<device>
<match key="volume.fsusage" string="filesystem">
<match key="volume.fstype" string="ntfs">
<merge key="volume.policy.mount_option.umask" type="string">0222</merge>
<!--merge key="volume.policy.mount_option.umask=0222" type="bool">true</merge-->
<append key="volume.mount.valid_options" type="strlist">umask=</append>
</match>
</match>
<match key="block.is_volume" bool="true">
<merge key="volume.ignore" type="bool">false</merge>
</match>
</device>
</deviceinfo>
大侠解释说:
顺便说一下,上面的fdi文件第一个大match处理ntfs的读取权限,
第二大match使本机硬盘的分区也能自动挂载。
9. 个人喜好配置
重启系统后,你会看见硬盘上所有Linux可以识别的空间都被挂载了。插上移动硬盘试试,顺利挂载!
但是桌面上乱糟糟的一堆,成何体统啊!
$ gconf-editor
找到/apps/nautilus/desktop/分支,volumes_visible项,去掉前面的复选框,桌面上清静了!双击桌面上的“计算机”图标,嘿,这些挂载的分区好端端的躺在里面呢!另外,你也可以发现多了一个“位置-可移动介质”子菜单,里面有被gnome-mount挂载的所有的分区,怎么样,不错吧。
如果你不想自动挂载硬盘上所有分区,你就直接把 /usr/share/hal/fdi/policy/95userpolicy/10-storage-methods.fdi 里面第二个大match注释掉或者删除掉。
如果你不想麻烦,你可以直接下载我编译好的rpm包:
http://ersaclarke.5upan.com/
在Linux目录下。有四个文件。包括rpm,src.rpm,patch和spec
就像这些,完全可以加到 rpms 仓库里面去。
回复删除