Use printf so we don't put blank lines at the top of new files and fix mountinfo for nfs roots
This commit is contained in:
parent
42a5cb043b
commit
26d11b33cf
@ -34,8 +34,8 @@ start() {
|
|||||||
|
|
||||||
if [ "${RC_UNAME}" = "Linux" ] ; then
|
if [ "${RC_UNAME}" = "Linux" ] ; then
|
||||||
# Setup login records
|
# Setup login records
|
||||||
echo > /var/run/utmp
|
printf "" >/var/run/utmp
|
||||||
[ -e /var/log/wtmp ] || echo > /var/log/wtmp
|
[ -e /var/log/wtmp ] || printf "" >/var/log/wtmp
|
||||||
chgrp utmp /var/run/utmp /var/log/wtmp
|
chgrp utmp /var/run/utmp /var/log/wtmp
|
||||||
chmod 0664 /var/run/utmp /var/log/wtmp
|
chmod 0664 /var/run/utmp /var/log/wtmp
|
||||||
fi
|
fi
|
||||||
@ -73,7 +73,7 @@ start() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the .keep to stop portage from removing /var/lock
|
# Create the .keep to stop portage from removing /var/lock
|
||||||
echo > /var/lock/.keep
|
printf "" >/var/lock/.keep
|
||||||
eend 0
|
eend 0
|
||||||
|
|
||||||
# Clean up /tmp directory
|
# Clean up /tmp directory
|
||||||
@ -126,7 +126,7 @@ start() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for /etc/resolv.conf, and create if missing
|
# Check for /etc/resolv.conf, and create if missing
|
||||||
[ -e /etc/resolv.conf ] || echo >/etc/resolv.conf
|
[ -e /etc/resolv.conf ] || printf "" >/etc/resolv.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
@ -21,7 +21,7 @@ stop_addon() {
|
|||||||
is_net_fs() {
|
is_net_fs() {
|
||||||
[ -z "$1" ] && return 1
|
[ -z "$1" ] && return 1
|
||||||
|
|
||||||
local t=$(mountinfo --fstype "$1" )
|
local t=$(mountinfo --fstype "$1")
|
||||||
for x in ${RC_NET_FS_LIST} ; do
|
for x in ${RC_NET_FS_LIST} ; do
|
||||||
[ "${x}" = "${t}" ] && return 0
|
[ "${x}" = "${t}" ] && return 0
|
||||||
done
|
done
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__OpenBSD__)
|
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__OpenBSD__)
|
||||||
static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex,
|
static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex,
|
||||||
regex_t *fstype_regex, regex_t *skip_fstype_regex,
|
regex_t *fstype_regex, regex_t *skip_fstype_regex,
|
||||||
char **mounts, bool list_nodes, bool list_fstype)
|
char **mounts, bool node, bool fstype)
|
||||||
{
|
{
|
||||||
struct statfs *mnts;
|
struct statfs *mnts;
|
||||||
int nmnts;
|
int nmnts;
|
||||||
@ -70,9 +70,9 @@ static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list = rc_strlist_addsortc (list, list_nodes ?
|
list = rc_strlist_addsortc (list, node ?
|
||||||
mnts[i].f_mntfromname :
|
mnts[i].f_mntfromname :
|
||||||
list_fstype ? mnts[i].f_fstypename :
|
fstype ? mnts[i].f_fstypename :
|
||||||
mnts[i].f_mntonname);
|
mnts[i].f_mntonname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,14 +82,14 @@ static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex,
|
|||||||
#elif defined (__linux__)
|
#elif defined (__linux__)
|
||||||
static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex,
|
static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex,
|
||||||
regex_t *fstype_regex, regex_t *skip_fstype_regex,
|
regex_t *fstype_regex, regex_t *skip_fstype_regex,
|
||||||
char **mounts, bool list_nodes, bool list_fstype)
|
char **mounts, bool node, bool fstype)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buffer[PATH_MAX * 3];
|
char buffer[PATH_MAX * 3];
|
||||||
char *p;
|
char *p;
|
||||||
char *from;
|
char *from;
|
||||||
char *to;
|
char *to;
|
||||||
char *fstype;
|
char *fst;
|
||||||
char **list = NULL;
|
char **list = NULL;
|
||||||
|
|
||||||
if ((fp = fopen ("/proc/mounts", "r")) == NULL)
|
if ((fp = fopen ("/proc/mounts", "r")) == NULL)
|
||||||
@ -106,15 +106,15 @@ static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
to = strsep (&p, " ");
|
to = strsep (&p, " ");
|
||||||
fstype = strsep (&p, " ");
|
fst = strsep (&p, " ");
|
||||||
/* Skip the really silly rootfs */
|
/* Skip the really silly rootfs */
|
||||||
if (strcmp (fstype, "rootfs") == 0)
|
if (strcmp (fst, "rootfs") == 0)
|
||||||
continue;
|
continue;
|
||||||
if (fstype_regex &&
|
if (fstype_regex &&
|
||||||
regexec (fstype_regex, fstype, 0, NULL, 0) != 0)
|
regexec (fstype_regex, fst, 0, NULL, 0) != 0)
|
||||||
continue;
|
continue;
|
||||||
if (skip_fstype_regex &&
|
if (skip_fstype_regex &&
|
||||||
regexec (skip_fstype_regex, fstype, 0, NULL, 0) == 0)
|
regexec (skip_fstype_regex, fst, 0, NULL, 0) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (mounts) {
|
if (mounts) {
|
||||||
@ -130,10 +130,7 @@ static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list = rc_strlist_addsortc (list,
|
list = rc_strlist_addsortc (list, node ? from : fstype ? fst : to);
|
||||||
list_nodes ?
|
|
||||||
list_fstype ? fstype :
|
|
||||||
from : to);
|
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
|
||||||
@ -168,8 +165,8 @@ static struct option longopts[] = {
|
|||||||
{ "skip-node-regex", 1, NULL, 'N'},
|
{ "skip-node-regex", 1, NULL, 'N'},
|
||||||
{ "point-regex", 1, NULL, 'p'},
|
{ "point-regex", 1, NULL, 'p'},
|
||||||
{ "skip-point-regex", 1, NULL, 'P'},
|
{ "skip-point-regex", 1, NULL, 'P'},
|
||||||
{ "list-nodes", 0, NULL, 'o'},
|
{ "node", 0, NULL, 'o'},
|
||||||
{ "list-fstype", 0, NULL, 's'},
|
{ "fstype", 0, NULL, 's'},
|
||||||
longopts_COMMON
|
longopts_COMMON
|
||||||
{ NULL, 0, NULL, 0}
|
{ NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
@ -185,9 +182,9 @@ int main (int argc, char **argv)
|
|||||||
regex_t *skip_node_regex = NULL;
|
regex_t *skip_node_regex = NULL;
|
||||||
regex_t *skip_point_regex = NULL;
|
regex_t *skip_point_regex = NULL;
|
||||||
char **nodes = NULL;
|
char **nodes = NULL;
|
||||||
char *node;
|
char *n;
|
||||||
bool list_nodes = false;
|
bool node = false;
|
||||||
bool list_fstype = false;
|
bool fstype = false;
|
||||||
char **mounts = NULL;
|
char **mounts = NULL;
|
||||||
int opt;
|
int opt;
|
||||||
int result;
|
int result;
|
||||||
@ -219,12 +216,12 @@ int main (int argc, char **argv)
|
|||||||
DO_REG (skip_point_regex);
|
DO_REG (skip_point_regex);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
list_nodes = true;
|
node = true;
|
||||||
list_fstype = false;
|
fstype = false;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
list_nodes = false;
|
node = false;
|
||||||
list_fstype = true;
|
fstype = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case_RC_COMMON_GETOPT
|
case_RC_COMMON_GETOPT
|
||||||
@ -239,7 +236,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
nodes = find_mounts (node_regex, skip_node_regex,
|
nodes = find_mounts (node_regex, skip_node_regex,
|
||||||
fstype_regex, skip_fstype_regex,
|
fstype_regex, skip_fstype_regex,
|
||||||
mounts, list_nodes, list_fstype);
|
mounts, node, fstype);
|
||||||
|
|
||||||
if (node_regex)
|
if (node_regex)
|
||||||
regfree (node_regex);
|
regfree (node_regex);
|
||||||
@ -253,12 +250,12 @@ int main (int argc, char **argv)
|
|||||||
rc_strlist_reverse (nodes);
|
rc_strlist_reverse (nodes);
|
||||||
|
|
||||||
result = EXIT_FAILURE;
|
result = EXIT_FAILURE;
|
||||||
STRLIST_FOREACH (nodes, node, i) {
|
STRLIST_FOREACH (nodes, n, i) {
|
||||||
if (point_regex && regexec (point_regex, node, 0, NULL, 0) != 0)
|
if (point_regex && regexec (point_regex, n, 0, NULL, 0) != 0)
|
||||||
continue;
|
continue;
|
||||||
if (skip_point_regex && regexec (skip_point_regex, node, 0, NULL, 0) == 0)
|
if (skip_point_regex && regexec (skip_point_regex, n, 0, NULL, 0) == 0)
|
||||||
continue;
|
continue;
|
||||||
printf ("%s\n", node);
|
printf ("%s\n", n);
|
||||||
result = EXIT_SUCCESS;
|
result = EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
rc_strlist_free (nodes);
|
rc_strlist_free (nodes);
|
||||||
|
Loading…
Reference in New Issue
Block a user