source: mainline/uspace/srv/vfs/vfs_ops.c@ 46c20c8

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 46c20c8 was 3a4b3ba, checked in by Jakub Jermar <jakub@…>, 15 years ago

Fix a regression introduced by changeset martin@….

  • Property mode set to 100644
File size: 34.6 KB
Line 
1/*
2 * Copyright (c) 2008 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup fs
30 * @{
31 */
32
33/**
34 * @file vfs_ops.c
35 * @brief Operations that VFS offers to its clients.
36 */
37
38#include "vfs.h"
39#include <ipc/ipc.h>
40#include <macros.h>
41#include <stdint.h>
42#include <async.h>
43#include <errno.h>
44#include <stdio.h>
45#include <stdlib.h>
46#include <str.h>
47#include <bool.h>
48#include <fibril_synch.h>
49#include <adt/list.h>
50#include <unistd.h>
51#include <ctype.h>
52#include <fcntl.h>
53#include <assert.h>
54#include <vfs/canonify.h>
55
56/* Forward declarations of static functions. */
57static int vfs_truncate_internal(fs_handle_t, devmap_handle_t, fs_index_t,
58 aoff64_t);
59
60/**
61 * This rwlock prevents the race between a triplet-to-VFS-node resolution and a
62 * concurrent VFS operation which modifies the file system namespace.
63 */
64FIBRIL_RWLOCK_INITIALIZE(namespace_rwlock);
65
66vfs_pair_t rootfs = {
67 .fs_handle = 0,
68 .devmap_handle = 0
69};
70
71static void vfs_mount_internal(ipc_callid_t rid, devmap_handle_t devmap_handle,
72 fs_handle_t fs_handle, char *mp, char *opts)
73{
74 vfs_lookup_res_t mp_res;
75 vfs_lookup_res_t mr_res;
76 vfs_node_t *mp_node = NULL;
77 vfs_node_t *mr_node;
78 fs_index_t rindex;
79 size_t rsize;
80 unsigned rlnkcnt;
81 ipcarg_t rc;
82 int phone;
83 aid_t msg;
84 ipc_call_t answer;
85
86 /* Resolve the path to the mountpoint. */
87 fibril_rwlock_write_lock(&namespace_rwlock);
88 if (rootfs.fs_handle) {
89 /* We already have the root FS. */
90 if (str_cmp(mp, "/") == 0) {
91 /* Trying to mount root FS over root FS */
92 fibril_rwlock_write_unlock(&namespace_rwlock);
93 ipc_answer_0(rid, EBUSY);
94 return;
95 }
96
97 rc = vfs_lookup_internal(mp, L_MP, &mp_res, NULL);
98 if (rc != EOK) {
99 /* The lookup failed for some reason. */
100 fibril_rwlock_write_unlock(&namespace_rwlock);
101 ipc_answer_0(rid, rc);
102 return;
103 }
104
105 mp_node = vfs_node_get(&mp_res);
106 if (!mp_node) {
107 fibril_rwlock_write_unlock(&namespace_rwlock);
108 ipc_answer_0(rid, ENOMEM);
109 return;
110 }
111
112 /*
113 * Now we hold a reference to mp_node.
114 * It will be dropped upon the corresponding VFS_IN_UNMOUNT.
115 * This prevents the mount point from being deleted.
116 */
117 } else {
118 /* We still don't have the root file system mounted. */
119 if (str_cmp(mp, "/") == 0) {
120 /*
121 * For this simple, but important case,
122 * we are almost done.
123 */
124
125 /* Tell the mountee that it is being mounted. */
126 phone = vfs_grab_phone(fs_handle);
127 msg = async_send_1(phone, VFS_OUT_MOUNTED,
128 (ipcarg_t) devmap_handle, &answer);
129 /* send the mount options */
130 rc = async_data_write_start(phone, (void *)opts,
131 str_size(opts));
132 if (rc != EOK) {
133 async_wait_for(msg, NULL);
134 vfs_release_phone(fs_handle, phone);
135 fibril_rwlock_write_unlock(&namespace_rwlock);
136 ipc_answer_0(rid, rc);
137 return;
138 }
139 async_wait_for(msg, &rc);
140 vfs_release_phone(fs_handle, phone);
141
142 if (rc != EOK) {
143 fibril_rwlock_write_unlock(&namespace_rwlock);
144 ipc_answer_0(rid, rc);
145 return;
146 }
147
148 rindex = (fs_index_t) IPC_GET_ARG1(answer);
149 rsize = (size_t) IPC_GET_ARG2(answer);
150 rlnkcnt = (unsigned) IPC_GET_ARG3(answer);
151
152 mr_res.triplet.fs_handle = fs_handle;
153 mr_res.triplet.devmap_handle = devmap_handle;
154 mr_res.triplet.index = rindex;
155 mr_res.size = rsize;
156 mr_res.lnkcnt = rlnkcnt;
157 mr_res.type = VFS_NODE_DIRECTORY;
158
159 rootfs.fs_handle = fs_handle;
160 rootfs.devmap_handle = devmap_handle;
161
162 /* Add reference to the mounted root. */
163 mr_node = vfs_node_get(&mr_res);
164 assert(mr_node);
165
166 fibril_rwlock_write_unlock(&namespace_rwlock);
167 ipc_answer_0(rid, rc);
168 return;
169 } else {
170 /*
171 * We can't resolve this without the root filesystem
172 * being mounted first.
173 */
174 fibril_rwlock_write_unlock(&namespace_rwlock);
175 ipc_answer_0(rid, ENOENT);
176 return;
177 }
178 }
179
180 /*
181 * At this point, we have all necessary pieces: file system and device
182 * handles, and we know the mount point VFS node.
183 */
184
185 int mountee_phone = vfs_grab_phone(fs_handle);
186 assert(mountee_phone >= 0);
187
188 phone = vfs_grab_phone(mp_res.triplet.fs_handle);
189 msg = async_send_4(phone, VFS_OUT_MOUNT,
190 (ipcarg_t) mp_res.triplet.devmap_handle,
191 (ipcarg_t) mp_res.triplet.index,
192 (ipcarg_t) fs_handle,
193 (ipcarg_t) devmap_handle, &answer);
194
195 /* send connection */
196 rc = async_req_1_0(phone, IPC_M_CONNECTION_CLONE, mountee_phone);
197 if (rc != EOK) {
198 async_wait_for(msg, NULL);
199 vfs_release_phone(fs_handle, mountee_phone);
200 vfs_release_phone(mp_res.triplet.fs_handle, phone);
201 /* Mount failed, drop reference to mp_node. */
202 if (mp_node)
203 vfs_node_put(mp_node);
204 ipc_answer_0(rid, rc);
205 fibril_rwlock_write_unlock(&namespace_rwlock);
206 return;
207 }
208
209 vfs_release_phone(fs_handle, mountee_phone);
210
211 /* send the mount options */
212 rc = async_data_write_start(phone, (void *)opts, str_size(opts));
213 if (rc != EOK) {
214 async_wait_for(msg, NULL);
215 vfs_release_phone(mp_res.triplet.fs_handle, phone);
216 /* Mount failed, drop reference to mp_node. */
217 if (mp_node)
218 vfs_node_put(mp_node);
219 fibril_rwlock_write_unlock(&namespace_rwlock);
220 ipc_answer_0(rid, rc);
221 return;
222 }
223 async_wait_for(msg, &rc);
224 vfs_release_phone(mp_res.triplet.fs_handle, phone);
225
226 if (rc == EOK) {
227 rindex = (fs_index_t) IPC_GET_ARG1(answer);
228 rsize = (size_t) IPC_GET_ARG2(answer);
229 rlnkcnt = (unsigned) IPC_GET_ARG3(answer);
230
231 mr_res.triplet.fs_handle = fs_handle;
232 mr_res.triplet.devmap_handle = devmap_handle;
233 mr_res.triplet.index = rindex;
234 mr_res.size = rsize;
235 mr_res.lnkcnt = rlnkcnt;
236 mr_res.type = VFS_NODE_DIRECTORY;
237
238 /* Add reference to the mounted root. */
239 mr_node = vfs_node_get(&mr_res);
240 assert(mr_node);
241 } else {
242 /* Mount failed, drop reference to mp_node. */
243 if (mp_node)
244 vfs_node_put(mp_node);
245 }
246
247 ipc_answer_0(rid, rc);
248 fibril_rwlock_write_unlock(&namespace_rwlock);
249}
250
251void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
252{
253 devmap_handle_t devmap_handle;
254
255 /*
256 * We expect the library to do the device-name to device-handle
257 * translation for us, thus the device handle will arrive as ARG1
258 * in the request.
259 */
260 devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
261
262 /*
263 * Mount flags are passed as ARG2.
264 */
265 unsigned int flags = (unsigned int) IPC_GET_ARG2(*request);
266
267 /*
268 * For now, don't make use of ARG3, but it can be used to
269 * carry mount options in the future.
270 */
271
272 /* We want the client to send us the mount point. */
273 char *mp;
274 int rc = async_data_write_accept((void **) &mp, true, 0, MAX_PATH_LEN,
275 0, NULL);
276 if (rc != EOK) {
277 ipc_answer_0(rid, rc);
278 return;
279 }
280
281 /* Now we expect to receive the mount options. */
282 char *opts;
283 rc = async_data_write_accept((void **) &opts, true, 0, MAX_MNTOPTS_LEN,
284 0, NULL);
285 if (rc != EOK) {
286 free(mp);
287 ipc_answer_0(rid, rc);
288 return;
289 }
290
291 /*
292 * Now, we expect the client to send us data with the name of the file
293 * system.
294 */
295 char *fs_name;
296 rc = async_data_write_accept((void **) &fs_name, true, 0,
297 FS_NAME_MAXLEN, 0, NULL);
298 if (rc != EOK) {
299 free(mp);
300 free(opts);
301 ipc_answer_0(rid, rc);
302 return;
303 }
304
305 /*
306 * Wait for IPC_M_PING so that we can return an error if we don't know
307 * fs_name.
308 */
309 ipc_call_t data;
310 ipc_callid_t callid = async_get_call(&data);
311 if (IPC_GET_METHOD(data) != IPC_M_PING) {
312 ipc_answer_0(callid, ENOTSUP);
313 ipc_answer_0(rid, ENOTSUP);
314 free(mp);
315 free(opts);
316 free(fs_name);
317 return;
318 }
319
320 /*
321 * Check if we know a file system with the same name as is in fs_name.
322 * This will also give us its file system handle.
323 */
324 fibril_mutex_lock(&fs_head_lock);
325 fs_handle_t fs_handle;
326recheck:
327 fs_handle = fs_name_to_handle(fs_name, false);
328 if (!fs_handle) {
329 if (flags & IPC_FLAG_BLOCKING) {
330 fibril_condvar_wait(&fs_head_cv, &fs_head_lock);
331 goto recheck;
332 }
333
334 fibril_mutex_unlock(&fs_head_lock);
335 ipc_answer_0(callid, ENOENT);
336 ipc_answer_0(rid, ENOENT);
337 free(mp);
338 free(fs_name);
339 free(opts);
340 return;
341 }
342 fibril_mutex_unlock(&fs_head_lock);
343
344 /* Acknowledge that we know fs_name. */
345 ipc_answer_0(callid, EOK);
346
347 /* Do the mount */
348 vfs_mount_internal(rid, devmap_handle, fs_handle, mp, opts);
349 free(mp);
350 free(fs_name);
351 free(opts);
352}
353
354void vfs_unmount(ipc_callid_t rid, ipc_call_t *request)
355{
356 int rc;
357 char *mp;
358 vfs_lookup_res_t mp_res;
359 vfs_lookup_res_t mr_res;
360 vfs_node_t *mr_node;
361 int phone;
362
363 /*
364 * Receive the mount point path.
365 */
366 rc = async_data_write_accept((void **) &mp, true, 0, MAX_PATH_LEN,
367 0, NULL);
368 if (rc != EOK)
369 ipc_answer_0(rid, rc);
370
371 /*
372 * Taking the namespace lock will do two things for us. First, it will
373 * prevent races with other lookup operations. Second, it will stop new
374 * references to already existing VFS nodes and creation of new VFS
375 * nodes. This is because new references are added as a result of some
376 * lookup operation or at least of some operation which is protected by
377 * the namespace lock.
378 */
379 fibril_rwlock_write_lock(&namespace_rwlock);
380
381 /*
382 * Lookup the mounted root and instantiate it.
383 */
384 rc = vfs_lookup_internal(mp, L_ROOT, &mr_res, NULL);
385 if (rc != EOK) {
386 fibril_rwlock_write_unlock(&namespace_rwlock);
387 free(mp);
388 ipc_answer_0(rid, rc);
389 return;
390 }
391 mr_node = vfs_node_get(&mr_res);
392 if (!mr_node) {
393 fibril_rwlock_write_unlock(&namespace_rwlock);
394 free(mp);
395 ipc_answer_0(rid, ENOMEM);
396 return;
397 }
398
399 /*
400 * Count the total number of references for the mounted file system. We
401 * are expecting at least two. One which we got above and one which we
402 * got when the file system was mounted. If we find more, it means that
403 * the file system cannot be gracefully unmounted at the moment because
404 * someone is working with it.
405 */
406 if (vfs_nodes_refcount_sum_get(mr_node->fs_handle,
407 mr_node->devmap_handle) != 2) {
408 fibril_rwlock_write_unlock(&namespace_rwlock);
409 vfs_node_put(mr_node);
410 free(mp);
411 ipc_answer_0(rid, EBUSY);
412 return;
413 }
414
415 if (str_cmp(mp, "/") == 0) {
416
417 /*
418 * Unmounting the root file system.
419 *
420 * In this case, there is no mount point node and we send
421 * VFS_OUT_UNMOUNTED directly to the mounted file system.
422 */
423
424 free(mp);
425 phone = vfs_grab_phone(mr_node->fs_handle);
426 rc = async_req_1_0(phone, VFS_OUT_UNMOUNTED,
427 mr_node->devmap_handle);
428 vfs_release_phone(mr_node->fs_handle, phone);
429 if (rc != EOK) {
430 fibril_rwlock_write_unlock(&namespace_rwlock);
431 vfs_node_put(mr_node);
432 ipc_answer_0(rid, rc);
433 return;
434 }
435 rootfs.fs_handle = 0;
436 rootfs.devmap_handle = 0;
437 } else {
438
439 /*
440 * Unmounting a non-root file system.
441 *
442 * We have a regular mount point node representing the parent
443 * file system, so we delegate the operation to it.
444 */
445
446 rc = vfs_lookup_internal(mp, L_MP, &mp_res, NULL);
447 free(mp);
448 if (rc != EOK) {
449 fibril_rwlock_write_unlock(&namespace_rwlock);
450 vfs_node_put(mr_node);
451 ipc_answer_0(rid, rc);
452 return;
453 }
454 vfs_node_t *mp_node = vfs_node_get(&mp_res);
455 if (!mp_node) {
456 fibril_rwlock_write_unlock(&namespace_rwlock);
457 vfs_node_put(mr_node);
458 ipc_answer_0(rid, ENOMEM);
459 return;
460 }
461
462 phone = vfs_grab_phone(mp_node->fs_handle);
463 rc = async_req_2_0(phone, VFS_OUT_UNMOUNT,
464 mp_node->devmap_handle, mp_node->index);
465 vfs_release_phone(mp_node->fs_handle, phone);
466 if (rc != EOK) {
467 fibril_rwlock_write_unlock(&namespace_rwlock);
468 vfs_node_put(mp_node);
469 vfs_node_put(mr_node);
470 ipc_answer_0(rid, rc);
471 return;
472 }
473
474 /* Drop the reference we got above. */
475 vfs_node_put(mp_node);
476 /* Drop the reference from when the file system was mounted. */
477 vfs_node_put(mp_node);
478 }
479
480
481 /*
482 * All went well, the mounted file system was successfully unmounted.
483 * The only thing left is to forget the unmounted root VFS node.
484 */
485 vfs_node_forget(mr_node);
486
487 fibril_rwlock_write_unlock(&namespace_rwlock);
488 ipc_answer_0(rid, EOK);
489}
490
491void vfs_open(ipc_callid_t rid, ipc_call_t *request)
492{
493 if (!vfs_files_init()) {
494 ipc_answer_0(rid, ENOMEM);
495 return;
496 }
497
498 /*
499 * The POSIX interface is open(path, oflag, mode).
500 * We can receive oflags and mode along with the VFS_IN_OPEN call;
501 * the path will need to arrive in another call.
502 *
503 * We also receive one private, non-POSIX set of flags called lflag
504 * used to pass information to vfs_lookup_internal().
505 */
506 int lflag = IPC_GET_ARG1(*request);
507 int oflag = IPC_GET_ARG2(*request);
508 int mode = IPC_GET_ARG3(*request);
509
510 /* Ignore mode for now. */
511 (void) mode;
512
513 /*
514 * Make sure that we are called with exactly one of L_FILE and
515 * L_DIRECTORY. Make sure that the user does not pass L_OPEN,
516 * L_ROOT or L_MP.
517 */
518 if (((lflag & (L_FILE | L_DIRECTORY)) == 0) ||
519 ((lflag & (L_FILE | L_DIRECTORY)) == (L_FILE | L_DIRECTORY)) ||
520 (lflag & (L_OPEN | L_ROOT | L_MP))) {
521 ipc_answer_0(rid, EINVAL);
522 return;
523 }
524
525 if (oflag & O_CREAT)
526 lflag |= L_CREATE;
527 if (oflag & O_EXCL)
528 lflag |= L_EXCLUSIVE;
529
530 char *path;
531 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL);
532 if (rc != EOK) {
533 ipc_answer_0(rid, rc);
534 return;
535 }
536
537 /*
538 * Avoid the race condition in which the file can be deleted before we
539 * find/create-and-lock the VFS node corresponding to the looked-up
540 * triplet.
541 */
542 if (lflag & L_CREATE)
543 fibril_rwlock_write_lock(&namespace_rwlock);
544 else
545 fibril_rwlock_read_lock(&namespace_rwlock);
546
547 /* The path is now populated and we can call vfs_lookup_internal(). */
548 vfs_lookup_res_t lr;
549 rc = vfs_lookup_internal(path, lflag | L_OPEN, &lr, NULL);
550 if (rc != EOK) {
551 if (lflag & L_CREATE)
552 fibril_rwlock_write_unlock(&namespace_rwlock);
553 else
554 fibril_rwlock_read_unlock(&namespace_rwlock);
555 ipc_answer_0(rid, rc);
556 free(path);
557 return;
558 }
559
560 /* Path is no longer needed. */
561 free(path);
562
563 vfs_node_t *node = vfs_node_get(&lr);
564 if (lflag & L_CREATE)
565 fibril_rwlock_write_unlock(&namespace_rwlock);
566 else
567 fibril_rwlock_read_unlock(&namespace_rwlock);
568
569 /* Truncate the file if requested and if necessary. */
570 if (oflag & O_TRUNC) {
571 fibril_rwlock_write_lock(&node->contents_rwlock);
572 if (node->size) {
573 rc = vfs_truncate_internal(node->fs_handle,
574 node->devmap_handle, node->index, 0);
575 if (rc) {
576 fibril_rwlock_write_unlock(&node->contents_rwlock);
577 vfs_node_put(node);
578 ipc_answer_0(rid, rc);
579 return;
580 }
581 node->size = 0;
582 }
583 fibril_rwlock_write_unlock(&node->contents_rwlock);
584 }
585
586 /*
587 * Get ourselves a file descriptor and the corresponding vfs_file_t
588 * structure.
589 */
590 int fd = vfs_fd_alloc((oflag & O_DESC) != 0);
591 if (fd < 0) {
592 vfs_node_put(node);
593 ipc_answer_0(rid, fd);
594 return;
595 }
596 vfs_file_t *file = vfs_file_get(fd);
597 assert(file);
598 file->node = node;
599 if (oflag & O_APPEND)
600 file->append = true;
601
602 /*
603 * The following increase in reference count is for the fact that the
604 * file is being opened and that a file structure is pointing to it.
605 * It is necessary so that the file will not disappear when
606 * vfs_node_put() is called. The reference will be dropped by the
607 * respective VFS_IN_CLOSE.
608 */
609 vfs_node_addref(node);
610 vfs_node_put(node);
611
612 /* Success! Return the new file descriptor to the client. */
613 ipc_answer_1(rid, EOK, fd);
614}
615
616void vfs_open_node(ipc_callid_t rid, ipc_call_t *request)
617{
618 // FIXME: check for sanity of the supplied fs, dev and index
619
620 if (!vfs_files_init()) {
621 ipc_answer_0(rid, ENOMEM);
622 return;
623 }
624
625 /*
626 * The interface is open_node(fs, dev, index, oflag).
627 */
628 vfs_lookup_res_t lr;
629
630 lr.triplet.fs_handle = IPC_GET_ARG1(*request);
631 lr.triplet.devmap_handle = IPC_GET_ARG2(*request);
632 lr.triplet.index = IPC_GET_ARG3(*request);
633 int oflag = IPC_GET_ARG4(*request);
634
635 fibril_rwlock_read_lock(&namespace_rwlock);
636
637 int rc = vfs_open_node_internal(&lr);
638 if (rc != EOK) {
639 fibril_rwlock_read_unlock(&namespace_rwlock);
640 ipc_answer_0(rid, rc);
641 return;
642 }
643
644 vfs_node_t *node = vfs_node_get(&lr);
645 fibril_rwlock_read_unlock(&namespace_rwlock);
646
647 /* Truncate the file if requested and if necessary. */
648 if (oflag & O_TRUNC) {
649 fibril_rwlock_write_lock(&node->contents_rwlock);
650 if (node->size) {
651 rc = vfs_truncate_internal(node->fs_handle,
652 node->devmap_handle, node->index, 0);
653 if (rc) {
654 fibril_rwlock_write_unlock(&node->contents_rwlock);
655 vfs_node_put(node);
656 ipc_answer_0(rid, rc);
657 return;
658 }
659 node->size = 0;
660 }
661 fibril_rwlock_write_unlock(&node->contents_rwlock);
662 }
663
664 /*
665 * Get ourselves a file descriptor and the corresponding vfs_file_t
666 * structure.
667 */
668 int fd = vfs_fd_alloc((oflag & O_DESC) != 0);
669 if (fd < 0) {
670 vfs_node_put(node);
671 ipc_answer_0(rid, fd);
672 return;
673 }
674 vfs_file_t *file = vfs_file_get(fd);
675 file->node = node;
676 if (oflag & O_APPEND)
677 file->append = true;
678
679 /*
680 * The following increase in reference count is for the fact that the
681 * file is being opened and that a file structure is pointing to it.
682 * It is necessary so that the file will not disappear when
683 * vfs_node_put() is called. The reference will be dropped by the
684 * respective VFS_IN_CLOSE.
685 */
686 vfs_node_addref(node);
687 vfs_node_put(node);
688
689 /* Success! Return the new file descriptor to the client. */
690 ipc_answer_1(rid, EOK, fd);
691}
692
693void vfs_sync(ipc_callid_t rid, ipc_call_t *request)
694{
695 int fd = IPC_GET_ARG1(*request);
696
697 /* Lookup the file structure corresponding to the file descriptor. */
698 vfs_file_t *file = vfs_file_get(fd);
699 if (!file) {
700 ipc_answer_0(rid, ENOENT);
701 return;
702 }
703
704 /*
705 * Lock the open file structure so that no other thread can manipulate
706 * the same open file at a time.
707 */
708 fibril_mutex_lock(&file->lock);
709 int fs_phone = vfs_grab_phone(file->node->fs_handle);
710
711 /* Make a VFS_OUT_SYMC request at the destination FS server. */
712 aid_t msg;
713 ipc_call_t answer;
714 msg = async_send_2(fs_phone, VFS_OUT_SYNC, file->node->devmap_handle,
715 file->node->index, &answer);
716
717 /* Wait for reply from the FS server. */
718 ipcarg_t rc;
719 async_wait_for(msg, &rc);
720
721 vfs_release_phone(file->node->fs_handle, fs_phone);
722 fibril_mutex_unlock(&file->lock);
723
724 ipc_answer_0(rid, rc);
725}
726
727int vfs_close_internal(vfs_file_t *file)
728{
729 /*
730 * Lock the open file structure so that no other thread can manipulate
731 * the same open file at a time.
732 */
733 fibril_mutex_lock(&file->lock);
734
735 if (file->refcnt <= 1) {
736 /* Only close the file on the destination FS server
737 if there are no more file descriptors (except the
738 present one) pointing to this file. */
739
740 int fs_phone = vfs_grab_phone(file->node->fs_handle);
741
742 /* Make a VFS_OUT_CLOSE request at the destination FS server. */
743 aid_t msg;
744 ipc_call_t answer;
745 msg = async_send_2(fs_phone, VFS_OUT_CLOSE,
746 file->node->devmap_handle, file->node->index, &answer);
747
748 /* Wait for reply from the FS server. */
749 ipcarg_t rc;
750 async_wait_for(msg, &rc);
751
752 vfs_release_phone(file->node->fs_handle, fs_phone);
753 fibril_mutex_unlock(&file->lock);
754
755 return IPC_GET_ARG1(answer);
756 }
757
758 fibril_mutex_unlock(&file->lock);
759 return EOK;
760}
761
762void vfs_close(ipc_callid_t rid, ipc_call_t *request)
763{
764 int fd = IPC_GET_ARG1(*request);
765
766 /* Lookup the file structure corresponding to the file descriptor. */
767 vfs_file_t *file = vfs_file_get(fd);
768 if (!file) {
769 ipc_answer_0(rid, ENOENT);
770 return;
771 }
772
773 int ret = vfs_close_internal(file);
774 if (ret != EOK)
775 ipc_answer_0(rid, ret);
776
777 ret = vfs_fd_free(fd);
778 ipc_answer_0(rid, ret);
779}
780
781static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read)
782{
783
784 /*
785 * The following code strongly depends on the fact that the files data
786 * structure can be only accessed by a single fibril and all file
787 * operations are serialized (i.e. the reads and writes cannot
788 * interleave and a file cannot be closed while it is being read).
789 *
790 * Additional synchronization needs to be added once the table of
791 * open files supports parallel access!
792 */
793
794 int fd = IPC_GET_ARG1(*request);
795
796 /* Lookup the file structure corresponding to the file descriptor. */
797 vfs_file_t *file = vfs_file_get(fd);
798 if (!file) {
799 ipc_answer_0(rid, ENOENT);
800 return;
801 }
802
803 /*
804 * Lock the open file structure so that no other thread can manipulate
805 * the same open file at a time.
806 */
807 fibril_mutex_lock(&file->lock);
808
809 /*
810 * Lock the file's node so that no other client can read/write to it at
811 * the same time.
812 */
813 if (read)
814 fibril_rwlock_read_lock(&file->node->contents_rwlock);
815 else
816 fibril_rwlock_write_lock(&file->node->contents_rwlock);
817
818 if (file->node->type == VFS_NODE_DIRECTORY) {
819 /*
820 * Make sure that no one is modifying the namespace
821 * while we are in readdir().
822 */
823 assert(read);
824 fibril_rwlock_read_lock(&namespace_rwlock);
825 }
826
827 int fs_phone = vfs_grab_phone(file->node->fs_handle);
828
829 /*
830 * Make a VFS_READ/VFS_WRITE request at the destination FS server
831 * and forward the IPC_M_DATA_READ/IPC_M_DATA_WRITE request to the
832 * destination FS server. The call will be routed as if sent by
833 * ourselves. Note that call arguments are immutable in this case so we
834 * don't have to bother.
835 */
836 ipcarg_t rc;
837 ipc_call_t answer;
838 if (read) {
839 rc = async_data_read_forward_3_1(fs_phone, VFS_OUT_READ,
840 file->node->devmap_handle, file->node->index, file->pos,
841 &answer);
842 } else {
843 if (file->append)
844 file->pos = file->node->size;
845
846 rc = async_data_write_forward_3_1(fs_phone, VFS_OUT_WRITE,
847 file->node->devmap_handle, file->node->index, file->pos,
848 &answer);
849 }
850
851 vfs_release_phone(file->node->fs_handle, fs_phone);
852
853 size_t bytes = IPC_GET_ARG1(answer);
854
855 if (file->node->type == VFS_NODE_DIRECTORY)
856 fibril_rwlock_read_unlock(&namespace_rwlock);
857
858 /* Unlock the VFS node. */
859 if (read)
860 fibril_rwlock_read_unlock(&file->node->contents_rwlock);
861 else {
862 /* Update the cached version of node's size. */
863 if (rc == EOK)
864 file->node->size = IPC_GET_ARG2(answer);
865 fibril_rwlock_write_unlock(&file->node->contents_rwlock);
866 }
867
868 /* Update the position pointer and unlock the open file. */
869 if (rc == EOK)
870 file->pos += bytes;
871 fibril_mutex_unlock(&file->lock);
872
873 /*
874 * FS server's reply is the final result of the whole operation we
875 * return to the client.
876 */
877 ipc_answer_1(rid, rc, bytes);
878}
879
880void vfs_read(ipc_callid_t rid, ipc_call_t *request)
881{
882 vfs_rdwr(rid, request, true);
883}
884
885void vfs_write(ipc_callid_t rid, ipc_call_t *request)
886{
887 vfs_rdwr(rid, request, false);
888}
889
890void vfs_seek(ipc_callid_t rid, ipc_call_t *request)
891{
892 int fd = (int) IPC_GET_ARG1(*request);
893 off64_t off = (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request),
894 IPC_GET_ARG3(*request));
895 int whence = (int) IPC_GET_ARG4(*request);
896
897 /* Lookup the file structure corresponding to the file descriptor. */
898 vfs_file_t *file = vfs_file_get(fd);
899 if (!file) {
900 ipc_answer_0(rid, ENOENT);
901 return;
902 }
903
904 fibril_mutex_lock(&file->lock);
905
906 off64_t newoff;
907 switch (whence) {
908 case SEEK_SET:
909 if (off >= 0) {
910 file->pos = (aoff64_t) off;
911 fibril_mutex_unlock(&file->lock);
912 ipc_answer_1(rid, EOK, off);
913 return;
914 }
915 break;
916 case SEEK_CUR:
917 if ((off >= 0) && (file->pos + off < file->pos)) {
918 fibril_mutex_unlock(&file->lock);
919 ipc_answer_0(rid, EOVERFLOW);
920 return;
921 }
922
923 if ((off < 0) && (file->pos < (aoff64_t) -off)) {
924 fibril_mutex_unlock(&file->lock);
925 ipc_answer_0(rid, EOVERFLOW);
926 return;
927 }
928
929 file->pos += off;
930 newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos;
931
932 fibril_mutex_unlock(&file->lock);
933 ipc_answer_2(rid, EOK, LOWER32(newoff),
934 UPPER32(newoff));
935 return;
936 case SEEK_END:
937 fibril_rwlock_read_lock(&file->node->contents_rwlock);
938 aoff64_t size = file->node->size;
939
940 if ((off >= 0) && (size + off < size)) {
941 fibril_rwlock_read_unlock(&file->node->contents_rwlock);
942 fibril_mutex_unlock(&file->lock);
943 ipc_answer_0(rid, EOVERFLOW);
944 return;
945 }
946
947 if ((off < 0) && (size < (aoff64_t) -off)) {
948 fibril_rwlock_read_unlock(&file->node->contents_rwlock);
949 fibril_mutex_unlock(&file->lock);
950 ipc_answer_0(rid, EOVERFLOW);
951 return;
952 }
953
954 file->pos = size + off;
955 newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos;
956
957 fibril_rwlock_read_unlock(&file->node->contents_rwlock);
958 fibril_mutex_unlock(&file->lock);
959 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
960 return;
961 }
962
963 fibril_mutex_unlock(&file->lock);
964 ipc_answer_0(rid, EINVAL);
965}
966
967int vfs_truncate_internal(fs_handle_t fs_handle, devmap_handle_t devmap_handle,
968 fs_index_t index, aoff64_t size)
969{
970 ipcarg_t rc;
971 int fs_phone;
972
973 fs_phone = vfs_grab_phone(fs_handle);
974 rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t) devmap_handle,
975 (ipcarg_t) index, LOWER32(size), UPPER32(size));
976 vfs_release_phone(fs_handle, fs_phone);
977 return (int)rc;
978}
979
980void vfs_truncate(ipc_callid_t rid, ipc_call_t *request)
981{
982 int fd = IPC_GET_ARG1(*request);
983 aoff64_t size = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request),
984 IPC_GET_ARG3(*request));
985 int rc;
986
987 vfs_file_t *file = vfs_file_get(fd);
988 if (!file) {
989 ipc_answer_0(rid, ENOENT);
990 return;
991 }
992 fibril_mutex_lock(&file->lock);
993
994 fibril_rwlock_write_lock(&file->node->contents_rwlock);
995 rc = vfs_truncate_internal(file->node->fs_handle,
996 file->node->devmap_handle, file->node->index, size);
997 if (rc == EOK)
998 file->node->size = size;
999 fibril_rwlock_write_unlock(&file->node->contents_rwlock);
1000
1001 fibril_mutex_unlock(&file->lock);
1002 ipc_answer_0(rid, (ipcarg_t)rc);
1003}
1004
1005void vfs_fstat(ipc_callid_t rid, ipc_call_t *request)
1006{
1007 int fd = IPC_GET_ARG1(*request);
1008 ipcarg_t rc;
1009
1010 vfs_file_t *file = vfs_file_get(fd);
1011 if (!file) {
1012 ipc_answer_0(rid, ENOENT);
1013 return;
1014 }
1015
1016 ipc_callid_t callid;
1017 if (!async_data_read_receive(&callid, NULL)) {
1018 ipc_answer_0(callid, EINVAL);
1019 ipc_answer_0(rid, EINVAL);
1020 return;
1021 }
1022
1023 fibril_mutex_lock(&file->lock);
1024
1025 int fs_phone = vfs_grab_phone(file->node->fs_handle);
1026
1027 aid_t msg;
1028 msg = async_send_3(fs_phone, VFS_OUT_STAT, file->node->devmap_handle,
1029 file->node->index, true, NULL);
1030 ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
1031 async_wait_for(msg, &rc);
1032 vfs_release_phone(file->node->fs_handle, fs_phone);
1033
1034 fibril_mutex_unlock(&file->lock);
1035 ipc_answer_0(rid, rc);
1036}
1037
1038void vfs_stat(ipc_callid_t rid, ipc_call_t *request)
1039{
1040 char *path;
1041 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL);
1042 if (rc != EOK) {
1043 ipc_answer_0(rid, rc);
1044 return;
1045 }
1046
1047 ipc_callid_t callid;
1048 if (!async_data_read_receive(&callid, NULL)) {
1049 free(path);
1050 ipc_answer_0(callid, EINVAL);
1051 ipc_answer_0(rid, EINVAL);
1052 return;
1053 }
1054
1055 vfs_lookup_res_t lr;
1056 fibril_rwlock_read_lock(&namespace_rwlock);
1057 rc = vfs_lookup_internal(path, L_NONE, &lr, NULL);
1058 free(path);
1059 if (rc != EOK) {
1060 fibril_rwlock_read_unlock(&namespace_rwlock);
1061 ipc_answer_0(callid, rc);
1062 ipc_answer_0(rid, rc);
1063 return;
1064 }
1065 vfs_node_t *node = vfs_node_get(&lr);
1066 if (!node) {
1067 fibril_rwlock_read_unlock(&namespace_rwlock);
1068 ipc_answer_0(callid, ENOMEM);
1069 ipc_answer_0(rid, ENOMEM);
1070 return;
1071 }
1072
1073 fibril_rwlock_read_unlock(&namespace_rwlock);
1074
1075 int fs_phone = vfs_grab_phone(node->fs_handle);
1076 aid_t msg;
1077 msg = async_send_3(fs_phone, VFS_OUT_STAT, node->devmap_handle,
1078 node->index, false, NULL);
1079 ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
1080
1081 ipcarg_t rv;
1082 async_wait_for(msg, &rv);
1083 vfs_release_phone(node->fs_handle, fs_phone);
1084
1085 ipc_answer_0(rid, rv);
1086
1087 vfs_node_put(node);
1088}
1089
1090void vfs_mkdir(ipc_callid_t rid, ipc_call_t *request)
1091{
1092 int mode = IPC_GET_ARG1(*request);
1093
1094 char *path;
1095 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL);
1096 if (rc != EOK) {
1097 ipc_answer_0(rid, rc);
1098 return;
1099 }
1100
1101 /* Ignore mode for now. */
1102 (void) mode;
1103
1104 fibril_rwlock_write_lock(&namespace_rwlock);
1105 int lflag = L_DIRECTORY | L_CREATE | L_EXCLUSIVE;
1106 rc = vfs_lookup_internal(path, lflag, NULL, NULL);
1107 fibril_rwlock_write_unlock(&namespace_rwlock);
1108 free(path);
1109 ipc_answer_0(rid, rc);
1110}
1111
1112void vfs_unlink(ipc_callid_t rid, ipc_call_t *request)
1113{
1114 int lflag = IPC_GET_ARG1(*request);
1115
1116 char *path;
1117 int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL);
1118 if (rc != EOK) {
1119 ipc_answer_0(rid, rc);
1120 return;
1121 }
1122
1123 fibril_rwlock_write_lock(&namespace_rwlock);
1124 lflag &= L_DIRECTORY; /* sanitize lflag */
1125 vfs_lookup_res_t lr;
1126 rc = vfs_lookup_internal(path, lflag | L_UNLINK, &lr, NULL);
1127 free(path);
1128 if (rc != EOK) {
1129 fibril_rwlock_write_unlock(&namespace_rwlock);
1130 ipc_answer_0(rid, rc);
1131 return;
1132 }
1133
1134 /*
1135 * The name has already been unlinked by vfs_lookup_internal().
1136 * We have to get and put the VFS node to ensure that it is
1137 * VFS_OUT_DESTROY'ed after the last reference to it is dropped.
1138 */
1139 vfs_node_t *node = vfs_node_get(&lr);
1140 fibril_mutex_lock(&nodes_mutex);
1141 node->lnkcnt--;
1142 fibril_mutex_unlock(&nodes_mutex);
1143 fibril_rwlock_write_unlock(&namespace_rwlock);
1144 vfs_node_put(node);
1145 ipc_answer_0(rid, EOK);
1146}
1147
1148void vfs_rename(ipc_callid_t rid, ipc_call_t *request)
1149{
1150 /* Retrieve the old path. */
1151 char *old;
1152 int rc = async_data_write_accept((void **) &old, true, 0, 0, 0, NULL);
1153 if (rc != EOK) {
1154 ipc_answer_0(rid, rc);
1155 return;
1156 }
1157
1158 /* Retrieve the new path. */
1159 char *new;
1160 rc = async_data_write_accept((void **) &new, true, 0, 0, 0, NULL);
1161 if (rc != EOK) {
1162 free(old);
1163 ipc_answer_0(rid, rc);
1164 return;
1165 }
1166
1167 size_t olen;
1168 size_t nlen;
1169 char *oldc = canonify(old, &olen);
1170 char *newc = canonify(new, &nlen);
1171
1172 if ((!oldc) || (!newc)) {
1173 ipc_answer_0(rid, EINVAL);
1174 free(old);
1175 free(new);
1176 return;
1177 }
1178
1179 oldc[olen] = '\0';
1180 newc[nlen] = '\0';
1181
1182 if ((!str_lcmp(newc, oldc, str_length(oldc))) &&
1183 ((newc[str_length(oldc)] == '/') ||
1184 (str_length(oldc) == 1) ||
1185 (str_length(oldc) == str_length(newc)))) {
1186 /*
1187 * oldc is a prefix of newc and either
1188 * - newc continues with a / where oldc ends, or
1189 * - oldc was / itself, or
1190 * - oldc and newc are equal.
1191 */
1192 ipc_answer_0(rid, EINVAL);
1193 free(old);
1194 free(new);
1195 return;
1196 }
1197
1198 vfs_lookup_res_t old_lr;
1199 vfs_lookup_res_t new_lr;
1200 vfs_lookup_res_t new_par_lr;
1201 fibril_rwlock_write_lock(&namespace_rwlock);
1202
1203 /* Lookup the node belonging to the old file name. */
1204 rc = vfs_lookup_internal(oldc, L_NONE, &old_lr, NULL);
1205 if (rc != EOK) {
1206 fibril_rwlock_write_unlock(&namespace_rwlock);
1207 ipc_answer_0(rid, rc);
1208 free(old);
1209 free(new);
1210 return;
1211 }
1212
1213 vfs_node_t *old_node = vfs_node_get(&old_lr);
1214 if (!old_node) {
1215 fibril_rwlock_write_unlock(&namespace_rwlock);
1216 ipc_answer_0(rid, ENOMEM);
1217 free(old);
1218 free(new);
1219 return;
1220 }
1221
1222 /* Determine the path to the parent of the node with the new name. */
1223 char *parentc = str_dup(newc);
1224 if (!parentc) {
1225 fibril_rwlock_write_unlock(&namespace_rwlock);
1226 ipc_answer_0(rid, rc);
1227 free(old);
1228 free(new);
1229 return;
1230 }
1231
1232 char *lastsl = str_rchr(parentc + 1, '/');
1233 if (lastsl)
1234 *lastsl = '\0';
1235 else
1236 parentc[1] = '\0';
1237
1238 /* Lookup parent of the new file name. */
1239 rc = vfs_lookup_internal(parentc, L_NONE, &new_par_lr, NULL);
1240 free(parentc); /* not needed anymore */
1241 if (rc != EOK) {
1242 fibril_rwlock_write_unlock(&namespace_rwlock);
1243 ipc_answer_0(rid, rc);
1244 free(old);
1245 free(new);
1246 return;
1247 }
1248
1249 /* Check whether linking to the same file system instance. */
1250 if ((old_node->fs_handle != new_par_lr.triplet.fs_handle) ||
1251 (old_node->devmap_handle != new_par_lr.triplet.devmap_handle)) {
1252 fibril_rwlock_write_unlock(&namespace_rwlock);
1253 ipc_answer_0(rid, EXDEV); /* different file systems */
1254 free(old);
1255 free(new);
1256 return;
1257 }
1258
1259 /* Destroy the old link for the new name. */
1260 vfs_node_t *new_node = NULL;
1261 rc = vfs_lookup_internal(newc, L_UNLINK, &new_lr, NULL);
1262
1263 switch (rc) {
1264 case ENOENT:
1265 /* simply not in our way */
1266 break;
1267 case EOK:
1268 new_node = vfs_node_get(&new_lr);
1269 if (!new_node) {
1270 fibril_rwlock_write_unlock(&namespace_rwlock);
1271 ipc_answer_0(rid, ENOMEM);
1272 free(old);
1273 free(new);
1274 return;
1275 }
1276 fibril_mutex_lock(&nodes_mutex);
1277 new_node->lnkcnt--;
1278 fibril_mutex_unlock(&nodes_mutex);
1279 break;
1280 default:
1281 fibril_rwlock_write_unlock(&namespace_rwlock);
1282 ipc_answer_0(rid, ENOTEMPTY);
1283 free(old);
1284 free(new);
1285 return;
1286 }
1287
1288 /* Create the new link for the new name. */
1289 rc = vfs_lookup_internal(newc, L_LINK, NULL, NULL, old_node->index);
1290 if (rc != EOK) {
1291 fibril_rwlock_write_unlock(&namespace_rwlock);
1292 if (new_node)
1293 vfs_node_put(new_node);
1294 ipc_answer_0(rid, rc);
1295 free(old);
1296 free(new);
1297 return;
1298 }
1299
1300 fibril_mutex_lock(&nodes_mutex);
1301 old_node->lnkcnt++;
1302 fibril_mutex_unlock(&nodes_mutex);
1303
1304 /* Destroy the link for the old name. */
1305 rc = vfs_lookup_internal(oldc, L_UNLINK, NULL, NULL);
1306 if (rc != EOK) {
1307 fibril_rwlock_write_unlock(&namespace_rwlock);
1308 vfs_node_put(old_node);
1309 if (new_node)
1310 vfs_node_put(new_node);
1311 ipc_answer_0(rid, rc);
1312 free(old);
1313 free(new);
1314 return;
1315 }
1316
1317 fibril_mutex_lock(&nodes_mutex);
1318 old_node->lnkcnt--;
1319 fibril_mutex_unlock(&nodes_mutex);
1320 fibril_rwlock_write_unlock(&namespace_rwlock);
1321 vfs_node_put(old_node);
1322
1323 if (new_node)
1324 vfs_node_put(new_node);
1325
1326 free(old);
1327 free(new);
1328 ipc_answer_0(rid, EOK);
1329}
1330
1331void vfs_dup(ipc_callid_t rid, ipc_call_t *request)
1332{
1333 int oldfd = IPC_GET_ARG1(*request);
1334 int newfd = IPC_GET_ARG2(*request);
1335
1336 /* Lookup the file structure corresponding to oldfd. */
1337 vfs_file_t *oldfile = vfs_file_get(oldfd);
1338 if (!oldfile) {
1339 ipc_answer_0(rid, EBADF);
1340 return;
1341 }
1342
1343 /* If the file descriptors are the same, do nothing. */
1344 if (oldfd == newfd) {
1345 ipc_answer_1(rid, EOK, newfd);
1346 return;
1347 }
1348
1349 /*
1350 * Lock the open file structure so that no other thread can manipulate
1351 * the same open file at a time.
1352 */
1353 fibril_mutex_lock(&oldfile->lock);
1354
1355 /* Lookup an open file structure possibly corresponding to newfd. */
1356 vfs_file_t *newfile = vfs_file_get(newfd);
1357 if (newfile) {
1358 /* Close the originally opened file. */
1359 int ret = vfs_close_internal(newfile);
1360 if (ret != EOK) {
1361 fibril_mutex_unlock(&oldfile->lock);
1362 ipc_answer_0(rid, ret);
1363 return;
1364 }
1365
1366 ret = vfs_fd_free(newfd);
1367 if (ret != EOK) {
1368 fibril_mutex_unlock(&oldfile->lock);
1369 ipc_answer_0(rid, ret);
1370 return;
1371 }
1372 }
1373
1374 /* Assign the old file to newfd. */
1375 int ret = vfs_fd_assign(oldfile, newfd);
1376 fibril_mutex_unlock(&oldfile->lock);
1377
1378 if (ret != EOK)
1379 ipc_answer_0(rid, ret);
1380 else
1381 ipc_answer_1(rid, EOK, newfd);
1382}
1383
1384/**
1385 * @}
1386 */
Note: See TracBrowser for help on using the repository browser.