flash_lock, flash_unlock: new applets

By Thierry Reding (thierry.reding AT avionic-design.de)

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/include/applets.h b/include/applets.h
index 7838757..5fbb346 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -155,8 +155,9 @@
 IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER, fgrep))
 IF_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_NEVER, find))
 IF_FINDFS(APPLET(findfs, _BB_DIR_SBIN, _BB_SUID_MAYBE))
-//IF_FLASH_ERASEALL(APPLET_ODDNAME(flash_eraseall, flash_eraseall, _BB_DIR_USR_SBIN, _BB_SUID_NEVER, flash_eraseall))
 IF_FLASH_ERASEALL(APPLET(flash_eraseall, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
+IF_FLASH_LOCK(APPLET_ODDNAME(flash_lock, flash_lock_unlock, _BB_DIR_USR_SBIN, _BB_SUID_NEVER, flash_lock))
+IF_FLASH_UNLOCK(APPLET_ODDNAME(flash_unlock, flash_lock_unlock, _BB_DIR_USR_SBIN, _BB_SUID_NEVER, flash_unlock))
 IF_FOLD(APPLET(fold, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 IF_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 IF_FREERAMDISK(APPLET(freeramdisk, _BB_DIR_SBIN, _BB_SUID_NEVER))
diff --git a/include/usage.h b/include/usage.h
index 1e327fb..e606925 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -1248,6 +1248,17 @@
        "$ find / -name passwd\n" \
        "/etc/passwd\n"
 
+#define flash_lock_trivial_usage \
+       "MTD_DEVICE OFFSET SECTORS"
+#define flash_lock_full_usage "\n\n" \
+       "Lock part or all of an MTD device. If SECTORS is -1, then all sectors\n" \
+       "will be locked, regardless of the value of OFFSET"
+
+#define flash_unlock_trivial_usage \
+       "MTD_DEVICE"
+#define flash_unlock_full_usage "\n\n" \
+       "Unlock an MTD device"
+
 #define flash_eraseall_trivial_usage \
        "[-jq] MTD_DEVICE"
 #define flash_eraseall_full_usage "\n\n" \
diff --git a/include/xatonum.h b/include/xatonum.h
index ee816ef..864d2a3 100644
--- a/include/xatonum.h
+++ b/include/xatonum.h
@@ -22,6 +22,7 @@
 unsigned type xato##UT(const char *str) FAST_FUNC; \
 type xstrto##T##_range_sfx(const char *str, int b, type l, type u, const struct suffix_mult *sfx) FAST_FUNC; \
 type xstrto##T##_range(const char *str, int b, type l, type u) FAST_FUNC; \
+type xstrto##T(const char *str, int b) FAST_FUNC; \
 type xato##T##_range_sfx(const char *str, type l, type u, const struct suffix_mult *sfx) FAST_FUNC; \
 type xato##T##_range(const char *str, type l, type u) FAST_FUNC; \
 type xato##T##_sfx(const char *str, const struct suffix_mult *sfx) FAST_FUNC; \
@@ -66,6 +67,9 @@
 narrow xstrto##N##_range(const char *str, int b, narrow l, narrow u) \
 { return xstrto##W##_range(str, b, l, u); } \
 static ALWAYS_INLINE \
+narrow xstrto##N(const char *str, int b) \
+{ return xstrto##W(str, b); } \
+static ALWAYS_INLINE \
 narrow xato##N##_range_sfx(const char *str, narrow l, narrow u, const struct suffix_mult *sfx) \
 { return xato##W##_range_sfx(str, l, u, sfx); } \
 static ALWAYS_INLINE \