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