aboutsummaryrefslogtreecommitdiff
path: root/src/mountinfo.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-04-10 11:24:58 +0000
committerRoy Marples <roy@marples.name>2007-04-10 11:24:58 +0000
commitd3db9e9910ef0a472feb27cf4a9ace78e431ddd9 (patch)
tree7e01917c209258b2f459f63ba42558c3beffb2f5 /src/mountinfo.c
parent662e308d86d63750fc1d939e68c2b5ee88fea593 (diff)
Fix indentation
Diffstat (limited to 'src/mountinfo.c')
-rw-r--r--src/mountinfo.c202
1 files changed, 101 insertions, 101 deletions
diff --git a/src/mountinfo.c b/src/mountinfo.c
index 1fc84420..c5dc60ff 100644
--- a/src/mountinfo.c
+++ b/src/mountinfo.c
@@ -28,7 +28,7 @@
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__OpenBSD__)
static char **find_mounts (regex_t *node_regex, regex_t *fstype_regex,
- char **mounts, bool list_nodes, bool list_fstype)
+ char **mounts, bool list_nodes, bool list_fstype)
{
struct statfs *mnts;
int nmnts;
@@ -36,36 +36,36 @@ static char **find_mounts (regex_t *node_regex, regex_t *fstype_regex,
char **list = NULL;
if ((nmnts = getmntinfo (&mnts, MNT_NOWAIT)) == 0)
- eerrorx ("getmntinfo: %s", strerror (errno));
+ eerrorx ("getmntinfo: %s", strerror (errno));
for (i = 0; i < nmnts; i++)
{
if (node_regex &&
- regexec (node_regex, mnts[i].f_mntfromname, 0, NULL, 0) != 0)
- continue;
+ regexec (node_regex, mnts[i].f_mntfromname, 0, NULL, 0) != 0)
+ continue;
if (fstype_regex &&
- regexec (fstype_regex, mnts[i].f_fstypename, 0, NULL, 0) != 0)
- continue;
+ regexec (fstype_regex, mnts[i].f_fstypename, 0, NULL, 0) != 0)
+ continue;
if (mounts)
- {
- bool found = false;
- int j;
- char *mnt;
- STRLIST_FOREACH (mounts, mnt, j)
- if (strcmp (mnt, mnts[i].f_mntonname) == 0)
- {
- found = true;
- break;
- }
- if (! found)
- continue;
- }
+ {
+ bool found = false;
+ int j;
+ char *mnt;
+ STRLIST_FOREACH (mounts, mnt, j)
+ if (strcmp (mnt, mnts[i].f_mntonname) == 0)
+ {
+ found = true;
+ break;
+ }
+ if (! found)
+ continue;
+ }
list = rc_strlist_addsortc (list, list_nodes ?
- mnts[i].f_mntfromname :
- list_fstype ? mnts[i].f_fstypename :
- mnts[i].f_mntonname);
+ mnts[i].f_mntfromname :
+ list_fstype ? mnts[i].f_fstypename :
+ mnts[i].f_mntonname);
}
return (list);
@@ -73,7 +73,7 @@ static char **find_mounts (regex_t *node_regex, regex_t *fstype_regex,
#elif defined (__linux__)
static char **find_mounts (regex_t *node_regex, regex_t *fstype_regex,
- char **mounts, bool list_nodes, bool list_fstype)
+ char **mounts, bool list_nodes, bool list_fstype)
{
FILE *fp;
char buffer[PATH_MAX * 3];
@@ -82,46 +82,46 @@ static char **find_mounts (regex_t *node_regex, regex_t *fstype_regex,
char *to;
char *fstype;
char **list = NULL;
-
+
if ((fp = fopen ("/proc/mounts", "r")) == NULL)
- eerrorx ("getmntinfo: %s", strerror (errno));
+ eerrorx ("getmntinfo: %s", strerror (errno));
while (fgets (buffer, sizeof (buffer), fp))
{
p = buffer;
from = strsep (&p, " ");
if (node_regex &&
- regexec (node_regex, from, 0, NULL, 0) != 0)
- continue;
-
+ regexec (node_regex, from, 0, NULL, 0) != 0)
+ continue;
+
to = strsep (&p, " ");
fstype = strsep (&p, " ");
/* Skip the really silly rootfs */
if (strcmp (fstype, "rootfs") == 0)
- continue;
+ continue;
if (fstype_regex &&
- regexec (fstype_regex, fstype, 0, NULL, 0) != 0)
- continue;
+ regexec (fstype_regex, fstype, 0, NULL, 0) != 0)
+ continue;
if (mounts)
- {
- bool found = false;
- int j;
- char *mnt;
- STRLIST_FOREACH (mounts, mnt, j)
- if (strcmp (mnt, to) == 0)
- {
- found = true;
- break;
- }
- if (! found)
- continue;
- }
+ {
+ bool found = false;
+ int j;
+ char *mnt;
+ STRLIST_FOREACH (mounts, mnt, j)
+ if (strcmp (mnt, to) == 0)
+ {
+ found = true;
+ break;
+ }
+ if (! found)
+ continue;
+ }
list = rc_strlist_addsortc (list,
- list_nodes ?
- list_fstype ? fstype :
- from : to);
+ list_nodes ?
+ list_fstype ? fstype :
+ from : to);
}
fclose (fp);
@@ -150,75 +150,75 @@ int main (int argc, char **argv)
for (i = 1; i < argc; i++)
{
if (strcmp (argv[i], "--fstype-regex") == 0 && (i + 1 < argc))
- {
- i++;
- if (fstype_regex)
- free (fstype_regex);
- fstype_regex = rc_xmalloc (sizeof (regex_t));
- if ((result = regcomp (fstype_regex, argv[i],
- REG_EXTENDED | REG_NOSUB)) != 0)
- {
- regerror (result, fstype_regex, buffer, sizeof (buffer));
- eerrorx ("%s: invalid regex `%s'", argv[0], buffer);
- }
- continue;
- }
+ {
+ i++;
+ if (fstype_regex)
+ free (fstype_regex);
+ fstype_regex = rc_xmalloc (sizeof (regex_t));
+ if ((result = regcomp (fstype_regex, argv[i],
+ REG_EXTENDED | REG_NOSUB)) != 0)
+ {
+ regerror (result, fstype_regex, buffer, sizeof (buffer));
+ eerrorx ("%s: invalid regex `%s'", argv[0], buffer);
+ }
+ continue;
+ }
if (strcmp (argv[i], "--node-regex") == 0 && (i + 1 < argc))
- {
- i++;
- if (node_regex)
- free (node_regex);
- node_regex = rc_xmalloc (sizeof (regex_t));
- if ((result = regcomp (node_regex, argv[i],
- REG_EXTENDED | REG_NOSUB)) != 0)
- {
- regerror (result, node_regex, buffer, sizeof (buffer));
- eerrorx ("%s: invalid regex `%s'", argv[0], buffer);
- }
- continue;
- }
+ {
+ i++;
+ if (node_regex)
+ free (node_regex);
+ node_regex = rc_xmalloc (sizeof (regex_t));
+ if ((result = regcomp (node_regex, argv[i],
+ REG_EXTENDED | REG_NOSUB)) != 0)
+ {
+ regerror (result, node_regex, buffer, sizeof (buffer));
+ eerrorx ("%s: invalid regex `%s'", argv[0], buffer);
+ }
+ continue;
+ }
if (strcmp (argv[i], "--skip-regex") == 0 && (i + 1 < argc))
- {
- i++;
- if (skip_regex)
- free (skip_regex);
- skip_regex = rc_xmalloc (sizeof (regex_t));
- if ((result = regcomp (skip_regex, argv[i],
- REG_EXTENDED | REG_NOSUB)) != 0)
- {
- regerror (result, skip_regex, buffer, sizeof (buffer));
- eerrorx ("%s: invalid regex `%s'", argv[0], buffer);
- }
- continue;
- }
+ {
+ i++;
+ if (skip_regex)
+ free (skip_regex);
+ skip_regex = rc_xmalloc (sizeof (regex_t));
+ if ((result = regcomp (skip_regex, argv[i],
+ REG_EXTENDED | REG_NOSUB)) != 0)
+ {
+ regerror (result, skip_regex, buffer, sizeof (buffer));
+ eerrorx ("%s: invalid regex `%s'", argv[0], buffer);
+ }
+ continue;
+ }
if (strcmp (argv[i], "--fstype") == 0)
- {
- list_fstype = true;
- continue;
- }
+ {
+ list_fstype = true;
+ continue;
+ }
if (strcmp (argv[i], "--node") == 0)
- {
- list_nodes = true;
- continue;
- }
+ {
+ list_nodes = true;
+ continue;
+ }
if (strcmp (argv[i], "--reverse") == 0)
- {
- reverse = true;
- continue;
- }
+ {
+ reverse = true;
+ continue;
+ }
if (argv[i][0] != '/')
- eerrorx ("%s: `%s' is not a mount point", argv[0], argv[i]);
+ eerrorx ("%s: `%s' is not a mount point", argv[0], argv[i]);
mounts = rc_strlist_add (mounts, argv[i]);
}
nodes = find_mounts (node_regex, fstype_regex, mounts,
- list_nodes, list_fstype);
+ list_nodes, list_fstype);
if (node_regex)
regfree (node_regex);
@@ -232,7 +232,7 @@ int main (int argc, char **argv)
STRLIST_FOREACH (nodes, node, i)
{
if (skip_regex && regexec (skip_regex, node, 0, NULL, 0) == 0)
- continue;
+ continue;
printf ("%s\n", node);
result = EXIT_SUCCESS;
}