-
- /* Look for /\nFilesystem UUID:\s+/ in the output. */
- p = strstr (out, "\nFilesystem UUID:");
- if (p == NULL) {
- reply_with_error ("no Filesystem UUID in the output of tune2fs -l");
- free (out);
- return NULL;
- }
-
- p += 17;
- while (*p && c_isspace (*p))
- p++;
- if (!*p) {
- reply_with_error ("malformed Filesystem UUID in the output of tune2fs -l");
- free (out);
- return NULL;
- }
-
- /* Now 'p' hopefully points to the start of the UUID. */
- q = p;
- while (*q && (c_isxdigit (*q) || *q == '-'))
- q++;
- if (!*q) {
- reply_with_error ("malformed Filesystem UUID in the output of tune2fs -l");
- free (out);
- return NULL;
- }
-
- *q = '\0';
-
- p = strdup (p);
- if (!p) {
- reply_with_perror ("strdup");
- free (out);
- return NULL;
- }
-
- free (out);
- return p; /* caller frees */