Changeset 852b801 in mainline for uspace/lib/libc/generic/vfs/vfs.c


Ignore:
Timestamp:
2009-06-28T18:59:02Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
75160a6
Parents:
4198f9c3
Message:

Introduce VFS_IN_FSTAT and VFS_OUT_STAT.
Provide libc fstat() and devfs_stat().
This functionality replaces VFS_IN_NODE
and VFS_IN/OUT_DEVICE. FAT and TMPFS
still do not implement this and VFS_IN_STAT
and stat() need implementation as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/vfs/vfs.c

    r4198f9c3 r852b801  
    3939#include <dirent.h>
    4040#include <fcntl.h>
     41#include <stdio.h>
    4142#include <sys/stat.h>
    42 #include <stdio.h>
    4343#include <sys/types.h>
    4444#include <ipc/ipc.h>
     
    315315}
    316316
    317 int fd_phone(int fildes)
    318 {
    319         futex_down(&vfs_phone_futex);
    320         async_serialize_start();
    321         vfs_connect();
    322        
    323         ipcarg_t device;
    324         ipcarg_t rc = async_req_1_1(vfs_phone, VFS_IN_DEVICE, fildes, &device);
    325        
    326         async_serialize_end();
    327         futex_up(&vfs_phone_futex);
    328        
    329         if (rc != EOK)
    330                 return -1;
    331        
    332         return devmap_device_connect((dev_handle_t) device, 0);
    333 }
    334 
    335 int fd_node(int fildes, fdi_node_t *node)
    336 {
    337         futex_down(&vfs_phone_futex);
    338         async_serialize_start();
    339         vfs_connect();
    340        
    341         ipcarg_t fs_handle;
    342         ipcarg_t dev_handle;
    343         ipcarg_t index;
    344         ipcarg_t rc = async_req_1_3(vfs_phone, VFS_IN_NODE, fildes, &fs_handle,
    345             &dev_handle, &index);
    346        
    347         async_serialize_end();
    348         futex_up(&vfs_phone_futex);
    349        
    350         if (rc == EOK) {
    351                 node->fs_handle = (fs_handle_t) fs_handle;
    352                 node->dev_handle = (dev_handle_t) dev_handle;
    353                 node->index = (fs_index_t) index;
    354         }
    355        
    356         return rc;
    357 }
    358 
    359317int fsync(int fildes)
    360318{
     
    404362        futex_up(&vfs_phone_futex);
    405363        return (int) rc;
     364}
     365
     366int fstat(int fildes, struct stat *stat)
     367{
     368        ipcarg_t rc;
     369        ipc_call_t answer;
     370        aid_t req;
     371
     372        futex_down(&vfs_phone_futex);
     373        async_serialize_start();
     374        vfs_connect();
     375       
     376        req = async_send_1(vfs_phone, VFS_IN_FSTAT, fildes, NULL);
     377        rc = ipc_data_read_start(vfs_phone, (void *)stat, sizeof(struct stat));
     378        if (rc != EOK) {
     379                async_wait_for(req, NULL);
     380                async_serialize_end();
     381                futex_up(&vfs_phone_futex);
     382                return (ssize_t) rc;
     383        }
     384        async_wait_for(req, &rc);
     385        async_serialize_end();
     386        futex_up(&vfs_phone_futex);
     387
     388        return rc;
    406389}
    407390
     
    599582}
    600583
     584int fd_phone(int fildes)
     585{
     586        struct stat stat;
     587        int rc;
     588
     589        rc = fstat(fildes, &stat);
     590
     591        if (!stat.devfs_stat.device)
     592                return -1;
     593       
     594        return devmap_device_connect(stat.devfs_stat.device, 0);
     595}
     596
     597int fd_node(int fildes, fdi_node_t *node)
     598{
     599        struct stat stat;
     600        int rc;
     601
     602        rc = fstat(fildes, &stat);
     603       
     604        if (rc == EOK) {
     605                node->fs_handle = stat.fs_handle;
     606                node->dev_handle = stat.dev_handle;
     607                node->index = stat.index;
     608        }
     609       
     610        return rc;
     611}
     612
    601613/** @}
    602614 */
Note: See TracChangeset for help on using the changeset viewer.