blob: b161cfa0f9fa15dce4e2afdc7d71bd0b3925ba3c [file] [log] [blame]
Alexey Dobriyan3ee2a192017-11-17 15:26:49 -08001#include <linux/dcache.h>
2
3unsigned name_to_int(const struct qstr *qstr)
4{
5 const char *name = qstr->name;
6 int len = qstr->len;
7 unsigned n = 0;
8
9 if (len > 1 && *name == '0')
10 goto out;
Alexey Dobriyan0746a0b2017-11-17 15:26:52 -080011 do {
Alexey Dobriyan3ee2a192017-11-17 15:26:49 -080012 unsigned c = *name++ - '0';
13 if (c > 9)
14 goto out;
15 if (n >= (~0U-9)/10)
16 goto out;
17 n *= 10;
18 n += c;
Alexey Dobriyan0746a0b2017-11-17 15:26:52 -080019 } while (--len > 0);
Alexey Dobriyan3ee2a192017-11-17 15:26:49 -080020 return n;
21out:
22 return ~0U;
23}