Supported by libMapRClient for hadoop-0.20.2 and hadoop-2.x

Set the working directory. All relative paths will be resolved relative to it.

For example, if you call this API to set the working directory to /mycluster/myvolume and subsequently call hdfsOpenFile() with the path /temp/tmp.txt, the full path to the file to open is assumed to be /mycluster/myvolume/temp/tmp.txt.


int hdfsSetWorkingDirectory(hdfsFS fs, const char* path)



The handle of the filesystem where the directory is located. Obtain this handle with one of the hdfsConnect() APIs.


The path of the new working directory.

Return Value

Returns 0 on success, -1 on error.

Check errno for error codes and meanings.

errno is set to EINVAL for invalid arguments.