-
Notifications
You must be signed in to change notification settings - Fork 0
/
img-fsck.c
55 lines (46 loc) · 1018 Bytes
/
img-fsck.c
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Copyright (c) 2012-2016 Bromium Inc.
* All rights reserved
* Author: Jacob Gorm Hansen
*
* Sanity-check contents of .swap disk.
*/
#include <assert.h>
#include <err.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "block.h"
#include "block-swap.h"
#include "aio.h"
#include "ioh.h"
int main(int argc, char **argv)
{
#ifdef _WIN32
setprogname(argv[0]);
#endif
BlockDriverState bs;
//int r;
if (argc != 2) {
fprintf(stderr, "usage: %s <dst.swap>\n",
argv[0]);
exit(-1);
}
aio_global_init();
const char *dst = argv[1];
int r;
r = swap_open(&bs, dst, 0);
if (r < 0) {
fprintf(stderr, "%s: unable to open %s\n", argv[0], dst);
}
r = swap_ioctl(&bs, 2, NULL);
if (r < 0) {
fprintf(stderr, "%s: unable to fsck %s\n", argv[0], dst);
}
if (r == 0) {
fprintf(stderr, "fsck completed.\n");
}
swap_close(&bs);
return r;
}