import stat


def get_flags(path, cpath, lstat):
    """Get flags for the file."""
    mode = list("....")
    if stat.S_ISDIR(lstat.st_mode):
        mode[0] = "D"
    elif stat.S_ISLNK(lstat.st_mode):
        mode[0] = "L"
    elif stat.S_ISREG(lstat.st_mode):
        mode[0] = "F"

    if mode[0] == ".":
        print(f"Invalide mode for {path}, skipping")
        return None

    if cpath.startswith("/usr/lib/kernel/") or cpath.startswith("/usr/lib/modules"):
        mode[2] = "b"

    return ''.join(mode)