1 /* Part of libhgfs - (c) 2009, D.C. van Moolenbroek */
5 /*===========================================================================*
7 *===========================================================================*/
8 int hgfs_opendir(path
, handle
)
12 /* Open a directory. Store a directory handle upon success.
16 RPC_REQUEST(HGFS_REQ_OPENDIR
);
20 if ((r
= rpc_query()) != OK
)
23 *handle
= (sffs_dir_t
)RPC_NEXT32
;
28 /*===========================================================================*
30 *===========================================================================*/
31 int hgfs_readdir(handle
, index
, buf
, size
, attr
)
36 struct sffs_attr
*attr
;
38 /* Read a directory entry from an open directory, using a zero-based index
39 * number. Upon success, the resulting path name is stored in the given buffer
40 * and the given attribute structure is filled selectively as requested. Upon
41 * error, the contents of the path buffer and attribute structure are
42 * undefined. ENOENT is returned upon end of directory.
46 RPC_REQUEST(HGFS_REQ_READDIR
);
47 RPC_NEXT32
= (u32_t
)handle
;
50 /* EINVAL signifies end of directory. */
51 if ((r
= rpc_query()) != OK
)
52 return (r
== EINVAL
) ? ENOENT
: OK
;
56 if ((r
= path_get(buf
, size
)) != OK
)
59 /* VMware Player 3 returns an empty name, instead of EINVAL, when reading
60 * from an EOF position right after opening the directory handle. Seems to be
61 * a newly introduced bug..
63 return (!buf
[0]) ? ENOENT
: OK
;
66 /*===========================================================================*
68 *===========================================================================*/
69 int hgfs_closedir(handle
)
72 /* Close an open directory.
75 RPC_REQUEST(HGFS_REQ_CLOSEDIR
);
76 RPC_NEXT32
= (u32_t
)handle
;