40 |
* On failure, returns a human-readable error message. |
* On failure, returns a human-readable error message. |
41 |
*/ |
*/ |
42 |
|
|
|
#include <alloca.h> |
|
43 |
#include <assert.h> |
#include <assert.h> |
44 |
#include <dirent.h> |
#include <dirent.h> |
45 |
#include <errno.h> |
#include <errno.h> |
156 |
const char *run_init(const char *realroot, const char *console, |
const char *run_init(const char *realroot, const char *console, |
157 |
const char *init, char **initargs) |
const char *init, char **initargs) |
158 |
{ |
{ |
159 |
struct stat rst, cst, ist; |
struct stat rst, cst; |
160 |
struct statfs sfs; |
struct statfs sfs; |
161 |
int confd; |
int confd; |
162 |
|
|
175 |
if (rst.st_dev == cst.st_dev) |
if (rst.st_dev == cst.st_dev) |
176 |
return "current directory on the same filesystem as the root"; |
return "current directory on the same filesystem as the root"; |
177 |
|
|
|
/* The initramfs should have /init */ |
|
|
if (stat("/init", &ist) || !S_ISREG(ist.st_mode)) |
|
|
return "can't find /init on initramfs"; |
|
|
|
|
178 |
/* Make sure we're on a ramfs */ |
/* Make sure we're on a ramfs */ |
179 |
if (statfs("/", &sfs)) |
if (statfs("/", &sfs)) |
180 |
return "statfs /"; |
return "statfs /"; |