summaryrefslogtreecommitdiff
path: root/hurd/documentation/translator_primer.mdwn
blob: 073d5e071cbc52a9627095751eaba64edd48f421 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
[[!meta copyright="Copyright © 2011 Free Software Foundation, Inc."]]

[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable
id="license" text="Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no Invariant
Sections, no Front-Cover Texts, and no Back-Cover Texts.  A copy of the license
is included in the section entitled [[GNU Free Documentation
License|/fdl]]."]]"""]]

[[!meta title="Translator Primer"]]

# Small Examples on Using Translators

The [[concept|concepts]] of user-space servers, [[Translators|translator]], is a very
powerful one.  Here is an introductionary text.


## Intro

The Hurd has some unique capabilities, and we created this simple image 
to enable you to easily try three of them: 

* The simplest of translators: Hello World!
* Transparent FTP
* Mount a remote ISO file 

### Hello World

To try out the simplest of translators, you can go the following simple steps: 

	$ touch hello
	$ cat hello
	$ settrans hello /hurd/hello  
	$ cat hello  
	"Hello World!"  
	
	$ fsysopts hello
	/hurd/hello --contents='Hello World!
	'
	$ fsysopts hello --contents='Hello GNU!
	> '
	$ cat hello
	Hello GNU!
	
	$ settrans -g hello  
	$ cat hello  
What you do with these steps is first creating the file "hello" and verifying that it is empty. 

Then you setup the translator `/hurd/hello` in the file/node `hello`. 

After that, you check the contents of the file, and the translator returns "Hello World!". 

Because you are a curious hacker, you wonder what filesystem options this node has.  It turns
out that the hello translator uses a "contents" option.  We can change what the hello
translator returns with another call to [[fsysopts]].

To finish it,
you remove the translator from the file "hello"
(and tell any active running instances to go away)
via "`settrans --g hello`", which is shorthand for "`settrans --goaway hello`"
Having done that, verify that now the file is empty again.

### Transparent FTP

We already setup a a transparent FTP translator for you at /ftp: 

With it you can easily access public FTP via the file system, for example the one from the GNU project: 

	$ ls /ftp://ftp.gnu.org/

But you can also do this very easily yourself: 

	$ # Setup the translator on the node ftp:  
	$ settrans -c ftp: /hurd/hostmux /hurd/ftpfs /

and you can access FTP sites via the pseudo-directory ftp:, for example with 

	$ ls ftp://ftp.gnu.org/

What you do here is setting up the translator /hurd/hostmux on ftp: and passing it the translator /hurd/ftpfs to use for resolving accesses as well as / as additional path component. 

### ISO file mount

Now that we can access ftp.gnu.org transparently, let's mount a remote ISO file:

	$ settrans -c mnt /hurd/iso9660fs $PWD/ftp://ftp.gnu.org/old-gnu/gnu-f2/hurd-F2-main.iso
	$ ls mnt/

It is interesting to note that since the ISO9660 format is indexed, ftpfs does not have to download the whole ISO file, it merely fetches what iso9660fs requests.


These were only three basic usages of translators on the Hurd. We're sure you'll quickly see many other ways to use this. 

As a last comment: You can setup a translator on any node you have access to, so you can for example mount any filesystems as normal user. 

You might currently be logged in as root, but you could just as well do the same as normal user. 

Why don't you try it out?