aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/util.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--fs/proc/util.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/fs/proc/util.c b/fs/proc/util.c
new file mode 100644
index 000000000000..c29aa497394b
--- /dev/null
+++ b/fs/proc/util.c
@@ -0,0 +1,23 @@
+#include <linux/dcache.h>
+
+unsigned name_to_int(const struct qstr *qstr)
+{
+ const char *name = qstr->name;
+ int len = qstr->len;
+ unsigned n = 0;
+
+ if (len > 1 && *name == '0')
+ goto out;
+ while (len-- > 0) {
+ unsigned c = *name++ - '0';
+ if (c > 9)
+ goto out;
+ if (n >= (~0U-9)/10)
+ goto out;
+ n *= 10;
+ n += c;
+ }
+ return n;
+out:
+ return ~0U;
+}