some coverity fixes.
[minix.git] / lib / libvboxfs / info.c
blob767744d71c0f0684213b852ee798b37fa8fc7904
1 /* Part of libvboxfs - (c) 2012, D.C. van Moolenbroek */
3 #include "inc.h"
5 /*
6 * Get or set file information.
7 */
8 int
9 vboxfs_getset_info(vboxfs_handle_t handle, u32_t flags, void *data,
10 size_t size)
12 vbox_param_t param[5];
14 vbox_set_u32(&param[0], vboxfs_root);
15 vbox_set_u64(&param[1], handle);
16 vbox_set_u32(&param[2], flags);
17 vbox_set_u32(&param[3], size);
18 vbox_set_ptr(&param[4], data, size, VBOX_DIR_INOUT);
20 return vbox_call(vboxfs_conn, VBOXFS_CALL_INFO, param, 5, NULL);
24 * Query volume information.
26 int
27 vboxfs_query_vol(char *path, vboxfs_volinfo_t *volinfo)
29 vboxfs_handle_t h;
30 int r;
32 if ((r = vboxfs_open_file(path, O_RDONLY, 0, &h, NULL)) != OK)
33 return r;
35 r = vboxfs_getset_info(h, VBOXFS_INFO_GET | VBOXFS_INFO_VOLUME,
36 volinfo, sizeof(*volinfo));
38 vboxfs_close_file(h);
40 return r;
44 * Query volume information.
46 int
47 vboxfs_queryvol(char *path, u64_t *free, u64_t *total)
49 vboxfs_volinfo_t volinfo;
50 int r;
52 if ((r = vboxfs_query_vol(path, &volinfo)) != OK)
53 return r;
55 *free = volinfo.free;
56 *total = volinfo.total;
57 return OK;