summaryrefslogtreecommitdiff
path: root/src/fstabinfo.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-04-11 12:44:47 +0000
committerRoy Marples <roy@marples.name>2007-04-11 12:44:47 +0000
commite6674b2caee26d2421215d29977cb91d5731ec8a (patch)
tree330ef9a3fd817a50ed62438e346e560be08f19fe /src/fstabinfo.c
parent55884f7959e1c80e573eb7cc3c8749197c11c4c9 (diff)
downloadopenrc-e6674b2caee26d2421215d29977cb91d5731ec8a.tar.gz
openrc-e6674b2caee26d2421215d29977cb91d5731ec8a.tar.bz2
openrc-e6674b2caee26d2421215d29977cb91d5731ec8a.tar.xz
Cuddle up to LKML C style
Diffstat (limited to 'src/fstabinfo.c')
-rw-r--r--src/fstabinfo.c162
1 files changed, 77 insertions, 85 deletions
diff --git a/src/fstabinfo.c b/src/fstabinfo.c
index de37383..f435d5a 100644
--- a/src/fstabinfo.c
+++ b/src/fstabinfo.c
@@ -43,104 +43,96 @@
#ifdef HAVE_GETMNTENT
static struct mntent *getmntfile (FILE *fp, const char *file)
{
- struct mntent *ent;
+ struct mntent *ent;
- while ((ent = getmntent (fp)))
- if (strcmp (file, ent->mnt_dir) == 0)
- return (ent);
+ while ((ent = getmntent (fp)))
+ if (strcmp (file, ent->mnt_dir) == 0)
+ return (ent);
- return (NULL);
+ return (NULL);
}
#endif
int main (int argc, char **argv)
{
- int i;
+ int i;
#ifdef HAVE_GETMNTENT
- FILE *fp;
- struct mntent *ent;
+ FILE *fp;
+ struct mntent *ent;
#else
- struct fstab *ent;
+ struct fstab *ent;
#endif
- int result = EXIT_FAILURE;
- char *p;
- char *token;
- int n = 0;
+ int result = EXIT_FAILURE;
+ char *p;
+ char *token;
+ int n = 0;
- for (i = 1; i < argc; i++)
- {
+ for (i = 1; i < argc; i++) {
#ifdef HAVE_GETMNTENT
- fp = setmntent ("/etc/fstab", "r");
+ fp = setmntent ("/etc/fstab", "r");
#endif
- if (strcmp (argv[i], "--fstype") == 0 && i + 1 < argc)
- {
- i++;
- p = argv[i];
- while ((token = strsep (&p, ",")))
- while ((ent = GET_ENT))
- if (strcmp (token, ENT_TYPE (ent)) == 0)
- printf ("%s\n", ENT_FILE (ent));
- result = EXIT_SUCCESS;
- }
-
- if (strcmp (argv[i], "--mount-cmd") == 0 && i + 1 < argc)
- {
- i++;
- if ((ent = GET_ENT_FILE (argv[i])) == NULL)
- continue;
- printf ("-o %s -t %s %s %s\n", ENT_OPTS (ent), ENT_TYPE (ent),
- ENT_DEVICE (ent), ENT_FILE (ent));
- result = EXIT_SUCCESS;
- }
-
- if (strcmp (argv[i], "--opts") == 0 && i + 1 < argc)
- {
- i++;
- if ((ent = GET_ENT_FILE (argv[i])) == NULL)
- continue;
- printf ("%s\n", ENT_OPTS (ent));
- result = EXIT_SUCCESS;
- }
-
- if (strcmp (argv[i], "--passno") == 0 && i + 1 < argc)
- {
- i++;
- switch (argv[i][0])
- {
- case '=':
- case '<':
- case '>':
- if (sscanf (argv[i] + 1, "%d", &n) != 1)
- eerrorx ("%s: invalid passno %s", argv[0], argv[i] + 1);
-
- while ((ent = GET_ENT))
- {
- if (((argv[i][0] == '=' && n == ENT_PASS (ent)) ||
- (argv[i][0] == '<' && n > ENT_PASS (ent)) ||
- (argv[i][0] == '>' && n < ENT_PASS (ent))) &&
- strcmp (ENT_FILE (ent), "none") != 0)
- printf ("%s\n", ENT_FILE (ent));
- }
-
- default:
- if ((ent = GET_ENT_FILE (argv[i])) == NULL)
- continue;
- printf ("%d\n", ENT_PASS (ent));
- result = EXIT_SUCCESS;
- }
- }
-
- END_ENT;
-
- if (result != EXIT_SUCCESS)
- {
- eerror ("%s: unknown option `%s'", basename (argv[0]), argv[i]);
- break;
- }
-
- }
-
- exit (result);
+ if (strcmp (argv[i], "--fstype") == 0 && i + 1 < argc) {
+ i++;
+ p = argv[i];
+ while ((token = strsep (&p, ",")))
+ while ((ent = GET_ENT))
+ if (strcmp (token, ENT_TYPE (ent)) == 0)
+ printf ("%s\n", ENT_FILE (ent));
+ result = EXIT_SUCCESS;
+ }
+
+ if (strcmp (argv[i], "--mount-cmd") == 0 && i + 1 < argc) {
+ i++;
+ if ((ent = GET_ENT_FILE (argv[i])) == NULL)
+ continue;
+ printf ("-o %s -t %s %s %s\n", ENT_OPTS (ent), ENT_TYPE (ent),
+ ENT_DEVICE (ent), ENT_FILE (ent));
+ result = EXIT_SUCCESS;
+ }
+
+ if (strcmp (argv[i], "--opts") == 0 && i + 1 < argc) {
+ i++;
+ if ((ent = GET_ENT_FILE (argv[i])) == NULL)
+ continue;
+ printf ("%s\n", ENT_OPTS (ent));
+ result = EXIT_SUCCESS;
+ }
+
+ if (strcmp (argv[i], "--passno") == 0 && i + 1 < argc) {
+ i++;
+ switch (argv[i][0]) {
+ case '=':
+ case '<':
+ case '>':
+ if (sscanf (argv[i] + 1, "%d", &n) != 1)
+ eerrorx ("%s: invalid passno %s", argv[0], argv[i] + 1);
+
+ while ((ent = GET_ENT)) {
+ if (((argv[i][0] == '=' && n == ENT_PASS (ent)) ||
+ (argv[i][0] == '<' && n > ENT_PASS (ent)) ||
+ (argv[i][0] == '>' && n < ENT_PASS (ent))) &&
+ strcmp (ENT_FILE (ent), "none") != 0)
+ printf ("%s\n", ENT_FILE (ent));
+ }
+
+ default:
+ if ((ent = GET_ENT_FILE (argv[i])) == NULL)
+ continue;
+ printf ("%d\n", ENT_PASS (ent));
+ result = EXIT_SUCCESS;
+ }
+ }
+
+ END_ENT;
+
+ if (result != EXIT_SUCCESS) {
+ eerror ("%s: unknown option `%s'", basename (argv[0]), argv[i]);
+ break;
+ }
+
+ }
+
+ exit (result);
}