Changeset f17667a in mainline


Ignore:
Timestamp:
2008-02-17T13:32:53Z (16 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
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat.c

    rb5553a2 rf17667a  
    5252        .ops = {
    5353                [IPC_METHOD_TO_VFS_OP(VFS_LOOKUP)] = VFS_OP_DEFINED,
    54                 [IPC_METHOD_TO_VFS_OP(VFS_OPEN)] = VFS_OP_DEFINED,
    55                 [IPC_METHOD_TO_VFS_OP(VFS_CLOSE)] = VFS_OP_DEFINED,
    5654                [IPC_METHOD_TO_VFS_OP(VFS_READ)] = VFS_OP_DEFINED,
    5755                [IPC_METHOD_TO_VFS_OP(VFS_WRITE)] = VFS_OP_NULL,
    5856                [IPC_METHOD_TO_VFS_OP(VFS_TRUNCATE)] = VFS_OP_NULL,
    59                 [IPC_METHOD_TO_VFS_OP(VFS_RENAME)] = VFS_OP_NULL,
    60                 [IPC_METHOD_TO_VFS_OP(VFS_OPENDIR)] = VFS_OP_NULL,
    61                 [IPC_METHOD_TO_VFS_OP(VFS_READDIR)] = VFS_OP_NULL,
    62                 [IPC_METHOD_TO_VFS_OP(VFS_CLOSEDIR)] = VFS_OP_NULL,
    63                 [IPC_METHOD_TO_VFS_OP(VFS_UNLINK)] = VFS_OP_NULL,
    6457                [IPC_METHOD_TO_VFS_OP(VFS_MOUNT)] = VFS_OP_NULL,
    6558                [IPC_METHOD_TO_VFS_OP(VFS_UNMOUNT)] = VFS_OP_NULL,
  • uspace/srv/fs/tmpfs/tmpfs.c

    rb5553a2 rf17667a  
    5656        .ops = {
    5757                [IPC_METHOD_TO_VFS_OP(VFS_LOOKUP)] = VFS_OP_DEFINED,
    58                 [IPC_METHOD_TO_VFS_OP(VFS_OPEN)] = VFS_OP_DEFINED,
    59                 [IPC_METHOD_TO_VFS_OP(VFS_CLOSE)] = VFS_OP_DEFINED,
    6058                [IPC_METHOD_TO_VFS_OP(VFS_READ)] = VFS_OP_DEFINED,
    6159                [IPC_METHOD_TO_VFS_OP(VFS_WRITE)] = VFS_OP_DEFINED,
    62                 [IPC_METHOD_TO_VFS_OP(VFS_TRUNCATE)] = VFS_OP_NULL,
    63                 [IPC_METHOD_TO_VFS_OP(VFS_RENAME)] = VFS_OP_NULL,
    64                 [IPC_METHOD_TO_VFS_OP(VFS_OPENDIR)] = VFS_OP_NULL,
    65                 [IPC_METHOD_TO_VFS_OP(VFS_READDIR)] = VFS_OP_NULL,
    66                 [IPC_METHOD_TO_VFS_OP(VFS_CLOSEDIR)] = VFS_OP_NULL,
    67                 [IPC_METHOD_TO_VFS_OP(VFS_UNLINK)] = VFS_OP_NULL,
     60                [IPC_METHOD_TO_VFS_OP(VFS_TRUNCATE)] = VFS_OP_DEFINED,
    6861                [IPC_METHOD_TO_VFS_OP(VFS_MOUNT)] = VFS_OP_NULL,
    6962                [IPC_METHOD_TO_VFS_OP(VFS_UNMOUNT)] = VFS_OP_NULL,
     63                [IPC_METHOD_TO_VFS_OP(VFS_FREE)] = VFS_OP_DEFINED,
    7064        }
    7165};
     
    119113                        tmpfs_write(callid, &call);
    120114                        break;
     115                case VFS_TRUNCATE:
     116                        tmpfs_truncate(callid, &call);
     117                        break;
     118                case VFS_FREE:
     119                        tmpfs_free(callid, &call);
     120                        break;
    121121                default:
    122122                        ipc_answer_0(callid, ENOTSUP);
  • uspace/srv/fs/tmpfs/tmpfs.h

    rb5553a2 rf17667a  
    6565extern void tmpfs_write(ipc_callid_t, ipc_call_t *);
    6666extern void tmpfs_truncate(ipc_callid_t, ipc_call_t *);
     67extern void tmpfs_free(ipc_callid_t, ipc_call_t *);
    6768
    6869#endif
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    rb5553a2 rf17667a  
    497497}
    498498
     499void tmpfs_free(ipc_callid_t rid, ipc_call_t *request)
     500{
     501        int dev_handle = IPC_GET_ARG1(*request);
     502        unsigned long index = IPC_GET_ARG2(*request);
     503
     504        link_t *hlp;
     505        hlp = hash_table_find(&dentries, &index);
     506        if (!hlp) {
     507                ipc_answer_0(rid, ENOENT);
     508                return;
     509        }
     510        tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t,
     511            dh_link);
     512       
     513        assert(!dentry->parent);
     514        assert(!dentry->child);
     515        assert(!dentry->sibling);
     516
     517        if (dentry->type == TMPFS_FILE)
     518                free(dentry->data);
     519        free(dentry->name);
     520        free(dentry);
     521
     522        ipc_answer_0(rid, EOK);
     523}
     524
    499525/**
    500526 * @}
  • 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.