1#include <stdlib.h>
2#include <string.h>
3
4#include <disk/swsusp.h>
5#include <disk/read.h>
6#include <disk/geom.h>
7
8/**
9 * swsusp_check - check if a (swap) partition contains the swsusp signature
10 * @drive_info:	driveinfo struct describing the disk containing the partition
11 * @ptab;	Partition table of the partition
12 **/
13int swsusp_check(struct driveinfo *drive_info, struct part_entry *ptab)
14{
15    struct swsusp_header header_p;
16    int offset;
17    int found;
18
19    /* Read first page of the swap device */
20    offset = ptab->start_lba;
21    if (read_sectors(drive_info, &header_p, offset, PAGE_SIZE / SECTOR) == -1) {
22	return -1;
23    } else {
24	found = !memcmp(SWSUSP_SIG, header_p.sig, 10);
25	return found;
26    }
27}
28