[u]mount: extend -t option (Roy Marples <uberlord@gentoo.org>)
This commit is contained in:
parent
df5bbb938a
commit
bf295dd5b6
@ -17,6 +17,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <mntent.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@ -657,6 +658,7 @@ extern struct BB_applet *find_applet_by_name(const char *name);
|
|||||||
extern void run_applet_by_name(const char *name, int argc, char **argv);
|
extern void run_applet_by_name(const char *name, int argc, char **argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern int match_fstype(const struct mntent *mt, const char *fstypes);
|
||||||
extern struct mntent *find_mount_point(const char *name, const char *table);
|
extern struct mntent *find_mount_point(const char *name, const char *table);
|
||||||
extern void erase_mtab(const char * name);
|
extern void erase_mtab(const char * name);
|
||||||
extern unsigned int tty_baud_to_value(speed_t speed);
|
extern unsigned int tty_baud_to_value(speed_t speed);
|
||||||
|
@ -51,6 +51,7 @@ lib-y += llist.o
|
|||||||
lib-y += login.o
|
lib-y += login.o
|
||||||
lib-y += make_directory.o
|
lib-y += make_directory.o
|
||||||
lib-y += makedev.o
|
lib-y += makedev.o
|
||||||
|
lib-y += match_fstype.o
|
||||||
lib-y += md5.o
|
lib-y += md5.o
|
||||||
lib-y += messages.o
|
lib-y += messages.o
|
||||||
lib-y += mode_string.o
|
lib-y += mode_string.o
|
||||||
|
@ -77,6 +77,7 @@ struct {
|
|||||||
{"defaults", 0},
|
{"defaults", 0},
|
||||||
/* {"quiet", 0}, - do not filter out, vfat wants to see it */
|
/* {"quiet", 0}, - do not filter out, vfat wants to see it */
|
||||||
{"noauto", MOUNT_NOAUTO},
|
{"noauto", MOUNT_NOAUTO},
|
||||||
|
{"sw", MOUNT_SWAP},
|
||||||
{"swap", MOUNT_SWAP},
|
{"swap", MOUNT_SWAP},
|
||||||
USE_DESKTOP({"user", MOUNT_USERS},)
|
USE_DESKTOP({"user", MOUNT_USERS},)
|
||||||
USE_DESKTOP({"users", MOUNT_USERS},)
|
USE_DESKTOP({"users", MOUNT_USERS},)
|
||||||
@ -1703,9 +1704,7 @@ int mount_main(int argc, char **argv)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Do we need to match a filesystem type?
|
// Do we need to match a filesystem type?
|
||||||
// TODO: support "-t type1,type2"; "-t notype1,type2"
|
if (fstype && match_fstype(mtcur, fstype)) continue;
|
||||||
|
|
||||||
if (fstype && strcmp(mtcur->mnt_type, fstype)) continue;
|
|
||||||
|
|
||||||
// Skip noauto and swap anyway.
|
// Skip noauto and swap anyway.
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
#define OPTION_STRING "flDnravd"
|
#define OPTION_STRING "flDnravdt:"
|
||||||
#define OPT_FORCE 1
|
#define OPT_FORCE 1
|
||||||
#define OPT_LAZY 2
|
#define OPT_LAZY 2
|
||||||
#define OPT_DONTFREELOOP 4
|
#define OPT_DONTFREELOOP 4
|
||||||
@ -27,6 +27,7 @@ int umount_main(int argc, char **argv)
|
|||||||
char path[2*PATH_MAX];
|
char path[2*PATH_MAX];
|
||||||
struct mntent me;
|
struct mntent me;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
char *fstype = 0;
|
||||||
int status = EXIT_SUCCESS;
|
int status = EXIT_SUCCESS;
|
||||||
unsigned opt;
|
unsigned opt;
|
||||||
struct mtab_list {
|
struct mtab_list {
|
||||||
@ -37,7 +38,7 @@ int umount_main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Parse any options */
|
/* Parse any options */
|
||||||
|
|
||||||
opt = getopt32(argc, argv, OPTION_STRING);
|
opt = getopt32(argc, argv, OPTION_STRING, &fstype);
|
||||||
|
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
@ -61,6 +62,9 @@ int umount_main(int argc, char **argv)
|
|||||||
bb_error_msg_and_die("cannot open %s", bb_path_mtab_file);
|
bb_error_msg_and_die("cannot open %s", bb_path_mtab_file);
|
||||||
} else {
|
} else {
|
||||||
while (getmntent_r(fp, &me, path, sizeof(path))) {
|
while (getmntent_r(fp, &me, path, sizeof(path))) {
|
||||||
|
/* Match fstype if passed */
|
||||||
|
if (fstype && match_fstype(&me, fstype))
|
||||||
|
continue;
|
||||||
m = xmalloc(sizeof(struct mtab_list));
|
m = xmalloc(sizeof(struct mtab_list));
|
||||||
m->next = mtl;
|
m->next = mtl;
|
||||||
m->device = xstrdup(me.mnt_fsname);
|
m->device = xstrdup(me.mnt_fsname);
|
||||||
@ -71,7 +75,7 @@ int umount_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If we're not umounting all, we need at least one argument. */
|
/* If we're not umounting all, we need at least one argument. */
|
||||||
if (!(opt & OPT_ALL)) {
|
if (!(opt & OPT_ALL) && !fstype) {
|
||||||
m = 0;
|
m = 0;
|
||||||
if (!argc) bb_show_usage();
|
if (!argc) bb_show_usage();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user