source: mainline/uspace/srv/fs/tmpfs/tmpfs.c@ 86ffa27f

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 86ffa27f was efcebe1, checked in by Jakub Jermar <jakub@…>, 14 years ago

Get rid of per filesystem VFS_OUT method switch and IPC unmarshalling.

  • libfs now understands the notion of VFS_OUT operations and provides the single version of the switch
  • libfs now automatically takes care of some libfs provided operations, such as lookup and stat; filesystem need not be even aware of these
  • one filesystem time per libfs instance
  • plb_get_char() no longer a libfs operation
  • filesystem implemenations need not worry about IPC with the exception of VFS_OUT_READ/WRITE methods and filesystems that depend on doing extra IPC in these and similar methods, such as devfs
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * Copyright (c) 2006 Martin Decky
3 * Copyright (c) 2008 Jakub Jermar
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 * @{
32 */
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>
45#include <ns.h>
46#include <async.h>
47#include <errno.h>
48#include <unistd.h>
49#include <stdio.h>
50#include <task.h>
51#include <libfs.h>
52#include "../../vfs/vfs.h"
53
54#define NAME "tmpfs"
55
56
57vfs_info_t tmpfs_vfs_info = {
58 .name = NAME,
59 .concurrent_read_write = false,
60 .write_retains_size = false,
61};
62
63int main(int argc, char **argv)
64{
65 printf(NAME ": HelenOS TMPFS file system server\n");
66
67 if (!tmpfs_init()) {
68 printf(NAME ": failed to initialize TMPFS\n");
69 return -1;
70 }
71
72 async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
73 SERVICE_VFS, 0, 0);
74 if (!vfs_sess) {
75 printf(NAME ": Unable to connect to VFS\n");
76 return -1;
77 }
78
79 int rc = fs_register(vfs_sess, &tmpfs_vfs_info, &tmpfs_ops,
80 &tmpfs_libfs_ops);
81 if (rc != EOK) {
82 printf(NAME ": Failed to register file system (%d)\n", rc);
83 return rc;
84 }
85
86 printf(NAME ": Accepting connections\n");
87 task_retval(0);
88 async_manager();
89
90 /* Not reached */
91 return 0;
92}
93
94/**
95 * @}
96 */
Note: See TracBrowser for help on using the repository browser.