source: trunk/packages/xen-3.1/xen-3.1/tools/xenstore/xenstored_linux.c @ 34

Last change on this file since 34 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

File size: 1.3 KB
Line 
1/******************************************************************************
2 *
3 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
4 * Use is subject to license terms.
5 *
6 * Copyright (C) 2005 Rusty Russell IBM Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation, version 2 of the
11 * License.
12 */
13
14#include <fcntl.h>
15#include <unistd.h>
16#include <stdlib.h>
17#include <sys/mman.h>
18
19#include "xenstored_core.h"
20
21#define XENSTORED_PROC_KVA  "/proc/xen/xsd_kva"
22#define XENSTORED_PROC_PORT "/proc/xen/xsd_port"
23
24evtchn_port_t xenbus_evtchn(void)
25{
26        int fd;
27        int rc;
28        evtchn_port_t port; 
29        char str[20]; 
30
31        fd = open(XENSTORED_PROC_PORT, O_RDONLY); 
32        if (fd == -1)
33                return -1;
34
35        rc = read(fd, str, sizeof(str)); 
36        if (rc == -1)
37        {
38                int err = errno;
39                close(fd);
40                errno = err;
41                return -1;
42        }
43
44        str[rc] = '\0'; 
45        port = strtoul(str, NULL, 0); 
46
47        close(fd); 
48        return port;
49}
50
51void *xenbus_map(void)
52{
53        int fd;
54        void *addr;
55
56        fd = open(XENSTORED_PROC_KVA, O_RDWR);
57        if (fd == -1)
58                return NULL;
59
60        addr = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE,
61                MAP_SHARED, fd, 0);
62
63        if (addr == MAP_FAILED)
64                addr = NULL;
65
66        close(fd);
67
68        return addr;
69}
70
71void xenbus_notify_running(void)
72{
73}
Note: See TracBrowser for help on using the repository browser.