]>
Commit | Line | Data |
---|---|---|
f0fa1795 MT |
1 | /*############################################################################# |
2 | # # | |
3 | # IPFire - An Open Source Firewall Distribution # | |
4 | # Copyright (C) 2014 IPFire development team # | |
5 | # # | |
6 | # This program is free software: you can redistribute it and/or modify # | |
7 | # it under the terms of the GNU General Public License as published by # | |
8 | # the Free Software Foundation, either version 3 of the License, or # | |
9 | # (at your option) any later version. # | |
10 | # # | |
11 | # This program is distributed in the hope that it will be useful, # | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
14 | # GNU General Public License for more details. # | |
15 | # # | |
16 | # You should have received a copy of the GNU General Public License # | |
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
18 | # # | |
19 | #############################################################################*/ | |
20 | ||
21 | #ifndef HEADER_HW_H | |
22 | #define HEADER_HW_H | |
23 | ||
24 | #include <libudev.h> | |
25 | ||
25fcce25 | 26 | #define DESTINATION_MOUNT_PATH "/harddisk" |
f0fa1795 MT |
27 | #define SOURCE_MOUNT_PATH "/cdrom" |
28 | #define SOURCE_TEST_FILE SOURCE_MOUNT_PATH "/" VERSION ".media" | |
29 | ||
d7dd283b MT |
30 | #define HW_MAX_DISKS 32 |
31 | #define STRING_SIZE 1024 | |
32 | #define DEV_SIZE 128 | |
33 | ||
25fcce25 MT |
34 | #define HW_PATH_BOOT "/boot" |
35 | #define HW_PATH_DATA "/var" | |
36 | ||
d7dd283b MT |
37 | #define HW_PART_TYPE_NORMAL 0 |
38 | #define HW_PART_TYPE_RAID1 1 | |
39 | ||
25fcce25 MT |
40 | #define HW_PART_TABLE_MSDOS 0 |
41 | #define HW_PART_TABLE_GPT 1 | |
42 | ||
43 | #define HW_FS_SWAP 0 | |
44 | #define HW_FS_REISERFS 1 | |
45 | #define HW_FS_EXT4 2 | |
46 | #define HW_FS_EXT4_WO_JOURNAL 3 | |
47 | ||
48 | #define HW_FS_DEFAULT HW_FS_EXT4 | |
49 | ||
50 | #define BYTES2MB(x) ((x) / 1024 / 1024) | |
51 | #define MB2BYTES(x) ((unsigned long long)(x) * 1024 * 1024) | |
52 | ||
f0fa1795 MT |
53 | struct hw { |
54 | struct udev *udev; | |
55 | }; | |
56 | ||
d7dd283b MT |
57 | struct hw_disk { |
58 | char path[DEV_SIZE]; | |
59 | unsigned long long size; | |
60 | ||
61 | char description[STRING_SIZE]; | |
62 | char vendor[STRING_SIZE]; | |
63 | char model[STRING_SIZE]; | |
64 | ||
65 | // Reference counter | |
66 | int ref; | |
67 | }; | |
68 | ||
69 | struct hw_destination { | |
70 | char path[DEV_SIZE]; | |
d7dd283b MT |
71 | |
72 | int is_raid; | |
d7dd283b MT |
73 | const struct hw_disk* disk1; |
74 | const struct hw_disk* disk2; | |
75 | ||
25fcce25 | 76 | int part_table; |
d7dd283b MT |
77 | char part_boot[DEV_SIZE]; |
78 | char part_swap[DEV_SIZE]; | |
79 | char part_root[DEV_SIZE]; | |
80 | char part_data[DEV_SIZE]; | |
25fcce25 MT |
81 | int part_boot_idx; |
82 | ||
83 | int filesystem; | |
84 | ||
85 | unsigned long long size; | |
86 | unsigned long long size_boot; | |
87 | unsigned long long size_swap; | |
88 | unsigned long long size_root; | |
89 | unsigned long long size_data; | |
d7dd283b MT |
90 | }; |
91 | ||
f0fa1795 MT |
92 | struct hw* hw_init(); |
93 | void hw_free(struct hw* hw); | |
94 | ||
25fcce25 | 95 | int hw_mount(const char* source, const char* target, const char* fs, int flags); |
f0fa1795 MT |
96 | int hw_umount(const char* target); |
97 | ||
98 | char* hw_find_source_medium(struct hw* hw); | |
99 | ||
d7dd283b MT |
100 | struct hw_disk** hw_find_disks(struct hw* hw); |
101 | void hw_free_disks(struct hw_disk** disks); | |
102 | unsigned int hw_count_disks(struct hw_disk** disks); | |
103 | struct hw_disk** hw_select_disks(struct hw_disk** disks, int* selection); | |
104 | ||
25fcce25 MT |
105 | struct hw_destination* hw_make_destination(int part_type, struct hw_disk** disks); |
106 | ||
c4e96674 MT |
107 | unsigned long long hw_memory(); |
108 | ||
25fcce25 MT |
109 | int hw_create_partitions(struct hw_destination* dest); |
110 | int hw_create_filesystems(struct hw_destination* dest); | |
111 | ||
112 | int hw_mount_filesystems(struct hw_destination* dest, const char* prefix); | |
113 | int hw_umount_filesystems(struct hw_destination* dest, const char* prefix); | |
114 | ||
f0fa1795 | 115 | #endif /* HEADER_HW_H */ |