diff options
author | Michael Abbott <michael@araneidae.co.uk> | 2009-12-04 03:33:07 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-12-04 03:33:07 +0100 |
commit | 6b5accbfc1f721c5c34b8a3bfad07a19053946d0 (patch) | |
tree | b6a1b39b3f540fca1dde71d2054b82c5b8d295a2 /util-linux | |
parent | 6dc0ace10943b9f8e004b63277dc1186594f0450 (diff) | |
download | busybox-w32-6b5accbfc1f721c5c34b8a3bfad07a19053946d0.tar.gz busybox-w32-6b5accbfc1f721c5c34b8a3bfad07a19053946d0.tar.bz2 busybox-w32-6b5accbfc1f721c5c34b8a3bfad07a19053946d0.zip |
mount: add support for -O list. +44 bytes
Signed-off-by: Michael Abbott <michael@araneidae.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/mount.c | 82 |
1 files changed, 50 insertions, 32 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c index d27d65f80..d7ca7da37 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -1760,43 +1760,61 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
1760 | return rc; | 1760 | return rc; |
1761 | } | 1761 | } |
1762 | 1762 | ||
1763 | /* -O support | 1763 | // -O support |
1764 | * Unlike -t, -O should interpret "no" prefix differently: | 1764 | // -O interprets a list of filter options which select whether a mount |
1765 | * -t noa,b,c = -t no(a,b,c) = mount all except fs'es with types a,b, and c | 1765 | // point will be mounted: only mounts with options matching *all* filtering |
1766 | * -O noa,b,c = -O noa,b,c = mount all with without option a, | 1766 | // options will be selected. |
1767 | * or with option b or c. | 1767 | // By default each -O filter option must be present in the list of mount |
1768 | * But for now we do not support -O a,b,c at all (only -O a). | 1768 | // options, but if it is prefixed by "no" then it must be absent. |
1769 | * | 1769 | // For example, |
1770 | * Another difference from -t support (match_fstype) is that | 1770 | // -O a,nob,c matches -o a,c but fails to match -o a,b,c |
1771 | * we need to examine the _list_ of options in fsopt, not just a string. | 1771 | // (and also fails to match -o a because -o c is absent). |
1772 | */ | 1772 | // |
1773 | static int match_opt(const char *fs_opt, const char *O_opt) | 1773 | // It is different from -t in that each option is matched exactly; a leading |
1774 | // "no" at the beginning of one option does not negate the rest. | ||
1775 | static int match_opt(const char *fs_opt_in, const char *O_opt) | ||
1774 | { | 1776 | { |
1775 | int match = 1; | ||
1776 | int len; | ||
1777 | |||
1778 | if (!O_opt) | 1777 | if (!O_opt) |
1779 | return match; | 1778 | return 1; |
1780 | 1779 | ||
1781 | if (O_opt[0] == 'n' && O_opt[1] == 'o') { | 1780 | while (*O_opt) { |
1782 | match--; | 1781 | const char *fs_opt = fs_opt_in; |
1783 | O_opt += 2; | 1782 | int O_len; |
1784 | } | 1783 | int match; |
1785 | 1784 | ||
1786 | len = strlen(O_opt); | 1785 | // If option begins with "no" then treat as an inverted match: |
1787 | while (1) { | 1786 | // matching is a failure |
1788 | if (strncmp(fs_opt, O_opt, len) == 0 | 1787 | match = 0; |
1789 | && (fs_opt[len] == '\0' || fs_opt[len] == ',') | 1788 | if (O_opt[0] == 'n' && O_opt[1] == 'o') { |
1790 | ) { | 1789 | match = 1; |
1791 | return match; | 1790 | O_opt += 2; |
1791 | } | ||
1792 | // Isolate the current O option | ||
1793 | O_len = strchrnul(O_opt, ',') - O_opt; | ||
1794 | // Check for a match against existing options | ||
1795 | while (1) { | ||
1796 | if (strncmp(fs_opt, O_opt, O_len) == 0 | ||
1797 | && (fs_opt[O_len] == '\0' || fs_opt[O_len] == ',') | ||
1798 | ) { | ||
1799 | if (match) | ||
1800 | return 0; // "no" prefix, but option found | ||
1801 | match = 1; // current O option found, go check next one | ||
1802 | break; | ||
1803 | } | ||
1804 | fs_opt = strchr(fs_opt, ','); | ||
1805 | if (!fs_opt) | ||
1806 | break; | ||
1807 | fs_opt++; | ||
1792 | } | 1808 | } |
1793 | fs_opt = strchr(fs_opt, ','); | 1809 | if (match == 0) |
1794 | if (!fs_opt) | 1810 | return 0; // match wanted but not found |
1811 | if (O_opt[O_len] == '\0') // end? | ||
1795 | break; | 1812 | break; |
1796 | fs_opt++; | 1813 | // Step to the next O option |
1814 | O_opt += O_len + 1; | ||
1797 | } | 1815 | } |
1798 | 1816 | // If we get here then everything matched | |
1799 | return !match; | 1817 | return 1; |
1800 | } | 1818 | } |
1801 | 1819 | ||
1802 | // Parse options, if necessary parse fstab/mtab, and call singlemount for | 1820 | // Parse options, if necessary parse fstab/mtab, and call singlemount for |