/* Checks whether FCB sector contains data or not. Returns <0 in error. Returns 0 if sector is unused; Returns 1 if sector has data.  */
int fcb_sector_hdr_read(struct fcb *fcb, struct flash_sector *sector, struct fcb_disk_area *fdap)
/* Checks whether FCB sector contains data or not. Returns <0 in error. Returns 0 if sector is unused; Returns 1 if sector has data.  */
int fcb_sector_hdr_read(struct fcb *fcb, struct flash_sector *sector, struct fcb_disk_area *fdap)
{
	struct fcb_disk_area fda;
	int rc;
	if (!fdap) {
		fdap = &fda;
	}
	rc = fcb_flash_read(fcb, sector, 0, fdap, sizeof(*fdap));
	if (rc) {
		return -EIO;
	}
	if (fdap->fd_magic == MK32(fcb->f_erase_value)) {
		return 0;
	}
	if (fdap->fd_magic != fcb_flash_magic(fcb)) {
		return -ENOMSG;
	}
	return 1;
}