[d5cdffe] | 1 | /*
|
---|
| 2 | * Copyright (c) 2006 Martin Decky
|
---|
[cad9c72] | 3 | * Copyright (c) 2008 Jakub Jermar
|
---|
[d5cdffe] | 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | /** @addtogroup fs
|
---|
| 31 | * @{
|
---|
[79ae36dd] | 32 | */
|
---|
[d5cdffe] | 33 |
|
---|
| 34 | /**
|
---|
| 35 | * @file tmpfs.c
|
---|
| 36 | * @brief File system driver for in-memory file system.
|
---|
| 37 | *
|
---|
| 38 | * Every instance of tmpfs exists purely in memory and has neither a disk layout
|
---|
| 39 | * nor any permanent storage (e.g. disk blocks). With each system reboot, data
|
---|
| 40 | * stored in a tmpfs file system is lost.
|
---|
| 41 | */
|
---|
| 42 |
|
---|
| 43 | #include "tmpfs.h"
|
---|
| 44 | #include <ipc/services.h>
|
---|
[79ae36dd] | 45 | #include <ns.h>
|
---|
[d5cdffe] | 46 | #include <async.h>
|
---|
| 47 | #include <errno.h>
|
---|
| 48 | #include <stdio.h>
|
---|
[bbddafb] | 49 | #include <task.h>
|
---|
[d5cdffe] | 50 | #include <libfs.h>
|
---|
| 51 | #include "../../vfs/vfs.h"
|
---|
| 52 |
|
---|
[a4b4b47] | 53 | #define NAME "tmpfs"
|
---|
| 54 |
|
---|
[d5cdffe] | 55 |
|
---|
| 56 | vfs_info_t tmpfs_vfs_info = {
|
---|
[5643a04] | 57 | .name = NAME,
|
---|
[5581b469] | 58 | .concurrent_read_write = false,
|
---|
| 59 | .write_retains_size = false,
|
---|
[4979403] | 60 | .instance = 0,
|
---|
[d5cdffe] | 61 | };
|
---|
| 62 |
|
---|
| 63 | int main(int argc, char **argv)
|
---|
| 64 | {
|
---|
[a4b4b47] | 65 | printf(NAME ": HelenOS TMPFS file system server\n");
|
---|
[4979403] | 66 |
|
---|
| 67 | if (argc == 3) {
|
---|
| 68 | if (!str_cmp(argv[1], "--instance"))
|
---|
| 69 | tmpfs_vfs_info.instance = strtol(argv[2], NULL, 10);
|
---|
| 70 | else {
|
---|
| 71 | printf(NAME " Unrecognized parameters");
|
---|
| 72 | return -1;
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
[79ae36dd] | 75 |
|
---|
[8d049ee0] | 76 | if (!tmpfs_init()) {
|
---|
| 77 | printf(NAME ": failed to initialize TMPFS\n");
|
---|
| 78 | return -1;
|
---|
| 79 | }
|
---|
[79ae36dd] | 80 |
|
---|
[f9b2cb4c] | 81 | async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
|
---|
| 82 | INTERFACE_VFS_DRIVER, 0);
|
---|
[79ae36dd] | 83 | if (!vfs_sess) {
|
---|
[a32c9bb] | 84 | printf(NAME ": Unable to connect to VFS\n");
|
---|
| 85 | return -1;
|
---|
[d5cdffe] | 86 | }
|
---|
[79ae36dd] | 87 |
|
---|
[efcebe1] | 88 | int rc = fs_register(vfs_sess, &tmpfs_vfs_info, &tmpfs_ops,
|
---|
| 89 | &tmpfs_libfs_ops);
|
---|
[d5cdffe] | 90 | if (rc != EOK) {
|
---|
[a4b4b47] | 91 | printf(NAME ": Failed to register file system (%d)\n", rc);
|
---|
[d5cdffe] | 92 | return rc;
|
---|
| 93 | }
|
---|
[79ae36dd] | 94 |
|
---|
[a4b4b47] | 95 | printf(NAME ": Accepting connections\n");
|
---|
[bbddafb] | 96 | task_retval(0);
|
---|
[d5cdffe] | 97 | async_manager();
|
---|
[79ae36dd] | 98 |
|
---|
| 99 | /* Not reached */
|
---|
[d5cdffe] | 100 | return 0;
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | /**
|
---|
| 104 | * @}
|
---|
[79ae36dd] | 105 | */
|
---|