Changeset c577a9a in mainline for uspace/srv/vfs/vfs_file.c


Ignore:
Timestamp:
2017-03-05T20:23:05Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
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)
Message:

Merge from lp:~zarevucky-jiri/helenos/vfs-2.5 revisions 1929-1930

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_file.c

    r1dff985 rc577a9a  
    187187}
    188188
    189 static int _vfs_fd_alloc(vfs_client_data_t *vfs_data, bool desc)
     189static int _vfs_fd_alloc(vfs_client_data_t *vfs_data, vfs_file_t **file, bool desc)
    190190{
    191191        if (!vfs_files_init(vfs_data))
     
    207207                        }
    208208                       
     209                       
    209210                        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);
    211214                        vfs_file_addref(vfs_data, vfs_data->files[i]);
     215                       
     216                        *file = vfs_data->files[i];
     217                        vfs_file_addref(vfs_data, *file);
     218                       
    212219                        fibril_mutex_unlock(&vfs_data->lock);
    213220                        return (int) i;
     
    233240/** Allocate a file descriptor.
    234241 *
     242 * @param file Is set to point to the newly created file structure. Must be put afterwards.
    235243 * @param desc If true, look for an available file descriptor
    236244 *             in a descending order.
     
    239247 *         code.
    240248 */
    241 int vfs_fd_alloc(bool desc)
    242 {
    243         return _vfs_fd_alloc(VFS_DATA, desc);
     249int vfs_fd_alloc(vfs_file_t **file, bool desc)
     250{
     251        return _vfs_fd_alloc(VFS_DATA, file, desc);
    244252}
    245253
     
    314322                        vfs_file_addref(vfs_data, file);
    315323                        fibril_mutex_unlock(&vfs_data->lock);
     324                        fibril_mutex_lock(&file->_lock);
    316325                        return file;
    317326                }
     
    335344static void _vfs_file_put(vfs_client_data_t *vfs_data, vfs_file_t *file)
    336345{
     346        fibril_mutex_unlock(&file->_lock);
     347       
    337348        fibril_mutex_lock(&vfs_data->lock);
    338349        vfs_file_delref(vfs_data, file);
     
    376387                goto out;
    377388
    378         acceptor_fd = _vfs_fd_alloc(acceptor_data, false);
     389        acceptor_fd = _vfs_fd_alloc(acceptor_data, &acceptor_file, false);
    379390        if (acceptor_fd < 0)
    380391                goto out;
     
    388399        (void) vfs_open_node_remote(donor_file->node);
    389400
    390         acceptor_file = _vfs_file_get(acceptor_data, acceptor_fd);
    391401        assert(acceptor_file);
    392402
Note: See TracChangeset for help on using the changeset viewer.