Changeset 449c246 in mainline for uspace/lib/libc/generic/vfs.c


Ignore:
Timestamp:
2007-12-30T21:32:31Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
badbd888
Parents:
92688eb
Message:

Add libc VFS wrapper for VFS_WRITE. Fix a small bug in read(). Place open(),
read() and write() declarations in their respective headers according to SUSv3.

File:
1 edited

Legend:

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

    r92688eb r449c246  
    3434 
    3535#include <vfs.h>
     36#include <unistd.h>
     37#include <fcntl.h>
    3638#include <ipc/ipc.h>
    3739#include <ipc/services.h>
     
    141143                }
    142144        }
    143         req = async_send_1(vfs_phone, VFS_READ, 0, &answer);
     145        req = async_send_1(vfs_phone, VFS_READ, fildes, &answer);
    144146        if (ipc_data_read_send(vfs_phone, buf, sizeof(buf)) != EOK) {
    145147                async_wait_for(req, NULL);
     
    154156}
    155157
     158ssize_t write(int fildes, const void *buf, size_t nbyte)
     159{
     160        int res;
     161        ipcarg_t rc;
     162        ipc_call_t answer;
     163        aid_t req;
     164
     165        futex_down(&vfs_phone_futex);
     166        async_serialize_start();
     167        if (vfs_phone < 0) {
     168                res = vfs_connect();
     169                if (res < 0) {
     170                        async_serialize_end();
     171                        futex_up(&vfs_phone_futex);
     172                        return res;
     173                }
     174        }
     175        req = async_send_1(vfs_phone, VFS_WRITE, fildes, &answer);
     176        if (ipc_data_write_send(vfs_phone, buf, sizeof(buf)) != EOK) {
     177                async_wait_for(req, NULL);
     178                async_serialize_end();
     179                futex_up(&vfs_phone_futex);
     180                return (ssize_t) rc;
     181        }
     182        async_wait_for(req, &rc);
     183        async_serialize_end();
     184        futex_up(&vfs_phone_futex);
     185        return (ssize_t) IPC_GET_ARG1(answer);
     186}
    156187/** @}
    157188 */
Note: See TracChangeset for help on using the changeset viewer.