source: mainline/uspace/srv/vfs/vfs.c@ 63a3276

Last change on this file since 63a3276 was 4224ef7, checked in by Matthieu Riolo <matthieu.riolo@…>, 6 years ago

sysman: Add VFS FS server autostart

  • VFS autostart instrumentation removes explicit dependency on FS servers.
  • Compositor service properly named, it's now resolved as implicit dependency.

Conflicts:

boot/Makefile.common
uspace/lib/gui/window.c
uspace/srv/locsrv/locsrv.c
uspace/srv/vfs/vfs.c
uspace/srv/vfs/vfs_ops.c

  • Property mode set to 100644
File size: 4.3 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 vfs
30 * @{
31 */
32
33/**
34 * @file vfs.c
35 * @brief VFS service for HelenOS.
36 */
37
38#include <vfs/vfs.h>
39#include <stdlib.h>
40#include <ipc/services.h>
41#include <abi/ipc/methods.h>
42#include <ns.h>
43#include <as.h>
44#include <async.h>
45#include <atomic.h>
46#include <errno.h>
47#include <str_error.h>
48#include <stdio.h>
49#include <ipc/services.h>
50#include <macros.h>
51#include <stdbool.h>
52#include <stdio.h>
53#include <str.h>
54#include <sysman/broker.h>
55#include "vfs.h"
56
57#define NAME "vfs"
58
59static void vfs_pager(ipc_call_t *icall, void *arg)
60{
61 async_accept_0(icall);
62
63 while (true) {
64 ipc_call_t call;
65 async_get_call(&call);
66
67 if (!ipc_get_imethod(&call)) {
68 async_answer_0(&call, EOK);
69 break;
70 }
71
72 switch (ipc_get_imethod(&call)) {
73 case IPC_M_PAGE_IN:
74 vfs_page_in(&call);
75 break;
76 default:
77 async_answer_0(&call, ENOTSUP);
78 break;
79 }
80 }
81}
82
83static void notification_handler(ipc_call_t *call, void *arg)
84{
85 if (ipc_get_arg1(call) == VFS_PASS_HANDLE)
86 vfs_op_pass_handle(
87 (task_id_t) MERGE_LOUP32(ipc_get_arg4(call),
88 ipc_get_arg5(call)), call->task_id,
89 (int) ipc_get_arg2(call));
90}
91
92int main(int argc, char **argv)
93{
94 printf("%s: HelenOS VFS server\n", NAME);
95
96 /*
97 * Initialize VFS node hash table.
98 */
99 if (!vfs_nodes_init()) {
100 printf("%s: Failed to initialize VFS node hash table\n",
101 NAME);
102 return ENOMEM;
103 }
104
105 /*
106 * Allocate and initialize the Path Lookup Buffer.
107 */
108 plb = as_area_create(AS_AREA_ANY, PLB_SIZE,
109 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, AS_AREA_UNPAGED);
110 if (plb == AS_MAP_FAILED) {
111 printf("%s: Cannot create address space area\n", NAME);
112 return ENOMEM;
113 }
114 memset(plb, 0, PLB_SIZE);
115
116 /*
117 * Set client data constructor and destructor.
118 */
119 async_set_client_data_constructor(vfs_client_data_create);
120 async_set_client_data_destructor(vfs_client_data_destroy);
121
122 /*
123 * Subscribe to notifications.
124 */
125 async_event_task_subscribe(EVENT_TASK_STATE_CHANGE, notification_handler,
126 NULL);
127
128 /*
129 * Register at the naming service.
130 */
131 errno_t rc = service_register(SERVICE_VFS, INTERFACE_PAGER, vfs_pager, NULL);
132 if (rc != EOK) {
133 printf("%s: Cannot register VFS pager port: %s\n", NAME, str_error(rc));
134 return rc;
135 }
136
137 rc = service_register(SERVICE_VFS, INTERFACE_VFS, vfs_connection, NULL);
138 if (rc != EOK) {
139 printf("%s: Cannot register VFS file system port: %s\n", NAME, str_error(rc));
140 return rc;
141 }
142
143 rc = service_register(SERVICE_VFS, INTERFACE_VFS_DRIVER, vfs_connection, NULL);
144 if (rc != EOK) {
145 printf("%s: Cannot register VFS driver port: %s\n", NAME, str_error(rc));
146 return rc;
147 }
148
149 /*
150 * Let sysman know we are broker
151 */
152 rc = sysman_broker_register();
153 if (rc != EOK) {
154 printf("%s: Error registering at sysman (%i)\n", NAME, rc);
155 return rc;
156 }
157
158 /*
159 * Start accepting connections.
160 */
161 printf("%s: Accepting connections\n", NAME);
162 async_manager();
163 return 0;
164}
165
166/**
167 * @}
168 */
Note: See TracBrowser for help on using the repository browser.