testsh2.sh: change output to new cksum util
[minix.git] / test / safeperf / grantor.c
blob5f0e68cafb61acb008f99300f44f56fad171b4a7
1 #include "inc.h"
3 char buf_buf[BUF_SIZE + CLICK_SIZE];
5 int fid_send, fid_get;
7 /* SEF functions and variables. */
8 static void sef_local_startup(void);
10 /*===========================================================================*
11 * main *
12 *===========================================================================*/
13 int main(int argc, char **argv)
15 endpoint_t ep_self, ep_requestor, ep_child;
16 cp_grant_id_t gid;
17 int i, r, pid;
18 char *buf;
19 int status;
21 /* SEF local startup. */
22 env_setargs(argc, argv);
23 sef_local_startup();
25 /* Prepare work. */
26 buf = (char*) CLICK_CEIL(buf_buf);
27 fid_send = open(FIFO_GRANTOR, O_WRONLY);
28 fid_get = open(FIFO_REQUESTOR, O_RDONLY);
29 if(fid_get < 0 || fid_send < 0) {
30 printf("GRANTOR: can't open fifo files.\n");
31 return 1;
34 /* Get the requestor's endpoint. */
35 read(fid_get, &ep_requestor, sizeof(ep_requestor));
36 dprint("GRANTOR: getting requestor's endpoint: %d\n", ep_requestor);
38 /* Grant. */
39 gid = cpf_grant_direct(ep_requestor, (long)buf, BUF_SIZE,
40 CPF_READ | CPF_WRITE | CPF_MAP);
41 ep_self = getprocnr();
42 dprint("GRANTOR: sending my endpoint %d and gid %d\n", ep_self, gid);
43 write(fid_send, &ep_self, sizeof(ep_self));
44 write(fid_send, &gid, sizeof(gid));
46 /* Test safemap. */
47 buf[0] = 0;
48 FIFO_NOTIFY(fid_send);
49 FIFO_WAIT(fid_get);
51 return 0;
54 /*===========================================================================*
55 * sef_local_startup *
56 *===========================================================================*/
57 static void sef_local_startup()
59 /* Let SEF perform startup. */
60 sef_startup();