code: function resolveOwnership (uid: number, gid: number, stat: Stat): number {
    if (uid === stat.uid) {
      return (stat.mode & constants.S_IRWXU) >> 6;
    } else if (gid === stat.gid) {
      return (stat.mode & constants.S_IRWXG) >> 3;
    } else {
      return stat.mode & constants.S_IRWXO;
    }
  }
docs: Permission checking relies on ownership details of the iNode.
  If the accessing user is the same as the iNode user, then only user permissions are used.
  If the accessing group is the same as the iNode group, then only the group permissions are used.
  Otherwise the other permissions are used.