Changeset 19f24fd in mainline for uspace/srv/vfs/vfs_register.c
- Timestamp:
- 2010-02-05T22:25:52Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dafa2d04
- Parents:
- 83349b03 (diff), d42976c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_register.c
r83349b03 r19f24fd 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 117 112 dprintf("Processing VFS_REGISTER request received from %p.\n", 118 113 request->in_phone_hash); 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); 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 166 119 if (rc != EOK) { 167 120 dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n", 168 121 rc); 169 free(fs_info);170 ipc_answer_0(callid, rc);171 122 ipc_answer_0(rid, rc); 172 123 return; 173 124 } 174 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 175 141 dprintf("VFS info delivered.\n"); 176 142 177 143 if (!vfs_info_sane(&fs_info->vfs_info)) { 178 144 free(fs_info); 179 ipc_answer_0(callid, EINVAL);180 145 ipc_answer_0(rid, EINVAL); 181 146 return; 182 147 } 183 148 184 149 fibril_mutex_lock(&fs_head_lock); 185 150 186 151 /* 187 152 * Check for duplicit registrations. … … 194 159 fibril_mutex_unlock(&fs_head_lock); 195 160 free(fs_info); 196 ipc_answer_0(callid, EEXISTS);197 161 ipc_answer_0(rid, EEXISTS); 198 162 return; 199 163 } 200 164 201 165 /* 202 166 * Add fs_info to the list of registered FS's. … … 210 174 * which to forward VFS requests to it. 211 175 */ 212 callid = async_get_call(&call); 176 ipc_call_t call; 177 ipc_callid_t callid = async_get_call(&call); 213 178 if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) { 214 179 dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); … … 222 187 fs_info->phone = IPC_GET_ARG5(call); 223 188 ipc_answer_0(callid, EOK); 224 189 225 190 dprintf("Callback connection to FS created.\n"); 226 191 227 192 /* 228 193 * The client will want us to send him the address space area with PLB. 229 194 */ 230 195 196 size_t size; 231 197 if (!async_share_in_receive(&callid, &size)) { 232 198 dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); … … 253 219 return; 254 220 } 255 221 256 222 /* 257 223 * Commit to read-only sharing the PLB with the client. … … 259 225 (void) async_share_in_finalize(callid, plb, 260 226 AS_AREA_READ | AS_AREA_CACHEABLE); 261 227 262 228 dprintf("Sharing PLB.\n"); 263 229 264 230 /* 265 231 * That was it. The FS has been registered.
Note:
See TracChangeset
for help on using the changeset viewer.