Changeset 41811af in mainline for uspace/srv/vfs/vfs_file.c


Ignore:
Timestamp:
2011-06-10T10:14:26Z (14 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ab547063
Parents:
9536e6e (diff), 390d80d (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 mainline

File:
1 edited

Legend:

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

    r9536e6e r41811af  
    4545#include "vfs.h"
    4646
    47 #define VFS_DATA        ((vfs_client_data_t *) async_client_data_get())
     47#define VFS_DATA        ((vfs_client_data_t *) async_get_client_data())
    4848#define FILES           (VFS_DATA->files)
    4949
     
    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        assert(!file->refcnt);
     113       
     114        async_exch_t *exch = vfs_exchange_grab(file->node->fs_handle);
     115       
     116        ipc_call_t answer;
     117        aid_t msg = async_send_2(exch, VFS_OUT_CLOSE, file->node->devmap_handle,
     118            file->node->index, &answer);
     119       
     120        vfs_exchange_release(exch);
     121       
     122        sysarg_t rc;
     123        async_wait_for(msg, &rc);
     124       
     125        return IPC_GET_ARG1(answer);
     126}
     127
    110128/** Increment reference count of VFS file structure.
    111129 *
     
    125143 *                      decremented.
    126144 */
    127 static void vfs_file_delref(vfs_file_t *file)
    128 {
     145static int vfs_file_delref(vfs_file_t *file)
     146{
     147        int rc = EOK;
     148
    129149        assert(fibril_mutex_is_locked(&VFS_DATA->lock));
    130150
    131151        if (file->refcnt-- == 1) {
    132152                /*
    133                  * Lost the last reference to a file, need to drop our reference
    134                  * to the underlying VFS node.
     153                 * Lost the last reference to a file, need to close it in the
     154                 * endpoint FS and drop our reference to the underlying VFS node.
    135155                 */
     156                rc = vfs_file_close_remote(file);
    136157                vfs_node_delref(file->node);
    137158                free(file);
    138159        }
     160
     161        return rc;
    139162}
    140163
     
    201224int vfs_fd_free(int fd)
    202225{
     226        int rc;
     227
    203228        if (!vfs_files_init())
    204229                return ENOMEM;
     
    210235        }
    211236       
    212         vfs_file_delref(FILES[fd]);
     237        rc = vfs_file_delref(FILES[fd]);
    213238        FILES[fd] = NULL;
    214239        fibril_mutex_unlock(&VFS_DATA->lock);
    215240       
    216         return EOK;
     241        return rc;
    217242}
    218243
Note: See TracChangeset for help on using the changeset viewer.