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


Ignore:
Timestamp:
2011-05-31T23:11:28Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5d1b3aa
Parents:
4ce90544 (diff), 25bef0ff (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.
Message:

Merge from lp:~jakub/helenos/fs.

File:
1 edited

Legend:

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

    r4ce90544 re8d5f9f  
    7979        for (i = 0; i < MAX_OPEN_FILES; i++) {
    8080                if (FILES[i]) {
    81                         (void) vfs_close_internal(FILES[i]);
    8281                        (void) vfs_fd_free(i);
    8382                }
     
    108107}
    109108
     109/** Close the file in the endpoint FS server. */
     110static int vfs_file_close_remote(vfs_file_t *file)
     111{
     112        ipc_call_t answer;
     113        aid_t msg;
     114        sysarg_t rc;
     115        int phone;
     116
     117        assert(!file->refcnt);
     118
     119        phone = vfs_grab_phone(file->node->fs_handle);
     120        msg = async_send_2(phone, VFS_OUT_CLOSE, file->node->devmap_handle,
     121            file->node->index, &answer);
     122        async_wait_for(msg, &rc);
     123        vfs_release_phone(file->node->fs_handle, phone);
     124
     125        return IPC_GET_ARG1(answer);
     126}
     127
     128
    110129/** Increment reference count of VFS file structure.
    111130 *
     
    125144 *                      decremented.
    126145 */
    127 static void vfs_file_delref(vfs_file_t *file)
    128 {
     146static int vfs_file_delref(vfs_file_t *file)
     147{
     148        int rc = EOK;
     149
    129150        assert(fibril_mutex_is_locked(&VFS_DATA->lock));
    130151
    131152        if (file->refcnt-- == 1) {
    132153                /*
    133                  * Lost the last reference to a file, need to drop our reference
    134                  * to the underlying VFS node.
     154                 * Lost the last reference to a file, need to close it in the
     155                 * endpoint FS and drop our reference to the underlying VFS node.
    135156                 */
     157                rc = vfs_file_close_remote(file);
    136158                vfs_node_delref(file->node);
    137159                free(file);
    138160        }
     161
     162        return rc;
    139163}
    140164
     
    201225int vfs_fd_free(int fd)
    202226{
     227        int rc;
     228
    203229        if (!vfs_files_init())
    204230                return ENOMEM;
     
    210236        }
    211237       
    212         vfs_file_delref(FILES[fd]);
     238        rc = vfs_file_delref(FILES[fd]);
    213239        FILES[fd] = NULL;
    214240        fibril_mutex_unlock(&VFS_DATA->lock);
    215241       
    216         return EOK;
     242        return rc;
    217243}
    218244
Note: See TracChangeset for help on using the changeset viewer.