Changeset f17667a in mainline for uspace/srv/vfs


Ignore:
Timestamp:
2008-02-17T13:32:53Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2616965d
Parents:
b5553a2
Message:

Add the VFS_FREE operation. This operation frees up whatever resources used by
a file system node for which there is no name (i.e. an unlinked node).

Cleanup VFS operations enums and remove unneeded VFS operations.

Location:
uspace/srv/vfs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs.h

    rb5553a2 rf17667a  
    4848
    4949typedef enum {
    50         VFS_OPEN = VFS_FIRST,
    51         VFS_CLOSE,
    52         VFS_READ,
     50        VFS_READ = VFS_FIRST,
    5351        VFS_WRITE,
    5452        VFS_TRUNCATE,
    55         VFS_RENAME,
    56         VFS_OPENDIR,
    57         VFS_READDIR,
    58         VFS_CLOSEDIR,
    59         VFS_MKDIR,
    60         VFS_UNLINK,
    6153        VFS_MOUNT,
    6254        VFS_UNMOUNT,
     
    6658typedef enum {
    6759        VFS_LOOKUP = VFS_LAST_CMN,
     60        VFS_FREE,
    6861        VFS_LAST_CLNT,  /* keep this the last member of this enum */
    6962} vfs_request_clnt_t;
     
    7164typedef enum {
    7265        VFS_REGISTER = VFS_LAST_CMN,
     66        VFS_OPEN,
     67        VFS_CLOSE,
    7368        VFS_SEEK,
     69        VFS_MKDIR,
     70        VFS_UNLINK,
     71        VFS_RENAME,
    7472        VFS_LAST_SRV,   /* keep this the last member of this enum */
    7573} vfs_request_srv_t;
  • uspace/srv/vfs/vfs_file.c

    rb5553a2 rf17667a  
    131131        if (file->refcnt-- == 1) {
    132132                /*
    133                  * Lost last reference to a file, need to drop our reference
     133                 * Lost the last reference to a file, need to drop our reference
    134134                 * to the underlying VFS node.
    135135                 */
  • uspace/srv/vfs/vfs_node.c

    rb5553a2 rf17667a  
    4444#include <libadt/hash_table.h>
    4545#include <assert.h>
     46#include <async.h>
     47#include <errno.h>
    4648
    4749/** Futex protecting the VFS node hash table. */
     
    102104void vfs_node_delref(vfs_node_t *node)
    103105{
     106        bool free_vfs_node = false;
     107        bool free_fs_node = false;
     108
    104109        futex_down(&nodes_futex);
    105110        if (node->refcnt-- == 1) {
     111                /*
     112                 * We are dropping the last reference to this node.
     113                 * Remove it from the VFS node hash table.
     114                 */
    106115                unsigned long key[] = {
    107116                        [KEY_FS_HANDLE] = node->fs_handle,
     
    110119                };
    111120                hash_table_remove(&nodes, key, 3);
     121                free_vfs_node = true;
     122                if (!node->lnkcnt)
     123                        free_fs_node = true;
    112124        }
    113125        futex_up(&nodes_futex);
     126
     127        if (free_fs_node) {
     128                /*
     129                 * The node is not visible in the file system namespace.
     130                 * Free up its resources.
     131                 */
     132                int phone = vfs_grab_phone(node->fs_handle);
     133                ipcarg_t rc;
     134                rc = async_req_2_0(phone, VFS_FREE, (ipcarg_t)node->dev_handle,
     135                    (ipcarg_t)node->index);
     136                assert(rc == EOK);
     137                vfs_release_phone(phone);
     138        }
     139        if (free_vfs_node)
     140                free(node);
    114141}
    115142
     
    197224void nodes_remove_callback(link_t *item)
    198225{
    199         vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link);
    200         free(node);
    201226}
    202227
  • uspace/srv/vfs/vfs_register.c

    rb5553a2 rf17667a  
    105105        if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_LOOKUP)] != VFS_OP_DEFINED) {
    106106                dprintf("Operation VFS_LOOKUP not defined by the client.\n");
    107                 return false;
    108         }
    109         if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_OPEN)] != VFS_OP_DEFINED) {
    110                 dprintf("Operation VFS_OPEN not defined by the client.\n");
    111                 return false;
    112         }
    113         if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_CLOSE)] != VFS_OP_DEFINED) {
    114                 dprintf("Operation VFS_CLOSE not defined by the client.\n");
    115107                return false;
    116108        }
Note: See TracChangeset for help on using the changeset viewer.