From 26d11b33cf4dc9d15688c734632ea850c6d2e3d3 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Mon, 16 Jul 2007 17:07:15 +0000 Subject: Use printf so we don't put blank lines at the top of new files and fix mountinfo for nfs roots --- init.d/bootmisc | 8 ++++---- sh/rc-functions.sh | 2 +- src/mountinfo.c | 51 ++++++++++++++++++++++++--------------------------- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/init.d/bootmisc b/init.d/bootmisc index 4fadb624..6be844e1 100755 --- a/init.d/bootmisc +++ b/init.d/bootmisc @@ -34,8 +34,8 @@ start() { if [ "${RC_UNAME}" = "Linux" ] ; then # Setup login records - echo > /var/run/utmp - [ -e /var/log/wtmp ] || echo > /var/log/wtmp + printf "" >/var/run/utmp + [ -e /var/log/wtmp ] || printf "" >/var/log/wtmp chgrp utmp /var/run/utmp /var/log/wtmp chmod 0664 /var/run/utmp /var/log/wtmp fi @@ -73,7 +73,7 @@ start() { fi # Create the .keep to stop portage from removing /var/lock - echo > /var/lock/.keep + printf "" >/var/lock/.keep eend 0 # Clean up /tmp directory @@ -126,7 +126,7 @@ start() { fi # 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() { diff --git a/sh/rc-functions.sh b/sh/rc-functions.sh index 632060ad..a1a7644b 100755 --- a/sh/rc-functions.sh +++ b/sh/rc-functions.sh @@ -21,7 +21,7 @@ stop_addon() { is_net_fs() { [ -z "$1" ] && return 1 - local t=$(mountinfo --fstype "$1" ) + local t=$(mountinfo --fstype "$1") for x in ${RC_NET_FS_LIST} ; do [ "${x}" = "${t}" ] && return 0 done diff --git a/src/mountinfo.c b/src/mountinfo.c index 9a44466a..5497875b 100644 --- a/src/mountinfo.c +++ b/src/mountinfo.c @@ -33,7 +33,7 @@ #if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__OpenBSD__) static char **find_mounts (regex_t *node_regex, regex_t *skip_node_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; int nmnts; @@ -70,9 +70,9 @@ static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex, continue; } - list = rc_strlist_addsortc (list, list_nodes ? + list = rc_strlist_addsortc (list, node ? mnts[i].f_mntfromname : - list_fstype ? mnts[i].f_fstypename : + fstype ? mnts[i].f_fstypename : mnts[i].f_mntonname); } @@ -82,14 +82,14 @@ static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex, #elif defined (__linux__) static char **find_mounts (regex_t *node_regex, regex_t *skip_node_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; char buffer[PATH_MAX * 3]; char *p; char *from; char *to; - char *fstype; + char *fst; char **list = 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; to = strsep (&p, " "); - fstype = strsep (&p, " "); + fst = strsep (&p, " "); /* Skip the really silly rootfs */ - if (strcmp (fstype, "rootfs") == 0) + if (strcmp (fst, "rootfs") == 0) continue; if (fstype_regex && - regexec (fstype_regex, fstype, 0, NULL, 0) != 0) + regexec (fstype_regex, fst, 0, NULL, 0) != 0) continue; if (skip_fstype_regex && - regexec (skip_fstype_regex, fstype, 0, NULL, 0) == 0) + regexec (skip_fstype_regex, fst, 0, NULL, 0) == 0) continue; if (mounts) { @@ -130,10 +130,7 @@ static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex, continue; } - list = rc_strlist_addsortc (list, - list_nodes ? - list_fstype ? fstype : - from : to); + list = rc_strlist_addsortc (list, node ? from : fstype ? fst : to); } fclose (fp); @@ -168,8 +165,8 @@ static struct option longopts[] = { { "skip-node-regex", 1, NULL, 'N'}, { "point-regex", 1, NULL, 'p'}, { "skip-point-regex", 1, NULL, 'P'}, - { "list-nodes", 0, NULL, 'o'}, - { "list-fstype", 0, NULL, 's'}, + { "node", 0, NULL, 'o'}, + { "fstype", 0, NULL, 's'}, longopts_COMMON { NULL, 0, NULL, 0} }; @@ -185,9 +182,9 @@ int main (int argc, char **argv) regex_t *skip_node_regex = NULL; regex_t *skip_point_regex = NULL; char **nodes = NULL; - char *node; - bool list_nodes = false; - bool list_fstype = false; + char *n; + bool node = false; + bool fstype = false; char **mounts = NULL; int opt; int result; @@ -219,12 +216,12 @@ int main (int argc, char **argv) DO_REG (skip_point_regex); break; case 'o': - list_nodes = true; - list_fstype = false; + node = true; + fstype = false; break; case 's': - list_nodes = false; - list_fstype = true; + node = false; + fstype = true; break; case_RC_COMMON_GETOPT @@ -239,7 +236,7 @@ int main (int argc, char **argv) nodes = find_mounts (node_regex, skip_node_regex, fstype_regex, skip_fstype_regex, - mounts, list_nodes, list_fstype); + mounts, node, fstype); if (node_regex) regfree (node_regex); @@ -253,12 +250,12 @@ int main (int argc, char **argv) rc_strlist_reverse (nodes); result = EXIT_FAILURE; - STRLIST_FOREACH (nodes, node, i) { - if (point_regex && regexec (point_regex, node, 0, NULL, 0) != 0) + STRLIST_FOREACH (nodes, n, i) { + if (point_regex && regexec (point_regex, n, 0, NULL, 0) != 0) 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; - printf ("%s\n", node); + printf ("%s\n", n); result = EXIT_SUCCESS; } rc_strlist_free (nodes); -- cgit v1.2.3