XINU
rfsndmsg.c
Go to the documentation of this file.
1 /* rfsndmsg.c - rfsndmsg */
2 
3 #include <xinu.h>
4 
5 /*------------------------------------------------------------------------
6  * rfsndmsg - Create and send a message that only has header fields
7  *------------------------------------------------------------------------
8  */
10  uint16 type, /* Message type */
11  char *name /* Null-terminated file name */
12  )
13 {
14  struct rf_msg_hdr req; /* Request message to send */
15  struct rf_msg_hdr resp; /* Buffer for response */
16  int32 retval; /* Return value */
17  char *to; /* Used during name copy */
18 
19  /* Form a request */
20 
21  req.rf_type = htons(type);
22  req.rf_status = htons(0);
23  req.rf_seq = 0; /* Rfscomm will set sequence */
24  to = req.rf_name;
25  while ( (*to++ = *name++) ) { /* Copy name to request */
26  ;
27  }
28 
29  /* Send message and receive response */
30 
31  retval = rfscomm(&req, sizeof(struct rf_msg_hdr),
32  &resp, sizeof(struct rf_msg_hdr) );
33 
34  /* Check response */
35 
36  if (retval == SYSERR) {
37  return SYSERR;
38  } else if (retval == TIMEOUT) {
39  kprintf("Timeout during remote file server access\n");
40  return SYSERR;
41  } else if (ntohl(resp.rf_status) != 0) {
42  return SYSERR;
43  }
44 
45  return OK;
46 }
syscall kprintf(char *fmt,...)
ポーリングI/Oを使用して、フォーマットされた文字列をコンソールに出力する。
Definition: kprintf.c:98
全てのシステムヘッダファイルをインクルードする。
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
status rfsndmsg(uint16 type, char *name)
Definition: rfsndmsg.c:9
#define OK
処理が成功した場合
Definition: kernel.h:77
int32 rfscomm(struct rf_msg_hdr *, int32, struct rf_msg_hdr *, int32)
Definition: rfscomm.c:10
#define TIMEOUT
システムコールがタイムアウトした場合
Definition: kernel.h:83
int32 status
ステータスを意味する返り値の型(OK/SYSERR)
Definition: kernel.h:57
#define ntohl(x)
Definition: prototypes.h:623
int int32
符号あり32ビット整数(int)
Definition: kernel.h:11
unsigned short uint16
符号なし16ビット整数(unsigned short)
Definition: kernel.h:17
#define htons(x)
Definition: prototypes.h:619