Changeset a35b458 in mainline for uspace/srv/vfs/vfs_register.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_register.c
r3061bc1 ra35b458 71 71 { 72 72 int i; 73 73 74 74 /* 75 75 * Check if the name is non-empty and is composed solely of ASCII … … 80 80 return false; 81 81 } 82 82 83 83 for (i = 1; i < FS_NAME_MAXLEN; i++) { 84 84 if (!(islower(info->name[i]) || isdigit(info->name[i])) && … … 93 93 } 94 94 } 95 95 96 96 /* 97 97 * This check is not redundant. It ensures that the name is … … 102 102 return false; 103 103 } 104 104 105 105 return true; 106 106 } … … 116 116 dprintf("Processing VFS_REGISTER request received from %zx.\n", 117 117 request->in_phone_hash); 118 118 119 119 vfs_info_t *vfs_info; 120 120 errno_t rc = async_data_write_accept((void **) &vfs_info, false, 121 121 sizeof(vfs_info_t), sizeof(vfs_info_t), 0, NULL); 122 122 123 123 if (rc != EOK) { 124 124 dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n", … … 127 127 return; 128 128 } 129 129 130 130 /* 131 131 * Allocate and initialize a buffer for the fs_info structure. … … 137 137 return; 138 138 } 139 139 140 140 link_initialize(&fs_info->fs_link); 141 141 fs_info->vfs_info = *vfs_info; 142 142 free(vfs_info); 143 143 144 144 dprintf("VFS info delivered.\n"); 145 145 146 146 if (!vfs_info_sane(&fs_info->vfs_info)) { 147 147 free(fs_info); … … 149 149 return; 150 150 } 151 151 152 152 fibril_mutex_lock(&fs_list_lock); 153 153 154 154 /* 155 155 * Check for duplicit registrations. … … 166 166 return; 167 167 } 168 168 169 169 /* 170 170 * Add fs_info to the list of registered FS's. … … 172 172 dprintf("Inserting FS into the list of registered file systems.\n"); 173 173 list_append(&fs_info->fs_link, &fs_list); 174 174 175 175 /* 176 176 * Now we want the client to send us the IPC_M_CONNECT_TO_ME call so … … 187 187 return; 188 188 } 189 189 190 190 dprintf("Callback connection to FS created.\n"); 191 191 192 192 /* 193 193 * The client will want us to send him the address space area with PLB. 194 194 */ 195 195 196 196 size_t size; 197 197 ipc_callid_t callid; … … 206 206 return; 207 207 } 208 208 209 209 /* 210 210 * We can only send the client address space area PLB_SIZE bytes long. … … 220 220 return; 221 221 } 222 222 223 223 /* 224 224 * Commit to read-only sharing the PLB with the client. … … 226 226 (void) async_share_in_finalize(callid, plb, 227 227 AS_AREA_READ | AS_AREA_CACHEABLE); 228 228 229 229 dprintf("Sharing PLB.\n"); 230 230 231 231 /* 232 232 * That was it. The FS has been registered. … … 236 236 fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next); 237 237 async_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle); 238 238 239 239 fibril_condvar_broadcast(&fs_list_cv); 240 240 fibril_mutex_unlock(&fs_list_lock); 241 241 242 242 dprintf("\"%.*s\" filesystem successfully registered, handle=%d.\n", 243 243 FS_NAME_MAXLEN, fs_info->vfs_info.name, fs_info->fs_handle); … … 260 260 */ 261 261 fibril_mutex_lock(&fs_list_lock); 262 262 263 263 list_foreach(fs_list, fs_link, fs_info_t, fs) { 264 264 if (fs->fs_handle == handle) { 265 265 fibril_mutex_unlock(&fs_list_lock); 266 266 267 267 assert(fs->sess); 268 268 async_exch_t *exch = async_exchange_begin(fs->sess); 269 269 270 270 assert(exch); 271 271 return exch; 272 272 } 273 273 } 274 274 275 275 fibril_mutex_unlock(&fs_list_lock); 276 276 277 277 return NULL; 278 278 } … … 300 300 { 301 301 int handle = 0; 302 302 303 303 if (lock) 304 304 fibril_mutex_lock(&fs_list_lock); 305 305 306 306 list_foreach(fs_list, fs_link, fs_info_t, fs) { 307 307 if (str_cmp(fs->vfs_info.name, name) == 0 && … … 311 311 } 312 312 } 313 313 314 314 if (lock) 315 315 fibril_mutex_unlock(&fs_list_lock); 316 316 317 317 return handle; 318 318 } … … 328 328 { 329 329 vfs_info_t *info = NULL; 330 330 331 331 fibril_mutex_lock(&fs_list_lock); 332 332 list_foreach(fs_list, fs_link, fs_info_t, fs) { … … 337 337 } 338 338 fibril_mutex_unlock(&fs_list_lock); 339 339 340 340 return info; 341 341 } … … 355 355 356 356 fibril_mutex_lock(&fs_list_lock); 357 357 358 358 size = 0; 359 359 count = 0; … … 362 362 count++; 363 363 } 364 364 365 365 if (size == 0) 366 366 size = 1; 367 367 368 368 fstypes->buf = calloc(1, size); 369 369 if (fstypes->buf == NULL) { … … 371 371 return ENOMEM; 372 372 } 373 373 374 374 fstypes->fstypes = calloc(sizeof(char *), count); 375 375 if (fstypes->fstypes == NULL) { … … 379 379 return ENOMEM; 380 380 } 381 381 382 382 fstypes->size = size; 383 383 384 384 size = 0; count = 0; 385 385 list_foreach(fs_list, fs_link, fs_info_t, fs) {
Note:
See TracChangeset
for help on using the changeset viewer.