Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Linux Timesaving Techniques For Dummies.pdf
Скачиваний:
59
Добавлен:
15.03.2015
Размер:
15.98 Mб
Скачать

2 Getting GNOME Virtual File Systems

Technique to Do the Work for You

Save Time By

Using GNOME virtual file systems

Combining VFS modules

Using VFS to work with packages

Burning CDs and DVDs from a browser

Previewing fonts and themes with Nautilus

Linux supports a wide variety of physical file systems. A file system’s job is to make sense of the bytes stored on a disk so that other programs don’t have to interpret them. A file system module, for exam-

ple, might look at the bytes in sector 52033 on your hard disk and say, “Hey, that’s a directory.” File system modules also work in the other direction as well. For example, a program might ask for a listing of the /tmp directory, and the file system knows how to find that data on the disk. A file system module creates order out of the billion or more bytes of chaos on your disk.

GNOME takes the physical file system one step further by introducing the virtual file system (or VFS for short). A virtual file system performs the same function as a physical file system except that the underlying data comes from somewhere beyond your disk. A virtual file system gathers data from an unusual source and makes that data appear as a set of directories, subdirectories, and data files. Using a VFS, you can peek into tar, gzip, and RPM archives, treat remote files as if they were local, and even access CD audio tracks as if they were normal data files. GNOME also has some handy preview tools that let you view fonts and desktop themes as if they were normal files.

In this technique, we show you how to save time by using some of the more useful GNOME VFS modules. When you use the VFS, you don’t have to waste time finding (and opening) the right program to view a file in an unconventional location — GNOME does the hard work for you. Whether you use the VFS in a browser or at the command line, the time you save and the power you gain will surprise you.

Using GNOME VFS Modules

The GNOME VFS is still evolving, and not all GNOME applications are VFS savvy. We’ve found that most (if not all) VFS modules work when you use

14 Technique 2: Getting GNOME Virtual File Systems to Do the Work for You

them from the command line, but some fail in strange and quirky ways when you try to use them from a browser. If you can’t get a VFS URL to work, try it at the command line (we show you how in a moment). If it works there, the problem is in the browser.

To use a VFS module, simply use the module name as if it were a protocol. For example, to open a font that’s installed on your system, you can browse to the URL fonts://Courier. Finding out which VFS modules are installed on your system can be tricky. The VFS modules are listed in a group of files in

/etc/gnome-vfs-2.0/modules, but just because you find a module listed there doesn’t mean that the

TABLE 2-1: COMMONLY INCLUDED VFS MODULES

module is actually installed. You also have to check for the library in /usr/lib/ gnome-vfs-2.0/modules/. To save you some time, Table 2-1 lists some of the most commonly included VFS modules.

/proc is a virtual file system that works in either KDE or GNOME and exposes kernel data — see Technique 26 for more information.

We cover only a few of the VFS modules distributed with Linux, but you can find others on the Web. If you find another module you want to use, you’ll likely need to download and compile it. See Technique 14 for help with downloading and compiling programs.

Module Name

What It Does

http:

Accesses data stored on a Web server

https:

Accesses data stored on a secure Web server (typically an e-commerce site)

ftp:

Accesses data stored on an FTP server

mailto:

Sends e-mail

bzip2:

Peeks inside bzip2 archives

cdda:

Treats CD audio tracks as if they were normal files

file:

Accesses data stored in a local physical file system

nntp:

Reads newsgroups by using the network news transport protocol

gzip:

Peeks inside gzip archives

dav:

Accesses data stored on a WebDAV server

pipe:

Accesses data sent to a pipe

ssh:

Connects to a remote SSH server

tar:

Peeks inside uncompressed tar archives

fonts:

Accesses font information

burn:

Burns CDs from within a browser

themes:

Accesses desktop themes installed on your system

 

 

Working with Packages: rpm and rpms

15

Stacking VFS Modules

GNOME VFS URLs can be stacked together. For example, if you have an uncompressed tar file located on a remote system, you can stack a tar URL on top of an http:// URL to get to the data stored inside. Suppose that you have an uncompressed tar archive named /tmp/pics.tar that contains an image named freddie.jpg and you want to view that picture with GNOME’s Eye Of Gnome viewer.

Sure, you could un-tar the archive and tell the viewer to open the JPG photo (reminding yourself to clean up all the temporary files after you finish). But you can save yourself time and trouble by making VFS worry about those details. Rather than extracting the image to a temporary location, you can use a VFS URL like this:

$ eog file:///tmp/pics.tar#tar:/freddie.jpg

