Changes in uspace/srv/vfs/vfs_register.c [eda925a:1e4cada] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_register.c
reda925a r1e4cada 110 110 void vfs_register(ipc_callid_t rid, ipc_call_t *request) 111 111 { 112 ipc_callid_t callid; 113 ipc_call_t call; 114 int rc; 115 size_t size; 116 112 117 dprintf("Processing VFS_REGISTER request received from %p.\n", 113 118 request->in_phone_hash); 114 115 vfs_info_t *vfs_info; 116 int rc = async_data_write_accept((void **) &vfs_info, false, 117 sizeof(vfs_info_t), sizeof(vfs_info_t), 0, NULL); 118 119 120 /* 121 * The first call has to be IPC_M_DATA_SEND in which we receive the 122 * VFS info structure from the client FS. 123 */ 124 if (!async_data_write_receive(&callid, &size)) { 125 /* 126 * The client doesn't obey the same protocol as we do. 127 */ 128 dprintf("Receiving of VFS info failed.\n"); 129 ipc_answer_0(callid, EINVAL); 130 ipc_answer_0(rid, EINVAL); 131 return; 132 } 133 134 dprintf("VFS info received, size = %d\n", size); 135 136 /* 137 * We know the size of the VFS info structure. See if the client 138 * understands this easy concept too. 139 */ 140 if (size != sizeof(vfs_info_t)) { 141 /* 142 * The client is sending us something, which cannot be 143 * the info structure. 144 */ 145 dprintf("Received VFS info has bad size.\n"); 146 ipc_answer_0(callid, EINVAL); 147 ipc_answer_0(rid, EINVAL); 148 return; 149 } 150 151 /* 152 * Allocate and initialize a buffer for the fs_info structure. 153 */ 154 fs_info_t *fs_info; 155 fs_info = (fs_info_t *) malloc(sizeof(fs_info_t)); 156 if (!fs_info) { 157 dprintf("Could not allocate memory for FS info.\n"); 158 ipc_answer_0(callid, ENOMEM); 159 ipc_answer_0(rid, ENOMEM); 160 return; 161 } 162 link_initialize(&fs_info->fs_link); 163 fibril_mutex_initialize(&fs_info->phone_lock); 164 165 rc = async_data_write_finalize(callid, &fs_info->vfs_info, size); 119 166 if (rc != EOK) { 120 167 dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n", 121 168 rc); 169 free(fs_info); 170 ipc_answer_0(callid, rc); 122 171 ipc_answer_0(rid, rc); 123 172 return; 124 173 } 125 126 /* 127 * Allocate and initialize a buffer for the fs_info structure. 128 */ 129 fs_info_t *fs_info = (fs_info_t *) malloc(sizeof(fs_info_t)); 130 if (!fs_info) { 131 dprintf("Could not allocate memory for FS info.\n"); 132 ipc_answer_0(rid, ENOMEM); 133 return; 134 } 135 136 link_initialize(&fs_info->fs_link); 137 fibril_mutex_initialize(&fs_info->phone_lock); 138 fs_info->vfs_info = *vfs_info; 139 free(vfs_info); 140 174 141 175 dprintf("VFS info delivered.\n"); 142 176 143 177 if (!vfs_info_sane(&fs_info->vfs_info)) { 144 178 free(fs_info); 145 ipc_answer_0(rid, EINVAL); 146 return; 147 } 148 179 ipc_answer_0(callid, EINVAL); 180 ipc_answer_0(rid, EINVAL); 181 return; 182 } 183 149 184 fibril_mutex_lock(&fs_head_lock); 150 185 151 186 /* 152 187 * Check for duplicit registrations. … … 159 194 fibril_mutex_unlock(&fs_head_lock); 160 195 free(fs_info); 196 ipc_answer_0(callid, EEXISTS); 161 197 ipc_answer_0(rid, EEXISTS); 162 198 return; 163 199 } 164 200 165 201 /* 166 202 * Add fs_info to the list of registered FS's. … … 174 210 * which to forward VFS requests to it. 175 211 */ 176 ipc_call_t call; 177 ipc_callid_t callid = async_get_call(&call); 212 callid = async_get_call(&call); 178 213 if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) { 179 214 dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); … … 187 222 fs_info->phone = IPC_GET_ARG5(call); 188 223 ipc_answer_0(callid, EOK); 189 224 190 225 dprintf("Callback connection to FS created.\n"); 191 226 192 227 /* 193 228 * The client will want us to send him the address space area with PLB. 194 229 */ 195 196 size_t size; 230 197 231 if (!async_share_in_receive(&callid, &size)) { 198 232 dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); … … 219 253 return; 220 254 } 221 255 222 256 /* 223 257 * Commit to read-only sharing the PLB with the client. … … 225 259 (void) async_share_in_finalize(callid, plb, 226 260 AS_AREA_READ | AS_AREA_CACHEABLE); 227 261 228 262 dprintf("Sharing PLB.\n"); 229 263 230 264 /* 231 265 * That was it. The FS has been registered.
Note:
See TracChangeset
for help on using the changeset viewer.