aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-04-05 21:57:47 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-04-05 21:57:47 +0000
commit63e158bf68ca057a43d3c281fb2c4468328c7d55 (patch)
tree652596d819687154790512fc68b2047290c9efc9
parent569a01c37235208ea1d38031378a586dd1349f31 (diff)
downloadbusybox-w32-63e158bf68ca057a43d3c281fb2c4468328c7d55.tar.gz
busybox-w32-63e158bf68ca057a43d3c281fb2c4468328c7d55.tar.bz2
busybox-w32-63e158bf68ca057a43d3c281fb2c4468328c7d55.zip
[u]mount: extend -t option (Roy Marples <uberlord@gentoo.org>)
git-svn-id: svn://busybox.net/trunk/busybox@18344 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--include/libbb.h2
-rw-r--r--libbb/Kbuild1
-rw-r--r--util-linux/mount.c5
-rw-r--r--util-linux/umount.c10
4 files changed, 12 insertions, 6 deletions
diff --git a/include/libbb.h b/include/libbb.h
index b56352626..dca611b68 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -17,6 +17,7 @@
17#include <errno.h> 17#include <errno.h>
18#include <fcntl.h> 18#include <fcntl.h>
19#include <inttypes.h> 19#include <inttypes.h>
20#include <mntent.h>
20#include <netdb.h> 21#include <netdb.h>
21#include <setjmp.h> 22#include <setjmp.h>
22#include <signal.h> 23#include <signal.h>
@@ -657,6 +658,7 @@ extern struct BB_applet *find_applet_by_name(const char *name);
657extern void run_applet_by_name(const char *name, int argc, char **argv); 658extern void run_applet_by_name(const char *name, int argc, char **argv);
658#endif 659#endif
659 660
661extern int match_fstype(const struct mntent *mt, const char *fstypes);
660extern struct mntent *find_mount_point(const char *name, const char *table); 662extern struct mntent *find_mount_point(const char *name, const char *table);
661extern void erase_mtab(const char * name); 663extern void erase_mtab(const char * name);
662extern unsigned int tty_baud_to_value(speed_t speed); 664extern unsigned int tty_baud_to_value(speed_t speed);
diff --git a/libbb/Kbuild b/libbb/Kbuild
index bdf25da09..4865c9c7c 100644
--- a/libbb/Kbuild
+++ b/libbb/Kbuild
@@ -51,6 +51,7 @@ lib-y += llist.o
51lib-y += login.o 51lib-y += login.o
52lib-y += make_directory.o 52lib-y += make_directory.o
53lib-y += makedev.o 53lib-y += makedev.o
54lib-y += match_fstype.o
54lib-y += md5.o 55lib-y += md5.o
55lib-y += messages.o 56lib-y += messages.o
56lib-y += mode_string.o 57lib-y += mode_string.o
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 567514ccb..4a0237196 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -77,6 +77,7 @@ struct {
77 {"defaults", 0}, 77 {"defaults", 0},
78 /* {"quiet", 0}, - do not filter out, vfat wants to see it */ 78 /* {"quiet", 0}, - do not filter out, vfat wants to see it */
79 {"noauto", MOUNT_NOAUTO}, 79 {"noauto", MOUNT_NOAUTO},
80 {"sw", MOUNT_SWAP},
80 {"swap", MOUNT_SWAP}, 81 {"swap", MOUNT_SWAP},
81 USE_DESKTOP({"user", MOUNT_USERS},) 82 USE_DESKTOP({"user", MOUNT_USERS},)
82 USE_DESKTOP({"users", MOUNT_USERS},) 83 USE_DESKTOP({"users", MOUNT_USERS},)
@@ -1703,9 +1704,7 @@ int mount_main(int argc, char **argv)
1703 1704
1704 } else { 1705 } else {
1705 // Do we need to match a filesystem type? 1706 // Do we need to match a filesystem type?
1706 // TODO: support "-t type1,type2"; "-t notype1,type2" 1707 if (fstype && match_fstype(mtcur, fstype)) continue;
1707
1708 if (fstype && strcmp(mtcur->mnt_type, fstype)) continue;
1709 1708
1710 // Skip noauto and swap anyway. 1709 // Skip noauto and swap anyway.
1711 1710
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 4ea15d91b..19f13454b 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -12,7 +12,7 @@
12#include <mntent.h> 12#include <mntent.h>
13#include <getopt.h> 13#include <getopt.h>
14 14
15#define OPTION_STRING "flDnravd" 15#define OPTION_STRING "flDnravdt:"
16#define OPT_FORCE 1 16#define OPT_FORCE 1
17#define OPT_LAZY 2 17#define OPT_LAZY 2
18#define OPT_DONTFREELOOP 4 18#define OPT_DONTFREELOOP 4
@@ -27,6 +27,7 @@ int umount_main(int argc, char **argv)
27 char path[2*PATH_MAX]; 27 char path[2*PATH_MAX];
28 struct mntent me; 28 struct mntent me;
29 FILE *fp; 29 FILE *fp;
30 char *fstype = 0;
30 int status = EXIT_SUCCESS; 31 int status = EXIT_SUCCESS;
31 unsigned opt; 32 unsigned opt;
32 struct mtab_list { 33 struct mtab_list {
@@ -37,7 +38,7 @@ int umount_main(int argc, char **argv)
37 38
38 /* Parse any options */ 39 /* Parse any options */
39 40
40 opt = getopt32(argc, argv, OPTION_STRING); 41 opt = getopt32(argc, argv, OPTION_STRING, &fstype);
41 42
42 argc -= optind; 43 argc -= optind;
43 argv += optind; 44 argv += optind;
@@ -61,6 +62,9 @@ int umount_main(int argc, char **argv)
61 bb_error_msg_and_die("cannot open %s", bb_path_mtab_file); 62 bb_error_msg_and_die("cannot open %s", bb_path_mtab_file);
62 } else { 63 } else {
63 while (getmntent_r(fp, &me, path, sizeof(path))) { 64 while (getmntent_r(fp, &me, path, sizeof(path))) {
65 /* Match fstype if passed */
66 if (fstype && match_fstype(&me, fstype))
67 continue;
64 m = xmalloc(sizeof(struct mtab_list)); 68 m = xmalloc(sizeof(struct mtab_list));
65 m->next = mtl; 69 m->next = mtl;
66 m->device = xstrdup(me.mnt_fsname); 70 m->device = xstrdup(me.mnt_fsname);
@@ -71,7 +75,7 @@ int umount_main(int argc, char **argv)
71 } 75 }
72 76
73 /* If we're not umounting all, we need at least one argument. */ 77 /* If we're not umounting all, we need at least one argument. */
74 if (!(opt & OPT_ALL)) { 78 if (!(opt & OPT_ALL) && !fstype) {
75 m = 0; 79 m = 0;
76 if (!argc) bb_show_usage(); 80 if (!argc) bb_show_usage();
77 } 81 }