summaryrefslogtreecommitdiffstats
path: root/usr/kinit/kinit.h
blob: ee006f40a8b3afc81c359a297102dc08e5b8f809 (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
/*
 * kinit/kinit.h
 */

#ifndef KINIT_H
#define KINIT_H

#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>

int do_mounts(int argc, char *argv[]);
int mount_nfs_root(int argc, char *argv[], int flags);
int ramdisk_load(int argc, char *argv[]);
void md_run(int argc, char *argv[]);
const char *bdevname(dev_t dev);

extern int mnt_procfs;
extern int mnt_sysfs;

extern int init_argc;
extern char **init_argv;
extern const char *progname;

char *get_arg(int argc, char *argv[], const char *name);
int get_flag(int argc, char *argv[], const char *name);

int getintfile(const char *path, long *val);

ssize_t readfile(const char *path, char **pptr);
ssize_t freadfile(FILE *f, char **pptr);

/*
 * min()/max() macros that also do
 * strict type-checking.. See the
 * "unnecessary" pointer comparison.
 * From the Linux kernel.
 */
#define min(x, y) ({ \
	typeof(x) _x = (x);     \
	typeof(y) _y = (y);     \
	(void) (&_x == &_y);            \
	_x < _y ? _x : _y; })

#define max(x, y) ({ \
	typeof(x) _x = (x);     \
	typeof(y) _y = (y);     \
	(void) (&_x == &_y);            \
	_x > _y ? _x : _y; })


#ifdef DEBUG
# define dprintf printf
#else
# define dprintf(...) ((void)0)
#endif

#ifdef DEBUG
void dump_args(int argc, char *argv[]);
#else
static inline void dump_args(int argc, char *argv[])
{
	(void)argc;
	(void)argv;
}
#endif

int drop_capabilities(const char *caps);

#endif				/* KINIT_H */