def extractDirInfo(dirname):
    """
    Extracts the metadata recursivly form all the subdirs/files

    :param dirname: the top directory
    :returns: the list of metadata tuples: name, size, link, st_mode, st_nlink
    """
    from os import walk, lstat
    from os.path import join, islink
    metadata = []
    for root, _dirs, files in walk(dirname):
        for f in files:
            n = join(root, f)
            sr = lstat(n)
            ret = (n.replace(dirname, ''), sr.st_size, islink(n), sr.
                st_mode, sr.st_nlink),
            metadata.append(ret)
    return sorted(metadata)