Here’s how the pieces of the command fit together. First, the eog part is the name of the command that you’re running (Eye Of Gnome). Next, you see a typical URL (file:///tmp/pics.tar) that uses the file: protocol to open /tmp/pics.tar. Next comes the magical part: #tar:/freddie.jpg. That tells GNOME to treat everything that precedes #tar: as a tar archive and to access the freddie.jpg member within.

What happens if the picture that you want to view is stored in a compressed tar archive? Simple, just put another VFS component (gzip) on the stack, like this:

$eog file:///tmp/pics.tgz#gzip:#tar:/ freddie.jpg

If the pics.tgz file lives on a remote Web server, you can combine the http: protocol with gzip: and tar: like this:

$eog http://myserver.example.com/pics. tgz#gzip:#tar:/freddie.jpg

Most of the VFS documentation that you find tells you that you can stack VFS URLs with the following syntax: url#url/suburl. For example, if you have a tar archive named /tmp/ foo.tar that contains a file named bar.txt, the GNOME VFS documentation tells you that you can access the bar.txt file with the URL file://tmp/foo.tar#tar/bar.txt. You can’t — the documentation is wrong. Instead, you have to use file://tmp/foo. tar#tar:/bar.txt. Notice the extra : between tar and /bar.txt. Without that colon, the #tar/bar.txt component acts like a named anchor in an HTML document, not like a VFS module.

Working with Packages: rpm and rpms

The rpm: VFS module lets you peek inside an RPM installer file. You can use the rpm: VFS to extract select files from an RPM package without having to install the whole thing. rpm: also lets you extract metadata (such as the name of the package vendor, the target distribution, and copyright) from

a package.

The rpm: module creates a virtual file system that represents the contents of the RPM file. If you list the directory of an rpm: URL, you see the name of each file that would be installed by that RPM. You also see a number of virtual files that expose the extra data stored inside the RPM. Here’s an example:

[freddie@bastille] cd /mnt/cdrom/ Fedora/RPMS

[freddie@bastille] gnomevfs-ls file: gnome-applets-2.4.1-1.i386.rpm#rpm:

-r--r--r-- 1 root root 941

Oct

3 2003

HEADER

 

 

-r-xr-xr-x 1 root root 39

Oct

3 2003

INSTALL

 

 

-r-xr-xr-x 1 root root 39

Oct

3 2003

UPGRADE

 

 

16 Technique 2: Getting GNOME Virtual File Systems to Do the Work for You

dr-xr-xr-x 3 root root 0

Oct

3

2003

INFO

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/NAME-VERSION-RELEASE

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/GROUP

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/BUILDHOST

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/SOURCERPM

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/DISTRIBUTION

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/VENDOR

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/DESCRIPTION

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/SUMMARY

 

 

 

dr-xr-xr-x 1 root root 0

Oct

3

2003

INFO/SCRIPTS

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/SCRIPTS/POSTIN

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/SCRIPTS/ALL

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/PACKAGER

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/URL

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/SERIAL

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/COPYRIGHT

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/LICENSE

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/BUILDTIME

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/RPMVERSION

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/OS

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/SIZE

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/REQUIRENAME

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/OBSOLETES

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/PROVIDES

 

 

 

-r--r--r-- 1 root root 0

Oct

3

2003

INFO/CHANGELOG

 

 

 

-rw-r--r-- 1 root root 63419 Oct

3

10:28

/etc/gconf/schemas/battstat.schemas

-rw-r--r-- 1 root root 8364 Oct 3 10:28 /etc/gconf/schemas/cdplayer.schemas -rw-r--r-- 1 root root 21092 Oct 3 10:27 /etc/gconf/schemas/charpick.schemas

...

The first 28 files listed are virtual files, and the rest are real files that would be installed on your system if you installed this particular package.

You can extract a single file from an archive by using gnomevfs-cat, for example:

[freddie@bastille] gnomevfs-cat file:gnome-applets- 2.4.1-1.i386.rpm#rpm:HEADER

Name

: gnome-applets

Relocations: (not relocateable)

Version

: 2.4.1

Vendor: Red Hat, Inc.

Release

:

1

Build Date: Fri Oct 3 10:29:07 2003

Install Date: (not installed)

Build Host: daffy.perf.redhat.com

Group

: User Interface/Desktops

Source RPM: gnome-applets-

2.4.1-1.src.rpm

Size

: 11210002

License: GPL

Signature

: DSA/SHA1, Tue Oct 28

19:10:23 2003, Key ID b44269d04f2a6fd2

Packager

: Red Hat, Inc.

<http://bugzilla.redhat.com/bugzilla>

URL

: http://www.gnome.org/

Summary

: Small applications for the

Gnome panel. Description :

Gnome (GNU Network Object Model Environment) is a user-friendly set of

applications and desktop tools to be used in conjunction with a window

manager for the X Window System. The gnome-applets package provides small utilities for the Gnome panel.

Notice that you can access both virtual and real files within the RPM.

The rpms: module (note the s on the end) lets you treat the database of installed software as a virtual file system. In other words, when you view the

Соседние файлы в предмете Операционные системы