ia64/xen-unstable

view tools/internal/xi_phys_grant.c @ 522:07cb518caf2f

bitkeeper revision 1.289 (3f09877bT-kkJTOM1WvHevpN2wY-qw)

Prune old code
author rac61@labyrinth.cl.cam.ac.uk
date Mon Jul 07 14:45:15 2003 +0000 (2003-07-07)
parents f47cba6ba7af
children b912fe2f29ba 49232d5003e6
line source
1 #include <unistd.h>
2 #include <stdio.h>
3 #include <errno.h>
4 #include <sys/fcntl.h>
6 #include "physdev.h"
8 int main(int argc, char *argv[])
9 {
10 xp_disk_t buf;
11 int fd;
12 char *strbuf;
14 if (argc != 7) {
15 fprintf(stderr, "Usage: xi_physdev_grant <r/rw> <domain> <device> <start sector> <n_sectors> <partition>\n");
16 return 1;
17 }
19 buf.mode = 0;
20 if (argv[1][0] == 'r')
21 buf.mode |= 1;
22 else if (argv[1][0] == 'w')
23 buf.mode |= 2;
24 if (argv[1][1] == 'r')
25 buf.mode |= 1;
26 else if (argv[1][1] == 'w')
27 buf.mode |= 2;
29 buf.device = atol(argv[3]) + atol(argv[6]);
30 buf.start_sect = atol(argv[4]);
31 buf.n_sectors = atol(argv[5]);
33 asprintf(&strbuf, "/proc/xeno/dom%s/phd", argv[2]);
34 fd = open(strbuf, O_WRONLY);
35 if (fd < 0) {
36 fprintf(stderr, "Can\'t open %s: %s.\n", strbuf, strerror(errno));
37 return 1;
38 }
39 free(strbuf);
41 write(fd, &buf, sizeof(buf));
42 close(fd);
44 return 0;
45 }