summaryrefslogtreecommitdiffstats
path: root/src/hdaccess.h
blob: f1431b03f137e4674acef018265207ccf1189eea (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*

    File: hdaccess.h

    Copyright (C) 1998-2009 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 _HDACCESS_H
#define _HDACCESS_H
#ifdef __cplusplus
extern "C" {
#endif
/*@
  @ requires \valid(disk_car);
  @ requires disk_car->sector_size > 0;
  @ requires disk_car->geom.heads_per_cylinder > 0;
  @ requires \valid_function(disk_car->pread);
  @*/
void hd_update_geometry(disk_t *disk_car, const int verbose);

/*@
  @ requires list_disk==\null || \valid_read(list_disk);
  @*/
void hd_update_all_geometry(const list_disk_t * list_disk, const int verbose);

/*@
  @ requires list_disk==\null || \valid_read(list_disk);
  @ ensures \result==\null || \valid_read(\result);
  @*/
list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const int testdisk_mode);

/*@
  @ requires valid_read_string(device);
  @ ensures \result==\null || \valid(\result);
  @ ensures \result!=\null ==> (0 < \result->geom.cylinders < 0x2000000000000);
  @ ensures \result!=\null ==> (0 < \result->geom.heads_per_cylinder <= 255);
  @ ensures \result!=\null ==> (0 < \result->geom.sectors_per_head <= 63);
  @ ensures \result!=\null ==> valid_read_string(\result->device);
  @ ensures \result!=\null ==> \freeable(\result);
  @ ensures \result!=\null ==> (\result->device == \null || \freeable(\result->device));
  @ ensures \result!=\null ==> (\result->model == \null || \freeable(\result->model));
  @ ensures \result!=\null ==> (\result->serial_no == \null || \freeable(\result->serial_no));
  @ ensures \result!=\null ==> (\result->fw_rev == \null || \freeable(\result->fw_rev));
  @ ensures \result!=\null ==> (\result->data == \null || \freeable(\result->data));
  @ ensures \result!=\null ==> (\result->rbuffer == \null || \freeable(\result->rbuffer));
  @ ensures \result!=\null ==> (\result->wbuffer == \null || \freeable(\result->wbuffer));
  @*/
disk_t *file_test_availability(const char *device, const int verbose, const int testdisk_mode);

/*@
  @ requires \valid(disk_car);
  @ requires 0 < disk_car->geom.heads_per_cylinder;
  @ requires 0 < disk_car->geom.sectors_per_head;
  @ requires 0 < disk_car->sector_size;
  @ ensures 0 < disk_car->geom.cylinders < 0x2000000000000;
  @*/
void update_disk_car_fields(disk_t *disk_car);

/*@
  @ requires \valid(disk);
  @ ensures disk->autodetect == 0;
  @ ensures disk->disk_size == 0;
  @ ensures disk->user_max == 0;
  @ ensures disk->native_max == 0;
  @ ensures disk->dco == 0;
  @ ensures disk->offset == 0;
  @ ensures disk->rbuffer == NULL;
  @ ensures disk->wbuffer == NULL;
  @ ensures disk->rbuffer_size == 0;
  @ ensures disk->wbuffer_size == 0;
  @ ensures disk->model == NULL;
  @ ensures disk->serial_no == NULL;
  @ ensures disk->fw_rev == NULL;
  @ ensures disk->write_used == 0;
  @ ensures disk->description_txt[0] == '\0';
  @ ensures disk->unit == UNIT_CHS;
  @ assigns disk->autodetect, disk->disk_size, disk->user_max, disk->native_max, disk->dco, disk->offset;
  @ assigns disk->rbuffer, disk->wbuffer, disk->rbuffer_size, disk->wbuffer_size;
  @ assigns disk->model, disk->serial_no, disk->fw_rev, disk->write_used;
  @ assigns disk->description_txt[0], disk->unit;
  @*/
void init_disk(disk_t *disk);

/*@
  @ requires \valid(disk);
  @ requires \freeable(disk);
  @ requires disk->device == \null || \freeable(disk->device);
  @ requires disk->model == \null || \freeable(disk->model);
  @ requires disk->serial_no == \null || \freeable(disk->serial_no);
  @ requires disk->fw_rev == \null || \freeable(disk->fw_rev);
  @ requires disk->data == \null || \freeable(disk->data);
  @ requires disk->rbuffer == \null || \freeable(disk->rbuffer);
  @ requires disk->wbuffer == \null || \freeable(disk->wbuffer);
  @*/
void generic_clean(disk_t *disk);

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