summaryrefslogtreecommitdiffstats
path: root/src/swap.h
blob: a2b5809b711f57db0c996fbeb09fedd52ecaacd2 (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
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*

    file: swap.h

    Copyright (C) 1998-2004,2006,2008 Christophe GRENIER <grenier@cgsecurity.org>
  
    this software is free software; you can redistribute it and/or modify
    it under the terms of the gnu general public license as published by
    the free software foundation; either version 2 of the license, or
    (at your option) any later version.
  
    this program is distributed in the hope that it will be useful,
    but without any warranty; without even the implied warranty of
    merchantability or fitness for a particular purpose.  see the
    gnu general public license for more details.
  
    You should have received a copy of the GNU General Public License along
    with this program; if not, write the Free Software Foundation, Inc., 51
    Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

 */

#ifndef _SWAP_H
#define _SWAP_H
#ifdef __cplusplus
extern "C" {
#endif

#define PAGE_SIZE 0x1000        /* 4k page */
#define PAGE_8K	  0x2000        /* 8K page */

union swap_header {
  struct
  {
	char reserved[PAGE_SIZE - 10];
	char magic[10];
  } magic;
  struct
  {
	char         bootbits[1024];    /* Space for disklabel etc. */
	unsigned int version;
	unsigned int last_page;
	unsigned int nr_badpages;
/*	char volume_name[16]; */
	unsigned int padding[125];
	unsigned int badpages[1];
  } info;
  struct
  {
	char reserved[PAGE_8K- 10];
	char magic[10];
  } magic8k;
};

/*@
  @ requires \valid(disk_car);
  @ requires \valid(partition);
  @ requires separation: \separated(disk_car, partition);
  @ decreases 0;
  @*/
int check_Linux_SWAP(disk_t *disk_car, partition_t *partition);

/*@
  @ requires \valid_read(swap_header);
  @ requires \valid(partition);
  @ requires separation: \separated(swap_header, partition);
  @*/
int recover_Linux_SWAP(const union swap_header *swap_header, partition_t *partition);

#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif
#endif