/* Finds the fcb entry that gives back upto n entries at the end.  */
int fcb_offset_last_n(struct fcb *fcb, uint8_t entries, struct fcb_entry *last_n_entry)
/* Finds the fcb entry that gives back upto n entries at the end.  */
int fcb_offset_last_n(struct fcb *fcb, uint8_t entries, struct fcb_entry *last_n_entry)
{
	struct fcb_entry loc;
	int i;
	int rc;
	if (!entries) {
		entries = 1U;
	}
	i = 0;
	(void)memset(&loc, 0, sizeof(loc));
	while (!fcb_getnext(fcb, &loc)) {
		if (i == 0) {
			*last_n_entry = loc;
		}
		else if (i > (entries - 1)) {
			rc = fcb_getnext(fcb, last_n_entry);
			if (rc) {
				return -ENOENT;
			}
		}
		i++;
	}
	return (i == 0) ? -ENOENT : 0;
}