]> git.ipfire.org Git - ipfire-2.x.git/blame_incremental - src/installer/hw.h
dracut: Remove biosdevname module
[ipfire-2.x.git] / src / installer / hw.h
... / ...
CommitLineData
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
26#define DESTINATION_MOUNT_PATH "/harddisk"
27#define SOURCE_MOUNT_PATH "/cdrom"
28#define SOURCE_TEST_FILE SOURCE_MOUNT_PATH "/" VERSION ".media"
29
30#define HW_MAX_DISKS 32
31#define STRING_SIZE 1024
32#define DEV_SIZE 128
33
34#define HW_PATH_BOOT "/boot"
35#define HW_PATH_DATA "/var"
36
37#define HW_PART_TYPE_NORMAL 0
38#define HW_PART_TYPE_RAID1 1
39
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#define HW_FS_XFS 4
48
49#define HW_FS_DEFAULT HW_FS_EXT4
50
51#define RAID_METADATA "1.0"
52
53#define BYTES2MB(x) ((x) / 1024 / 1024)
54#define MB2BYTES(x) ((unsigned long long)(x) * 1024 * 1024)
55
56struct hw {
57 struct udev *udev;
58};
59
60struct hw_disk {
61 char path[DEV_SIZE];
62 unsigned long long size;
63
64 char description[STRING_SIZE];
65 char vendor[STRING_SIZE];
66 char model[STRING_SIZE];
67
68 // Reference counter
69 int ref;
70};
71
72struct hw_destination {
73 char path[DEV_SIZE];
74
75 int is_raid;
76 int raid_level;
77 const struct hw_disk* disk1;
78 const struct hw_disk* disk2;
79
80 int part_table;
81 char part_bootldr[DEV_SIZE];
82 char part_boot[DEV_SIZE];
83 char part_swap[DEV_SIZE];
84 char part_root[DEV_SIZE];
85 char part_data[DEV_SIZE];
86 int part_boot_idx;
87
88 int filesystem;
89
90 unsigned long long size;
91 unsigned long long size_bootldr;
92 unsigned long long size_boot;
93 unsigned long long size_swap;
94 unsigned long long size_root;
95 unsigned long long size_data;
96};
97
98struct hw* hw_init();
99void hw_free(struct hw* hw);
100
101int hw_mount(const char* source, const char* target, const char* fs, int flags);
102int hw_umount(const char* target);
103
104char* hw_find_source_medium(struct hw* hw);
105
106struct hw_disk** hw_find_disks(struct hw* hw);
107void hw_free_disks(struct hw_disk** disks);
108unsigned int hw_count_disks(struct hw_disk** disks);
109struct hw_disk** hw_select_disks(struct hw_disk** disks, int* selection);
110
111struct hw_destination* hw_make_destination(int part_type, struct hw_disk** disks);
112
113unsigned long long hw_memory();
114
115int hw_create_partitions(struct hw_destination* dest, const char* output);
116int hw_create_filesystems(struct hw_destination* dest, const char* output);
117
118int hw_mount_filesystems(struct hw_destination* dest, const char* prefix);
119int hw_umount_filesystems(struct hw_destination* dest, const char* prefix);
120
121int hw_setup_raid(struct hw_destination* dest, const char* output);
122int hw_stop_all_raid_arrays(const char* output);
123
124int hw_install_bootloader(struct hw_destination* dest, const char* output);
125int hw_write_fstab(struct hw_destination* dest);
126
127void hw_sync();
128
129#endif /* HEADER_HW_H */