]>
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" |
fb76fc51 MT |
27 | #define SOURCE_MOUNT_PATH "/cdrom" |
28 | #define SOURCE_TEST_FILE SOURCE_MOUNT_PATH "/" DISTRO_SNAME "-" DISTRO_VERSION ".media" | |
f0fa1795 | 29 | |
d7dd283b MT |
30 | #define HW_MAX_DISKS 32 |
31 | #define STRING_SIZE 1024 | |
32 | #define DEV_SIZE 128 | |
33 | ||
25fcce25 | 34 | #define HW_PATH_BOOT "/boot" |
92e78233 | 35 | #define HW_PATH_BOOT_EFI "/boot/efi" |
25fcce25 MT |
36 | #define HW_PATH_DATA "/var" |
37 | ||
d7dd283b MT |
38 | #define HW_PART_TYPE_NORMAL 0 |
39 | #define HW_PART_TYPE_RAID1 1 | |
40 | ||
25fcce25 MT |
41 | #define HW_PART_TABLE_MSDOS 0 |
42 | #define HW_PART_TABLE_GPT 1 | |
43 | ||
44 | #define HW_FS_SWAP 0 | |
e2617fc0 MT |
45 | #define HW_FS_EXT4 1 |
46 | #define HW_FS_EXT4_WO_JOURNAL 2 | |
47 | #define HW_FS_XFS 3 | |
48 | #define HW_FS_FAT32 4 | |
25fcce25 MT |
49 | |
50 | #define HW_FS_DEFAULT HW_FS_EXT4 | |
51 | ||
7b4790d3 MT |
52 | #define RAID_METADATA "1.0" |
53 | ||
9dd16c6d MT |
54 | #define SERIAL_BAUDRATE 115200 |
55 | ||
25fcce25 MT |
56 | #define BYTES2MB(x) ((x) / 1024 / 1024) |
57 | #define MB2BYTES(x) ((unsigned long long)(x) * 1024 * 1024) | |
58 | ||
f0fa1795 MT |
59 | struct hw { |
60 | struct udev *udev; | |
92e78233 | 61 | char arch[STRING_SIZE]; |
8fbadfc7 MT |
62 | |
63 | // Enabled if we should install in EFI mode | |
5fb499f1 | 64 | int efi; |
f0fa1795 MT |
65 | }; |
66 | ||
d7dd283b MT |
67 | struct hw_disk { |
68 | char path[DEV_SIZE]; | |
69 | unsigned long long size; | |
70 | ||
71 | char description[STRING_SIZE]; | |
72 | char vendor[STRING_SIZE]; | |
73 | char model[STRING_SIZE]; | |
74 | ||
75 | // Reference counter | |
76 | int ref; | |
77 | }; | |
78 | ||
79 | struct hw_destination { | |
80 | char path[DEV_SIZE]; | |
d7dd283b MT |
81 | |
82 | int is_raid; | |
4a0d9bef | 83 | int raid_level; |
d7dd283b MT |
84 | const struct hw_disk* disk1; |
85 | const struct hw_disk* disk2; | |
86 | ||
25fcce25 | 87 | int part_table; |
48d6a112 | 88 | char part_bootldr[DEV_SIZE]; |
d7dd283b | 89 | char part_boot[DEV_SIZE]; |
92e78233 | 90 | char part_boot_efi[DEV_SIZE]; |
d7dd283b MT |
91 | char part_swap[DEV_SIZE]; |
92 | char part_root[DEV_SIZE]; | |
25fcce25 | 93 | int part_boot_idx; |
92e78233 | 94 | int part_boot_efi_idx; |
25fcce25 MT |
95 | |
96 | int filesystem; | |
97 | ||
98 | unsigned long long size; | |
48d6a112 | 99 | unsigned long long size_bootldr; |
25fcce25 | 100 | unsigned long long size_boot; |
92e78233 | 101 | unsigned long long size_boot_efi; |
25fcce25 MT |
102 | unsigned long long size_swap; |
103 | unsigned long long size_root; | |
d7dd283b MT |
104 | }; |
105 | ||
f0fa1795 MT |
106 | struct hw* hw_init(); |
107 | void hw_free(struct hw* hw); | |
108 | ||
25fcce25 | 109 | int hw_mount(const char* source, const char* target, const char* fs, int flags); |
ced15fdf | 110 | int hw_umount(const char* source, const char* prefix); |
f0fa1795 MT |
111 | |
112 | char* hw_find_source_medium(struct hw* hw); | |
113 | ||
ee00d203 | 114 | struct hw_disk** hw_find_disks(struct hw* hw, const char* sourcedrive); |
d7dd283b | 115 | void hw_free_disks(struct hw_disk** disks); |
335c5bd1 | 116 | unsigned int hw_count_disks(const struct hw_disk** disks); |
d7dd283b | 117 | struct hw_disk** hw_select_disks(struct hw_disk** disks, int* selection); |
a3e135c8 | 118 | struct hw_disk** hw_select_first_disk(const struct hw_disk** disks); |
d7dd283b | 119 | |
92e78233 | 120 | struct hw_destination* hw_make_destination(struct hw* hw, int part_type, struct hw_disk** disks, |
a8fca245 | 121 | int disable_swap); |
25fcce25 | 122 | |
c4e96674 MT |
123 | unsigned long long hw_memory(); |
124 | ||
46b56e20 MT |
125 | int hw_create_partitions(struct hw_destination* dest, const char* output); |
126 | int hw_create_filesystems(struct hw_destination* dest, const char* output); | |
25fcce25 MT |
127 | |
128 | int hw_mount_filesystems(struct hw_destination* dest, const char* prefix); | |
129 | int hw_umount_filesystems(struct hw_destination* dest, const char* prefix); | |
130 | ||
d78fffa0 | 131 | int hw_destroy_raid_superblocks(const struct hw_destination* dest, const char* output); |
46b56e20 MT |
132 | int hw_setup_raid(struct hw_destination* dest, const char* output); |
133 | int hw_stop_all_raid_arrays(const char* output); | |
4a0d9bef | 134 | |
92e78233 | 135 | int hw_install_bootloader(struct hw* hw, struct hw_destination* dest, const char* output); |
7f69d8a4 | 136 | int hw_write_fstab(struct hw_destination* dest); |
f5007e9c | 137 | |
38c6822d MT |
138 | char* hw_find_backup_file(const char* output, const char* search_path); |
139 | int hw_restore_backup(const char* output, const char* backup_path, const char* destination); | |
140 | ||
335c5bd1 MT |
141 | int hw_start_networking(const char* output); |
142 | ||
282ec35e MT |
143 | void hw_sync(); |
144 | ||
f0fa1795 | 145 | #endif /* HEADER_HW_H */ |