forked from chris-se/tiny-initramfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tiny_initramfs.h
135 lines (107 loc) · 3.75 KB
/
tiny_initramfs.h
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* tiny_initramfs - Minimalistic initramfs implementation
* Copyright (C) 2016 Christian Seiler <[email protected]>
*
* tiny_initramfs.h: function declarations
*
* This program 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef TINY_INITRAMFS_H
#define TINY_INITRAMFS_H
#include <sys/types.h>
#include <fcntl.h>
#include <config.h>
#ifndef MAX_LINE_LEN
#define MAX_LINE_LEN 4096
#endif
#ifndef MAX_PATH_LEN
#define MAX_PATH_LEN 1024
#endif
#ifndef MAX_ROOT_MOUNTS
#define MAX_ROOT_MOUNTS 32
#endif
#ifndef MODULES_FILE
#define MODULES_FILE "/modules"
#endif
#ifndef TARGET_DIRECTORY
#define TARGET_DIRECTORY "/target"
#endif
#ifndef FSTAB_FILENAME
#define FSTAB_FILENAME "/etc/fstab"
#endif
#ifndef PROC_FILESYSTEMS_FILENAME
#define PROC_FILESYSTEMS_FILENAME "/proc/filesystems"
#endif
#ifndef PROC_CMDLINE_FILENAME
#define PROC_CMDLINE_FILENAME "/proc/cmdline"
#endif
#ifndef PROC_NET_PNP_FILENAME
#define PROC_NET_PNP_FILENAME "/proc/net/pnp"
#endif
#ifndef KMSG_FILENAME
#define KMSG_FILENAME "/dev/ksmg"
#endif
#ifndef MAX_SUPPORTED_FILESYSTEMS
#define MAX_SUPPORTED_FILESYSTEMS 256
#endif
#ifndef MAX_FILESYSTEM_TYPE_LEN
#define MAX_FILESYSTEM_TYPE_LEN 32
#endif
#ifndef LOG_PREFIX
#define LOG_PREFIX "initramfs: "
#endif
#ifndef DEVTMPFS_MOUNTOPTS
#define DEVTMPFS_MOUNTOPTS "size=10240k,mode=0755"
#endif
#ifndef DEVICE_TIMEOUT
#define DEVICE_TIMEOUT 180
#endif
#ifndef DEVICE_MESSAGE_TIMEOUT
#define DEVICE_MESSAGE_TIMEOUT 10
#endif
#ifndef DEVICE_POLL_MSEC
#define DEVICE_POLL_MSEC 50
#endif
#ifndef DEFAULT_ROOTFS_NFS_DIR
#define DEFAULT_ROOTFS_NFS_DIR "@@/tftpboot/%s@@"
#endif
/* Not all alternative libc implementations support these constants yet. */
#ifndef O_CLOEXEC
#define O_CLOEXEC 02000000
#endif
/* io.c */
typedef int (*traverse_line_t)(void *data, const char *line, int line_is_incomplete);
int traverse_file_by_line(const char *filename, traverse_line_t fn, void *data);
/* mount.c */
int parse_mount_options(char *syscall_data, size_t syscall_data_len, const char *option_string, int *nfsver);
int mount_filesystem(const char *source, const char *target, const char *type, const char *flags);
/* log.c */
void panic(int err, ...) __attribute__((noreturn));
void warn(const char *str1, ...);
/* devices.c */
enum {
WANT_NAME = 0,
WANT_MAJMIN = 1,
WANT_UUID = 2,
WANT_SERIAL = 3
};
void wait_for_device(char *real_device_name /* MAX_PATH_LEN bytes */, int *timeout, const char *device, int delay);
int scan_devices(char *device_name /* MAX_PATH_LEN bytes */, int type, unsigned int maj, unsigned int min, const char *uuid /* 16 bytes */, char *serial /* 20 bytes */);
int parse_uuid(char *uuid_buf /* 16 bytes */, const char *string_representation);
#define VIRTIO_BLK_ID_BYTES 20 /* ID string length */
int is_valid_device_name(const char *device_name, int *type, unsigned int* major, unsigned int *minor, char *uuid /* 16 bytes */, char *serial /* 20 bytes */);
/* util.c */
void append_to_buf(char *buf, size_t size, ...);
void set_buf(char *buf, size_t size, ...);
#endif /* !defined(TINY_INITRAMFS_H) */