Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListDirectory errors when listing local paths #4

Closed
wangkuiyi opened this issue Oct 17, 2012 · 3 comments
Closed

ListDirectory errors when listing local paths #4

wangkuiyi opened this issue Oct 17, 2012 · 3 comments

Comments

@wangkuiyi
Copy link

I encountered a problem: it seems that hdfs.ListDirectory cannot list files on local filesystem.

The following program works when it connects to an HDFS, but failed with "no such file or directory" error when it connects to the local filesystem:

package main

import (
"fmt"
"github.com/zyxar/hdfs"
)

func main() {
// fs, _ := hdfs.Connect("localhost", 9000)
fs, _ := hdfs.Connect("", 0)
fi, _ := fs.GetPathInfo("/") // Work with both HDFS and local filesystem.
fmt.Println(fi)
fis, _ := fs.ListDirectory("/") // Work with only HDFS but not local filesystem.
fmt.Println(fis)
}

I then checked my build of libhdfs by running the following C program. It works with both HDFS and local filesystem:

include "hdfs.h"

int main() {
// hdfsFS fs = hdfsConnect("localhost", 9000);
hdfsFS fs = hdfsConnectAsUser(NULL, 0, NULL);

int numEntries = 0;
hdfsFileInfo* files = hdfsListDirectory(fs, "/", &numEntries);
for (int i = 0; i < numEntries; ++i) {
printf("%s\n", files[i].mName);
}
hdfsFreeFileInfo(files, numEntries);
return hdfsDisconnect(fs);
}

I cannot find any clue in hdfs.go.

zyxar added a commit that referenced this issue Oct 17, 2012
    ListDirectory errors when listing local paths: do not depend on `errno' ever.
@wangkuiyi
Copy link
Author

Got the diff. Thanks.

It seems that libhdfs sets errno by mistake?

@zyxar
Copy link
Owner

zyxar commented Oct 18, 2012

maybe cgo, or libhdfs. There are a lot similar cases in impl-ing hdfs.go, especially in accessing local file systems.

@wangkuiyi
Copy link
Author

It looks like this issue can be closed?

@zyxar zyxar closed this as completed Dec 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants