ia64/xen-unstable

changeset 817:18051e617fea

bitkeeper revision 1.501.1.2 (3f87baa7GCRi_yatMEUW36MM6ZAyEQ)

xen_refresh_dev.c:
new file
author kaf24@scramble.cl.cam.ac.uk
date Sat Oct 11 08:09:11 2003 +0000 (2003-10-11)
parents d94d0518b17a
children d5e8cbd474a3
files .rootkeys extras/mini-os/Makefile tools/misc/xen_refresh_dev.c
line diff
     1.1 --- a/.rootkeys	Sat Oct 11 08:05:28 2003 +0000
     1.2 +++ b/.rootkeys	Sat Oct 11 08:09:11 2003 +0000
     1.3 @@ -184,6 +184,7 @@ 3f1668d4-FUY6Enc7MB3GcwUtfJ5HA tools/mis
     1.4  3f13d81eQ9Vz-h-6RDGFkNR9CRP95g tools/misc/xen_nat_enable
     1.5  3f13d81e6Z6806ihYYUw8GVKNkYnuw tools/misc/xen_nat_enable.README
     1.6  3f1668d4F29Jsw0aC0bJEIkOBiagiQ tools/misc/xen_read_console.c
     1.7 +3f87ba90EUVPQLVOlFG0sW89BCwouQ tools/misc/xen_refresh_dev.c
     1.8  3f72f1bdJPsV3JCnBqs9ddL9tr6D2g xen/COPYING
     1.9  3f841450eJvqAD1Dldc0_aOweGiglQ xen/GUEST_CHANGES
    1.10  3ddb79bcbOVHh38VJzc97-JEGD4dJQ xen/Makefile
     2.1 --- a/extras/mini-os/Makefile	Sat Oct 11 08:05:28 2003 +0000
     2.2 +++ b/extras/mini-os/Makefile	Sat Oct 11 08:09:11 2003 +0000
     2.3 @@ -35,6 +35,7 @@ hypervisor-ifs:
     2.4  clean:
     2.5  	find . -type f -name '*.o' | xargs rm -f
     2.6  	rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
     2.7 +	find . -type l | xargs rm -f
     2.8  
     2.9  %.o: %.c $(HDRS) Makefile
    2.10  	$(CC) $(CFLAGS) -c $< -o $@
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/misc/xen_refresh_dev.c	Sat Oct 11 08:09:11 2003 +0000
     3.3 @@ -0,0 +1,49 @@
     3.4 +/******************************************************************************
     3.5 + * xen_refresh_dev.c
     3.6 + * 
     3.7 + * Refresh our view of a block device by rereading its partition table. This 
     3.8 + * is necessary to synchronise with VBD attaches and unattaches in Xen. 
     3.9 + * Currently there's no automatic plumbing of attach/unattach requests.
    3.10 + * 
    3.11 + * Copyright (c) 2003, K A Fraser
    3.12 + */
    3.13 +
    3.14 +#include <stdio.h>
    3.15 +#include <stdlib.h>
    3.16 +#include <sys/ioctl.h>
    3.17 +#include <sys/stat.h>
    3.18 +#include <sys/types.h>
    3.19 +#include <fcntl.h>
    3.20 +#include <string.h>
    3.21 +#include <errno.h>
    3.22 +#include <unistd.h>
    3.23 +#include <sys/mount.h> /* BLKRRPART */
    3.24 +
    3.25 +int main(int argc, char **argv)
    3.26 +{
    3.27 +    int fd;
    3.28 +
    3.29 +    if ( argc != 2 )
    3.30 +    {
    3.31 +        fprintf(stderr, "xen_refresh_dev <blkdev>\ne.g., /dev/xvda\n");
    3.32 +        return 1;
    3.33 +    }
    3.34 +
    3.35 +    if ( (fd = open(argv[1], O_RDWR)) == -1 )
    3.36 +    {
    3.37 +        fprintf(stderr, "Error opening %s: %s (%d)\n",
    3.38 +                argv[1], strerror(errno), errno);
    3.39 +        return 1;
    3.40 +    }
    3.41 +
    3.42 +    if ( ioctl(fd, BLKRRPART) == -1 )
    3.43 +    {
    3.44 +        fprintf(stderr, "Error executing BLKRRPART on %s: %s (%d)\n",
    3.45 +                argv[1], strerror(errno), errno);
    3.46 +        return 1;
    3.47 +    }
    3.48 +
    3.49 +    close(fd);
    3.50 +
    3.51 +    return 0;
    3.52 +}