1 /* Part of libhgfs - (c) 2009, D.C. van Moolenbroek */
5 char rpc_buf
[RPC_BUF_SIZE
];
8 static struct channel rpc_chan
;
10 /*===========================================================================*
12 *===========================================================================*/
15 /* Open a HGFS RPC backdoor channel to the VMware host, and make sure that it
16 * is working. Return OK upon success, or a negative error code otherwise; in
17 * particular, return EAGAIN if shared folders are disabled.
21 if ((r
= channel_open(&rpc_chan
, CH_OUT
)) != OK
)
27 channel_close(&rpc_chan
);
32 /*===========================================================================*
34 *===========================================================================*/
37 /* Send a HGFS RPC query over the backdoor channel. Return OK upon success, or
38 * a negative error code otherwise; EAGAIN is returned if shared folders are
39 * disabled. In general, we make the assumption that the sender (= VMware)
40 * speaks the protocol correctly. Hence, the callers of this function do not
47 /* A more robust version of this call could reopen the channel and
48 * retry the request upon low-level failure.
50 r
= channel_send(&rpc_chan
, rpc_buf
, len
);
53 r
= channel_recv(&rpc_chan
, rpc_buf
, sizeof(rpc_buf
));
55 if (r
< 2 || (len
> 2 && r
< 10)) return EIO
;
59 if (RPC_NEXT8
!= '1') return EAGAIN
;
60 if (RPC_NEXT8
!= ' ') return EAGAIN
;
62 if (len
<= 2) return OK
;
67 return error_convert(err
);
70 /*===========================================================================*
72 *===========================================================================*/
75 /* Test whether HGFS communication is working. Return OK on success, EAGAIN if
76 * shared folders are disabled, or another negative error code upon error.
86 /*===========================================================================*
88 *===========================================================================*/
91 /* Close the HGFS RPC backdoor channel.
94 channel_close(&rpc_chan
);