ia64/xen-unstable

view tools/internal/xi_phys_probe.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 11b14ed1bf78
children b912fe2f29ba 49232d5003e6
line source
1 #include <stdio.h>
2 #include <sys/fcntl.h>
3 #include <errno.h>
4 #include <unistd.h>
5 #include <string.h>
7 #include "physdev.h"
9 int main(int argc, char *argv[])
10 {
11 physdisk_probebuf_t buf;
12 int fd;
13 int x;
14 char *strbuf;
16 if (argc != 2) {
17 fprintf(stderr, "Usage: xi_phys_probe <domain_nr>\n");
18 return 1;
19 }
21 asprintf(&strbuf, "/proc/xeno/dom%s/phd", argv[1]);
22 fd = open(strbuf, O_RDONLY);
23 if (fd < 0) {
24 fprintf(stderr, "Can\'t open %s: %s.\n", strbuf, strerror(errno));
25 return 1;
26 }
27 free(strbuf);
29 memset(&buf, 0, sizeof(buf));
30 buf.n_aces = PHYSDISK_MAX_ACES_PER_REQUEST;
31 do {
32 buf.n_aces = PHYSDISK_MAX_ACES_PER_REQUEST;
33 read(fd, &buf, sizeof(buf));
34 if (!buf.n_aces)
35 break;
37 for (x = 0; x < buf.n_aces; x++) {
38 char read = ( buf.entries[x].mode & 1 ? 'r' : ' ' );
39 char write = ( buf.entries[x].mode & 2 ? 'w' : ' ' );
40 printf("%x %x %x %c%c\n", buf.entries[x].device,
41 buf.entries[x].start_sect,
42 buf.entries[x].n_sectors,
43 read,
44 write);
45 }
46 buf.start_ind += buf.n_aces;
47 } while (buf.n_aces == PHYSDISK_MAX_ACES_PER_REQUEST);
48 return 0;
49 }