OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [libposix/] [close.c] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * l4/posix glue for close() and fsync()
3
 *
4
 * Copyright (C) 2007 Bahadir Balban
5
 */
6
#include <errno.h>
7
#include <stdio.h>
8
#include <unistd.h>
9
#include <l4lib/ipcdefs.h>
10
#include <l4lib/utcb.h>
11
#include <l4/macros.h>
12
#include INC_GLUE(memory.h)
13
#include <libposix.h>
14
 
15
static inline int l4_close(int fd)
16
{
17
        write_mr(L4SYS_ARG0, fd);
18
 
19
        /* Call pager with close() request. Check ipc error. */
20
        if ((fd = l4_sendrecv(pagerid, pagerid, L4_IPC_TAG_CLOSE)) < 0) {
21
                print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd);
22
                return fd;
23
        }
24
        /* Check if syscall itself was successful */
25
        if ((fd = l4_get_retval()) < 0) {
26
                print_err("%s: CLOSE Error: %d.\n", __FUNCTION__, fd);
27
                return fd;
28
        }
29
        return fd;
30
}
31
 
32
int close(int fd)
33
{
34
        int ret = l4_close(fd);
35
 
36
        /* If error, return positive error code */
37
        if (ret < 0) {
38
                errno = -ret;
39
                return -1;
40
        }
41
 
42
        /* else return value */
43
        return ret;
44
}
45
 
46
static inline int l4_fsync(int fd)
47
{
48
        write_mr(L4SYS_ARG0, fd);
49
 
50
        /* Call pager with close() request. Check ipc error. */
51
        if ((fd = l4_sendrecv(pagerid, pagerid, L4_IPC_TAG_FSYNC)) < 0) {
52
                print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd);
53
                return fd;
54
        }
55
        /* Check if syscall itself was successful */
56
        if ((fd = l4_get_retval()) < 0) {
57
                print_err("%s: CLOSE Error: %d.\n", __FUNCTION__, fd);
58
                return fd;
59
        }
60
        return fd;
61
}
62
 
63
int fsync(int fd)
64
{
65
        int ret = l4_fsync(fd);
66
 
67
        /* If error, return positive error code */
68
        if (ret < 0) {
69
                errno = -ret;
70
                return -1;
71
        }
72
 
73
        /* else return value */
74
        return ret;
75
}
76
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.