Changeset c577a9a in mainline for uspace/srv/vfs/vfs_file.c
- Timestamp:
- 2017-03-05T20:23:05Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 354b642
- Parents:
- 1dff985
- git-author:
- Jiri Zarevucky <zarevucky.jiri@…> (2017-03-05 20:23:05)
- git-committer:
- Jakub Jermar <jakub@…> (2017-03-05 20:23:05)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_file.c
r1dff985 rc577a9a 187 187 } 188 188 189 static int _vfs_fd_alloc(vfs_client_data_t *vfs_data, bool desc)189 static int _vfs_fd_alloc(vfs_client_data_t *vfs_data, vfs_file_t **file, bool desc) 190 190 { 191 191 if (!vfs_files_init(vfs_data)) … … 207 207 } 208 208 209 209 210 memset(vfs_data->files[i], 0, sizeof(vfs_file_t)); 210 fibril_mutex_initialize(&vfs_data->files[i]->lock); 211 212 fibril_mutex_initialize(&vfs_data->files[i]->_lock); 213 fibril_mutex_lock(&vfs_data->files[i]->_lock); 211 214 vfs_file_addref(vfs_data, vfs_data->files[i]); 215 216 *file = vfs_data->files[i]; 217 vfs_file_addref(vfs_data, *file); 218 212 219 fibril_mutex_unlock(&vfs_data->lock); 213 220 return (int) i; … … 233 240 /** Allocate a file descriptor. 234 241 * 242 * @param file Is set to point to the newly created file structure. Must be put afterwards. 235 243 * @param desc If true, look for an available file descriptor 236 244 * in a descending order. … … 239 247 * code. 240 248 */ 241 int vfs_fd_alloc( bool desc)242 { 243 return _vfs_fd_alloc(VFS_DATA, desc);249 int vfs_fd_alloc(vfs_file_t **file, bool desc) 250 { 251 return _vfs_fd_alloc(VFS_DATA, file, desc); 244 252 } 245 253 … … 314 322 vfs_file_addref(vfs_data, file); 315 323 fibril_mutex_unlock(&vfs_data->lock); 324 fibril_mutex_lock(&file->_lock); 316 325 return file; 317 326 } … … 335 344 static void _vfs_file_put(vfs_client_data_t *vfs_data, vfs_file_t *file) 336 345 { 346 fibril_mutex_unlock(&file->_lock); 347 337 348 fibril_mutex_lock(&vfs_data->lock); 338 349 vfs_file_delref(vfs_data, file); … … 376 387 goto out; 377 388 378 acceptor_fd = _vfs_fd_alloc(acceptor_data, false);389 acceptor_fd = _vfs_fd_alloc(acceptor_data, &acceptor_file, false); 379 390 if (acceptor_fd < 0) 380 391 goto out; … … 388 399 (void) vfs_open_node_remote(donor_file->node); 389 400 390 acceptor_file = _vfs_file_get(acceptor_data, acceptor_fd);391 401 assert(acceptor_file); 392 402
Note:
See TracChangeset
for help on using the changeset viewer.