Mercurial > hg > toybox
comparison toys/other/switch_root.c @ 674:7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 08 Oct 2012 00:02:30 -0500 |
parents | c60ac785784f |
children | 786841fdb1e0 |
comparison
equal
deleted
inserted
replaced
673:c102f31a753e | 674:7e846e281e38 |
---|---|
15 | 15 |
16 -c Redirect console to device in NEW_ROOT | 16 -c Redirect console to device in NEW_ROOT |
17 -h Hang instead of exiting on failure (avoids kernel panic) | 17 -h Hang instead of exiting on failure (avoids kernel panic) |
18 */ | 18 */ |
19 | 19 |
20 #define FOR_switch_root | |
20 #include "toys.h" | 21 #include "toys.h" |
21 #include <sys/vfs.h> | 22 #include <sys/vfs.h> |
22 | 23 |
23 DEFINE_GLOBALS( | 24 GLOBALS( |
24 char *console; | 25 char *console; |
25 | 26 |
26 dev_t rootdev; | 27 dev_t rootdev; |
27 ) | 28 ) |
28 | |
29 #define TT this.switch_root | |
30 | |
31 #define FLAG_h (1<<0) | |
32 #define FLAG_c (1<<1) | |
33 | 29 |
34 static int del_node(struct dirtree *node) | 30 static int del_node(struct dirtree *node) |
35 { | 31 { |
36 if (node->st.st_dev == TT.rootdev && dirtree_notdotdot(node)) { | 32 if (node->st.st_dev == TT.rootdev && dirtree_notdotdot(node)) { |
37 int flag = 0; | 33 int flag = 0; |