2017-11-17 23:26:49 +00:00
|
|
|
#include <linux/dcache.h>
|
2019-01-03 23:26:00 +00:00
|
|
|
#include "internal.h"
|
2017-11-17 23:26:49 +00:00
|
|
|
|
|
|
|
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;
|
2017-11-17 23:26:52 +00:00
|
|
|
do {
|
2017-11-17 23:26:49 +00:00
|
|
|
unsigned c = *name++ - '0';
|
|
|
|
if (c > 9)
|
|
|
|
goto out;
|
|
|
|
if (n >= (~0U-9)/10)
|
|
|
|
goto out;
|
|
|
|
n *= 10;
|
|
|
|
n += c;
|
2017-11-17 23:26:52 +00:00
|
|
|
} while (--len > 0);
|
2017-11-17 23:26:49 +00:00
|
|
|
return n;
|
|
|
|
out:
|
|
|
|
return ~0U;
|
|
|
|
}
|