def read_fakeroot_state(statefile):
    """
    Reads fakeroot state file, key by inode.

    fakeroot state file has the following structure:
        dev=fd03,ino=136887,mode=100600,uid=0,gid=0,nlink=1,rdev=0
        dev=fd02,ino=3932193,mode=100600,uid=0,gid=0,nlink=1,rdev=0

    Read all fields by line into a dictionary, and keep this
    dictionary keyed by inode number.
    """
    entry_by_inode = {}
    for line in open(statefile, "r").readlines():
        d = {}
        for item in line[:-1].split(","):
            k, v = item.split("=")
            d[k] = v
        entry_by_inode[int(d["ino"])] = d
    return entry_by_inode