Changeset 222e57c in mainline for uspace/lib/libc


Ignore:
Timestamp:
2008-01-06T19:39:13Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
41a0d27
Parents:
10d6b858
Message:

Add libc and VFS implementation of lseek(), VFS_SEEK resp.
Add the size member to the VFS node structure (not yet initialized).

Location:
uspace/lib/libc
Files:
2 edited

Legend:

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

    r10d6b858 r222e57c  
    11/*
    2  * Copyright (c) 2007 Jakub Jermar
     2 * Copyright (c) 2008 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    185185        return (ssize_t) IPC_GET_ARG1(answer);
    186186}
     187
     188off_t lseek(int fildes, off_t offset, int whence)
     189{
     190        int res;
     191        ipcarg_t rc;
     192
     193        futex_down(&vfs_phone_futex);
     194        async_serialize_start();
     195        if (vfs_phone < 0) {
     196                res = vfs_connect();
     197                if (res < 0) {
     198                        async_serialize_end();
     199                        futex_up(&vfs_phone_futex);
     200                        return res;
     201                }
     202        }
     203               
     204        off_t newoffs;
     205        rc = async_req_3_1(vfs_phone, VFS_SEEK, fildes, offset, whence,
     206            &newoffs);
     207
     208        async_serialize_end();
     209        futex_up(&vfs_phone_futex);
     210
     211        if (rc != EOK)
     212                return (off_t) -1;
     213       
     214        return newoffs;
     215}
     216
    187217/** @}
    188218 */
  • uspace/lib/libc/include/unistd.h

    r10d6b858 r222e57c  
    4242#define getpagesize()     (PAGE_SIZE)
    4343
     44#define SEEK_SET        0
     45#define SEEK_CUR        1
     46#define SEEK_END        2
     47
    4448extern ssize_t write(int fd, const void * buf, size_t count);
    4549extern ssize_t read(int fd, void * buf, size_t count);
     50extern off_t lseek(int, off_t, int);
     51
    4652extern void _exit(int status);
    4753extern void *sbrk(ssize_t incr);
Note: See TracChangeset for help on using the changeset viewer.