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