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