Further cleanup of mount option handling.

This commit is contained in:
Matt Kraai 2001-04-17 04:32:50 +00:00
parent 24ed3bee0c
commit 1240082e37
2 changed files with 122 additions and 124 deletions

47
mount.c
View File

@ -273,24 +273,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
return (TRUE); return (TRUE);
} }
extern int mount_main(int argc, char **argv) void show_mounts()
{ {
char string_flags_buf[1024] = "";
char *string_flags = string_flags_buf;
char *extra_opts = string_flags_buf;
int flags = 0;
char *filesystemType = "auto";
char *device = NULL;
char *directory = NULL;
int all = FALSE;
int fakeIt = FALSE;
int useMtab = TRUE;
int i;
int rc = EXIT_FAILURE;
int fstabmount = FALSE;
#if defined BB_FEATURE_USE_DEVPS_PATCH #if defined BB_FEATURE_USE_DEVPS_PATCH
if (argc == 1) {
int fd, i, numfilesystems; int fd, i, numfilesystems;
char device[] = "/dev/mtab"; char device[] = "/dev/mtab";
struct k_mntent *mntentlist; struct k_mntent *mntentlist;
@ -323,10 +308,8 @@ extern int mount_main(int argc, char **argv)
free( mntentlist); free( mntentlist);
close(fd); close(fd);
#endif #endif
return EXIT_SUCCESS; exit(EXIT_SUCCESS);
}
#else #else
if (argc == 1) {
FILE *mountTable = setmntent(mtab_file, "r"); FILE *mountTable = setmntent(mtab_file, "r");
if (mountTable) { if (mountTable) {
@ -344,9 +327,25 @@ extern int mount_main(int argc, char **argv)
} else { } else {
perror_msg_and_die("%s", mtab_file); perror_msg_and_die("%s", mtab_file);
} }
return EXIT_SUCCESS; exit(EXIT_SUCCESS);
}
#endif #endif
}
extern int mount_main(int argc, char **argv)
{
char string_flags_buf[1024] = "";
char *string_flags = string_flags_buf;
char *extra_opts = string_flags_buf;
int flags = 0;
char *filesystemType = "auto";
char *device = NULL;
char *directory = NULL;
int all = FALSE;
int fakeIt = FALSE;
int useMtab = TRUE;
int i;
int rc = EXIT_FAILURE;
int fstabmount = FALSE;
/* Parse options */ /* Parse options */
i = --argc; i = --argc;
@ -405,14 +404,14 @@ extern int mount_main(int argc, char **argv)
argv++; argv++;
} }
if (device == NULL && !all)
show_mounts();
if (all == TRUE || directory == NULL) { if (all == TRUE || directory == NULL) {
struct mntent *m; struct mntent *m;
FILE *f = setmntent("/etc/fstab", "r"); FILE *f = setmntent("/etc/fstab", "r");
fstabmount = TRUE; fstabmount = TRUE;
if (all == FALSE && device == NULL)
goto goodbye;
if (f == NULL) if (f == NULL)
perror_msg_and_die( "\nCannot read /etc/fstab"); perror_msg_and_die( "\nCannot read /etc/fstab");

View File

@ -273,24 +273,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
return (TRUE); return (TRUE);
} }
extern int mount_main(int argc, char **argv) void show_mounts()
{ {
char string_flags_buf[1024] = "";
char *string_flags = string_flags_buf;
char *extra_opts = string_flags_buf;
int flags = 0;
char *filesystemType = "auto";
char *device = NULL;
char *directory = NULL;
int all = FALSE;
int fakeIt = FALSE;
int useMtab = TRUE;
int i;
int rc = EXIT_FAILURE;
int fstabmount = FALSE;
#if defined BB_FEATURE_USE_DEVPS_PATCH #if defined BB_FEATURE_USE_DEVPS_PATCH
if (argc == 1) {
int fd, i, numfilesystems; int fd, i, numfilesystems;
char device[] = "/dev/mtab"; char device[] = "/dev/mtab";
struct k_mntent *mntentlist; struct k_mntent *mntentlist;
@ -323,10 +308,8 @@ extern int mount_main(int argc, char **argv)
free( mntentlist); free( mntentlist);
close(fd); close(fd);
#endif #endif
return EXIT_SUCCESS; exit(EXIT_SUCCESS);
}
#else #else
if (argc == 1) {
FILE *mountTable = setmntent(mtab_file, "r"); FILE *mountTable = setmntent(mtab_file, "r");
if (mountTable) { if (mountTable) {
@ -344,9 +327,25 @@ extern int mount_main(int argc, char **argv)
} else { } else {
perror_msg_and_die("%s", mtab_file); perror_msg_and_die("%s", mtab_file);
} }
return EXIT_SUCCESS; exit(EXIT_SUCCESS);
}
#endif #endif
}
extern int mount_main(int argc, char **argv)
{
char string_flags_buf[1024] = "";
char *string_flags = string_flags_buf;
char *extra_opts = string_flags_buf;
int flags = 0;
char *filesystemType = "auto";
char *device = NULL;
char *directory = NULL;
int all = FALSE;
int fakeIt = FALSE;
int useMtab = TRUE;
int i;
int rc = EXIT_FAILURE;
int fstabmount = FALSE;
/* Parse options */ /* Parse options */
i = --argc; i = --argc;
@ -405,14 +404,14 @@ extern int mount_main(int argc, char **argv)
argv++; argv++;
} }
if (device == NULL && !all)
show_mounts();
if (all == TRUE || directory == NULL) { if (all == TRUE || directory == NULL) {
struct mntent *m; struct mntent *m;
FILE *f = setmntent("/etc/fstab", "r"); FILE *f = setmntent("/etc/fstab", "r");
fstabmount = TRUE; fstabmount = TRUE;
if (all == FALSE && device == NULL)
goto goodbye;
if (f == NULL) if (f == NULL)
perror_msg_and_die( "\nCannot read /etc/fstab"); perror_msg_and_die( "\nCannot read /etc/fstab");