@@ -0,0 +1,195 @@
2+title = "Manage Mounts"
7+Here we'll look at managing clay unix mounts programmatically.
11+There are four `task:clay` tags relevant to mounts:
13+- [%boat](#boat) - List mounts.
14+- [%mont](#mont) - Mount something.
15+- [%ogre](#ogre) - Unmount something.
16+- [%dirk](#dirk) - Commit changes.
20+This type of `task:clay` will request the list of existing mounts. It looks like:
26+Pretty simple. The type it returns is a `%hill` tagged `gift:clay`, which looks like:
32+...where the `@tas` is the name of the mount point.
36+Here's a thread that sends a `task:clay` and takes a `gift:clay` in response:
38+**`send-task-take-gift.hoon`**
43+=, strand=strand:spider
48+=/ uarg !< (unit task:clay) arg
50+ (strand-fail:strand %no-arg ~)
52+=/ =card:agent:gall [%pass /foo %arvo %c task]
53+;< ~ bind:m (send-raw-card:strandio card)
54+;< res=[wire sign-arvo] bind:m take-sign-arvo:strandio
59+Save it to `ted/send-task-take-gift.hoon`, `|commit %home`, and run it like:
62+> -send-task-take-gift [%boat ~]
68+This type of `task:clay` mounts the specified `beam:clay` to the specified `term` mount point. It looks like:
71+[%mont pot=term bem=beam]
74+A `beam:clay` is the following structure:
77++$ beam [[p=ship q=desk r=case] s=path] :: global name
80+You can mount the whole desk with a `path` of `/`, and you can also mount subdirectories or even individual files. If you want to mount an individual file, you must exclude its `mark` from the path. For example, if you want to mount `/gen/hood/hi/hoon`, you'd specify `/gen/hood/hi`. It will automatically be given the correct file extension when mounted. If you include the `hoon` mark it will crash (and currently crash your ship).
84+Here's a thread which will send the given `task:clay` to clay.
91+=, strand=strand:spider
96+=/ uarg !< (unit task:clay) arg
98+ (strand-fail:strand %no-arg ~)
100+=/ =card:agent:gall [%pass /foo %arvo %c task]
101+;< ~ bind:m (send-raw-card:strandio card)
105+Save it to `ted/send-task.hoon`, `|commit %home` and run it like:
108+> -send-task [%mont %kids [our %kids da+now] /]
111+If you look in your pier, you should now see a `kids` folder which contains the contents of that desk.
113+If we make a `%boat` request as detailed in the [%boat](#boat) section, we'll now see the mount point listed:
116+> -send-task-take-gift [%boat ~]
117+[%hill p=~[%kids %home]]
120+Note the mount point doesn't need to match a desk, file or directory. We can also do:
123+> -send-task [%mont %wibbly-wobbly [our %home da+now] /]
126+And you'll now see that there's a `wibbly-wobbly` folder with the contents of the `%home` desk. You'll also notice we can mount the same file or directory more than once. There's no problem having `%home` mounted to both `home` and `wibbly-wobbly`. The only requirement is that their mount points be unique.
128+Let's try mounting a subdirectory and a single folder:
131+> -send-task [%mont %gen [our %home da+now] /gen]
132+> -send-task [%mont %hi [our %home da+now] /gen/hood/hi]
135+If you look in your pier you'll now see a `gen` folder with the contents of `/gen` and a `hi.hoon` file by itself. Notice how the file extension has been automatically added.
139+This type of `task:clay` unmounts the specified mount. It's defined in `lull.hoon` as:
142+[%ogre pot=$@(desk beam)]
145+But in fact it will only unmount the target when specified as a `term` mount name. Passing it a `desk` will incidentally work if the mount is named the same as the desk but otherwise it won't work. Passing it a `beam:clay` will simply not work.
147+Using the thread from the [%mont](#mont) section, we can unmount `%kids` like:
150+-send-task [%ogre %kids]
153+Our custom mount point `%wibbly-wobbly` like:
156+-send-task [%ogre %wibbly-wobbly]
159+And the single `hi.hoon` we previously mounted by specifying its mount point `%hi`:
162+-send-task [%ogre %hi]
165+If we specify a non-existent mount point it will fail with an error printed to the dojo like:
168+> -send-task [%ogre %kids]
172+If we give it an unmounted `beam:clay` it will not print an error but still won't work.
176+This type of `task:clay` commits changes in the target mount. It's defined in `lull.hoon` as:
182+... but like [%ogre](#ogre), it actually takes the name of a mount point rather than a `desk` as is specified.
186+With your `%home` desk mounted, try adding a file and, using the thread from the [%mont](#mont) section, send a `%dirk` to commit the change:
189+> -send-task [%dirk %home]
190++ /~zod/home/12/foo/txt
193+Clay will print the changed files to the dojo with a leading `+`, `-` or `:` to indicate a new file, deleted file and changed file respectively.
195+If you have the same desk mounted to multiple points, a committed change in one mount will also update the others.