C编程-将Dirent d_name传递给opendir

I have this block of code, that should iterate over the whole filesystem. I start from / and work my way down from there.

DIR *dir = opendir("/");
linklist(dir, 1000);

void linklist (DIR *dir, long int foo) {
    struct dirent *dp;
    while ((dp = readdir(dir)) != NULL) {

        if (dp->d_type == DT_DIR) {

            DIR *new_dir = opendir(dp->d_name);

            if (new_dir != NULL) {
                linklist(new_dir, foo);
            }
        }
    }
}

It succesfully reads the / directory, but can't open any directory from there (all return NULL when trying to opendir).

任何帮助将非常感激。