1 /* Part of libvboxfs - (c) 2012, D.C. van Moolenbroek */
5 vbox_conn_t vboxfs_conn
;
6 vboxfs_root_t vboxfs_root
;
8 static struct sffs_table vboxfs_table
= {
10 .t_read
= vboxfs_read
,
11 .t_write
= vboxfs_write
,
12 .t_close
= vboxfs_close
,
14 .t_readbuf
= vboxfs_buffer
,
15 .t_writebuf
= vboxfs_buffer
,
17 .t_opendir
= vboxfs_opendir
,
18 .t_readdir
= vboxfs_readdir
,
19 .t_closedir
= vboxfs_closedir
,
21 .t_getattr
= vboxfs_getattr
,
22 .t_setattr
= vboxfs_setattr
,
24 .t_mkdir
= vboxfs_mkdir
,
25 .t_unlink
= vboxfs_unlink
,
26 .t_rmdir
= vboxfs_rmdir
,
27 .t_rename
= vboxfs_rename
,
29 .t_queryvol
= vboxfs_queryvol
33 * Initialize communication with the VBOX driver, and map the given share.
36 vboxfs_init(char *share
, const struct sffs_table
**tablep
, int *case_insens
,
39 vbox_param_t param
[4];
41 vboxfs_volinfo_t volinfo
;
44 if ((r
= vboxfs_set_path(&path
, share
)) != OK
)
47 if ((r
= vbox_init()) != OK
)
50 if ((vboxfs_conn
= r
= vbox_open("VBoxSharedFolders")) < 0)
53 r
= vbox_call(vboxfs_conn
, VBOXFS_CALL_SET_UTF8
, NULL
, 0, NULL
);
55 vbox_close(vboxfs_conn
);
60 vbox_set_ptr(¶m
[0], &path
, vboxfs_get_path_size(&path
),
62 vbox_set_u32(¶m
[1], 0);
63 vbox_set_u32(¶m
[2], '/'); /* path separator */
64 vbox_set_u32(¶m
[3], TRUE
); /* case sensitivity - no effect? */
66 r
= vbox_call(vboxfs_conn
, VBOXFS_CALL_MAP_FOLDER
, param
, 4, NULL
);
68 vbox_close(vboxfs_conn
);
73 vboxfs_root
= vbox_get_u32(¶m
[1]);
75 /* Gather extra information about the mapped shared. */
76 if (vboxfs_query_vol("", &volinfo
) == OK
) {
77 *case_insens
= !volinfo
.props
.casesens
;
78 *read_only
= !!volinfo
.props
.readonly
;
81 *tablep
= &vboxfs_table
;
86 * Unmap the share, and disconnect from the VBOX driver.
91 vbox_param_t param
[1];
93 vbox_set_u32(¶m
[0], vboxfs_root
);
95 vbox_call(vboxfs_conn
, VBOXFS_CALL_UNMAP_FOLDER
, param
, 1, NULL
);
97 vbox_close(vboxfs_conn
);