#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#if defined(__GLIBC__)
-# include <xlocale.h>
-#endif // defined(__GLIBC__)
#include "alloc-util.h"
//#include "extract-word.h"
return 0;
}
#endif // 0
+
+int parse_dev(const char *s, dev_t *ret) {
+ unsigned x, y;
+ dev_t d;
+
+ if (sscanf(s, "%u:%u", &x, &y) != 2)
+ return -EINVAL;
+
+ d = makedev(x, y);
+ if ((unsigned) major(d) != x || (unsigned) minor(d) != y)
+ return -EINVAL;
+
+ *ret = d;
+ return 0;
+}