ia64/xen-unstable

changeset 641:f635998b684b

bitkeeper revision 1.359 (3f1668d45SYPQy-7cLNFlIKxyY1X8w)

add mkdevnodes and read_console_udp to tools/misc
author iap10@labyrinth.cl.cam.ac.uk
date Thu Jul 17 09:13:56 2003 +0000 (2003-07-17)
parents 1e118e51c91f
children e09b8abaa2e3
files .rootkeys tools/misc/mkdevnodes tools/misc/read_console_udp.c
line diff
     1.1 --- a/.rootkeys	Wed Jul 16 12:45:05 2003 +0000
     1.2 +++ b/.rootkeys	Thu Jul 17 09:13:56 2003 +0000
     1.3 @@ -140,6 +140,8 @@ 3f108ae2to5nHRRXfvUK7oxgjcW_yA tools/int
     1.4  3eb781fd7211MZsLxJSiuy7W4KnJXg tools/internal/xi_vifinit
     1.5  3f13d81eQ9Vz-h-6RDGFkNR9CRP95g tools/misc/enable_nat
     1.6  3f13d81e6Z6806ihYYUw8GVKNkYnuw tools/misc/enable_nat.README
     1.7 +3f1668d4-FUY6Enc7MB3GcwUtfJ5HA tools/misc/mkdevnodes
     1.8 +3f1668d4F29Jsw0aC0bJEIkOBiagiQ tools/misc/read_console_udp.c
     1.9  3ddb79bcbOVHh38VJzc97-JEGD4dJQ xen/Makefile
    1.10  3ddb79bcCa2VbsMp7mWKlhgwLQUQGA xen/README
    1.11  3ddb79bcWnTwYsQRWl_PaneJfa6p0w xen/Rules.mk
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/misc/mkdevnodes	Thu Jul 17 09:13:56 2003 +0000
     2.3 @@ -0,0 +1,21 @@
     2.4 +#! /bin/bash
     2.5 +
     2.6 +BASE=${1:?"base directory missing (eg. /dev)"}
     2.7 +
     2.8 +rm -f ${BASE}/xhd[abcdefghijklmnop]*
     2.9 +rm -f ${BASE}/xsd[abcdefghijklmnop]*
    2.10 +rm -f ${BASE}/xvd[abcdefghijklmnop]*
    2.11 +
    2.12 +# XLVIRT is 16 devices of 15 partitions
    2.13 +
    2.14 +LETTERS="a b c d e f g h i j k l m n o p"
    2.15 +PARTITIONS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
    2.16 +
    2.17 +j=0
    2.18 +for l in ${LETTERS}; do
    2.19 +    mknod ${BASE}/xvd${l} b 125 ${j}
    2.20 +    for i in ${PARTITIONS}; do
    2.21 +        mknod ${BASE}/xvd${l}${i} b 125 $(($i+$j))
    2.22 +    done
    2.23 +    j=$(($j+16))
    2.24 +done
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/misc/read_console_udp.c	Thu Jul 17 09:13:56 2003 +0000
     3.3 @@ -0,0 +1,53 @@
     3.4 +/******************************************************************************
     3.5 + * Test program for reading console lines from DOM0 port 666.
     3.6 + */
     3.7 +
     3.8 +#include <arpa/inet.h>
     3.9 +#include <sys/types.h>
    3.10 +#include <sys/socket.h>
    3.11 +#include <stdio.h>
    3.12 +#include <stdlib.h>
    3.13 +#include <string.h>
    3.14 +
    3.15 +int main(void)
    3.16 +{
    3.17 +    unsigned char buf[208], abuf[32];
    3.18 +    struct sockaddr_in addr, from;
    3.19 +    int fromlen = sizeof(from);
    3.20 +    int len, fd = socket(PF_INET, SOCK_DGRAM, 0);
    3.21 +    
    3.22 +    if ( fd < 0 )
    3.23 +    {
    3.24 +        fprintf(stderr, "could not open datagram socket\n");
    3.25 +        return -1;
    3.26 +    }
    3.27 +
    3.28 +    memset(&addr, 0, sizeof(addr));
    3.29 +    addr.sin_addr.s_addr = htonl(0xa9fe0100); /* 169.254.1.0 */
    3.30 +    addr.sin_port = htons(666);
    3.31 +    addr.sin_family = AF_INET;
    3.32 +    if ( bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0 )
    3.33 +    {
    3.34 +        fprintf(stderr, "could not bind to local address and port\n");
    3.35 +        return -1;
    3.36 +    }
    3.37 +
    3.38 +    while ( (len = recvfrom(fd, buf, sizeof(buf), 0, 
    3.39 +                            (struct sockaddr *)&from, &fromlen)) 
    3.40 +            >= 0 )
    3.41 +    {
    3.42 +        printf("%d-byte message from %s:%d --\n", len,
    3.43 +               inet_ntop(AF_INET, &from.sin_addr, abuf, sizeof(abuf)),
    3.44 +               ntohs(from.sin_port));
    3.45 +
    3.46 +        /* For sanity, clean up the string's tail. */
    3.47 +        if ( buf[len-1] != '\n' ) { buf[len] = '\n'; len++; }
    3.48 +        buf[len] = '\0';
    3.49 +
    3.50 +        printf("%s", buf);
    3.51 +
    3.52 +        fromlen = sizeof(from);
    3.53 +    }
    3.54 +
    3.55 +    return 0;
    3.56 +}