blob: e09c6930469f82c7ea994b688864279dee986569 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* Part of libhgfs - (c) 2009, D.C. van Moolenbroek */
#include "inc.h"
/*===========================================================================*
* hgfs_opendir *
*===========================================================================*/
int hgfs_opendir(const char *path, sffs_dir_t *handle)
{
/* Open a directory. Store a directory handle upon success.
*/
int r;
RPC_REQUEST(HGFS_REQ_OPENDIR);
path_put(path);
if ((r = rpc_query()) != OK)
return r;
*handle = (sffs_dir_t)RPC_NEXT32;
return OK;
}
/*===========================================================================*
* hgfs_readdir *
*===========================================================================*/
int hgfs_readdir(sffs_dir_t handle, unsigned int index, char *buf,
size_t size, struct sffs_attr *attr)
{
/* Read a directory entry from an open directory, using a zero-based index
* number. Upon success, the resulting path name is stored in the given buffer
* and the given attribute structure is filled selectively as requested. Upon
* error, the contents of the path buffer and attribute structure are
* undefined. ENOENT is returned upon end of directory.
*/
int r;
RPC_REQUEST(HGFS_REQ_READDIR);
RPC_NEXT32 = (u32_t)handle;
RPC_NEXT32 = index;
/* EINVAL signifies end of directory. */
if ((r = rpc_query()) != OK)
return (r == EINVAL) ? ENOENT : OK;
attr_get(attr);
if ((r = path_get(buf, size)) != OK)
return r;
/* VMware Player 3 returns an empty name, instead of EINVAL, when reading
* from an EOF position right after opening the directory handle. Seems to be
* a newly introduced bug..
*/
return (!buf[0]) ? ENOENT : OK;
}
/*===========================================================================*
* hgfs_closedir *
*===========================================================================*/
int hgfs_closedir(sffs_dir_t handle)
{
/* Close an open directory.
*/
RPC_REQUEST(HGFS_REQ_CLOSEDIR);
RPC_NEXT32 = (u32_t)handle;
return rpc_query();
}
|