2010-01-26 00:18:02 +01:00
|
|
|
/* Part of libhgfs - (c) 2009, D.C. van Moolenbroek */
|
|
|
|
|
|
|
|
#include "inc.h"
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* hgfs_init *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int hgfs_init()
|
2010-01-26 00:18:02 +01:00
|
|
|
{
|
|
|
|
/* Initialize the library. Return OK on success, or a negative error code
|
|
|
|
* otherwise. If EAGAIN is returned, shared folders are disabled; in that
|
|
|
|
* case, other operations may be tried (and possibly succeed).
|
|
|
|
*/
|
|
|
|
|
|
|
|
time_init();
|
|
|
|
|
|
|
|
return rpc_open();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* hgfs_cleanup *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void hgfs_cleanup()
|
2010-01-26 00:18:02 +01:00
|
|
|
{
|
|
|
|
/* Clean up state.
|
|
|
|
*/
|
|
|
|
|
|
|
|
rpc_close();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* hgfs_enabled *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int hgfs_enabled()
|
2010-01-26 00:18:02 +01:00
|
|
|
{
|
|
|
|
/* Check if shared folders are enabled. Return OK if so, EAGAIN if not, and
|
|
|
|
* another negative error code on error.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return rpc_test();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* hgfs_queryvol *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int hgfs_queryvol(path, free, total)
|
2010-01-26 00:18:02 +01:00
|
|
|
char *path;
|
|
|
|
u64_t *free;
|
|
|
|
u64_t *total;
|
|
|
|
{
|
|
|
|
/* Retrieve information about available and total volume space associated with
|
|
|
|
* a given path.
|
|
|
|
*/
|
|
|
|
u32_t lo, hi;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
RPC_REQUEST(HGFS_REQ_QUERYVOL);
|
|
|
|
|
|
|
|
path_put(path);
|
|
|
|
|
|
|
|
if ((r = rpc_query()) != OK)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
lo = RPC_NEXT32;
|
|
|
|
hi = RPC_NEXT32;
|
|
|
|
*free = make64(lo, hi);
|
|
|
|
|
|
|
|
lo = RPC_NEXT32;
|
|
|
|
hi = RPC_NEXT32;
|
|
|
|
*total = make64(lo, hi);
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|