aboutsummaryrefslogtreecommitdiffstats
path: root/com32/gpllib/disk/swsusp.c
blob: ef782fd5f506a8610789dfc05279d5cc069edba3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdlib.h>
#include <string.h>

#include <disk/swsusp.h>
#include <disk/read.h>
#include <disk/geom.h>

/**
 * swsusp_check - check if a (swap) partition contains the swsusp signature
 * @drive_info:	driveinfo struct describing the disk containing the partition
 * @ptab;	Partition table of the partition
 **/
int swsusp_check(struct driveinfo *drive_info, struct part_entry *ptab)
{
    struct swsusp_header header_p;
    int offset;
    int found;

    /* Read first page of the swap device */
    offset = ptab->start_lba;
    if (read_sectors(drive_info, &header_p, offset, PAGE_SIZE / SECTOR) == -1) {
	return -1;
    } else {
	found = !memcmp(SWSUSP_SIG, header_p.sig, 10);
	return found;
    }
}