- if (!strncmp(line, block, len)) {
- char *p = &line[len + 1];
- char *t = strstr(p, " ");
-
- if (!t) {
- fclose(fp);
- return NULL;
- }
-
- *t = '\0';
- t++;
-
- if (root_only &&
- strncmp(t, "f2fs", 4) &&
- strncmp(t, "jffs2", 5) &&
- strncmp(t, "ubifs", 5)) {
- fclose(fp);
- ULOG_ERR("block is mounted with wrong fs\n");
- return NULL;
- }
- point = p;
+ /* skip first two columns */
+ pos = strchr(line, ' ');
+ if (!pos)
+ continue;
+
+ pos = strchr(pos + 1, ' ');
+ if (!pos)
+ continue;
+
+ /* extract block device major:minor */
+ tmp = ++pos;
+ pos = strchr(pos, ':');
+ if (!pos)
+ continue;
+
+ *pos = '\0';
+ major = atoi(tmp);
+
+ tmp = ++pos;
+ pos = strchr(pos, ' ');
+ if (!pos)
+ continue;
+
+ *pos = '\0';
+ minor = atoi(tmp);
+
+ /* skip another column */
+ pos = strchr(pos + 1, ' ');
+ if (!pos)
+ continue;
+
+ /* get mountpoint */
+ tmp = ++pos;
+ pos = strchr(pos, ' ');
+ if (!pos)
+ continue;
+
+ *pos = '\0';
+ cpoint = tmp;
+
+ /* skip another two columns */
+ pos = strchr(pos + 1, ' ');
+ if (!pos)
+ continue;
+
+ pos = strchr(pos + 1, ' ');
+ if (!pos)
+ continue;
+
+ /* get fstype */
+ tmp = ++pos;
+ pos = strchr(pos, ' ');
+ if (!pos)
+ continue;
+
+ *pos = '\0';
+ fstype = tmp;
+
+ /* get device name */
+ tmp = ++pos;
+ pos = strchr(pos, ' ');
+ if (!pos)
+ continue;
+
+ *pos = '\0';
+ devname = tmp;
+
+ /* if device name matches */
+ if (!strncmp(block, devname, len)) {
+ if (root_only && fs_rootfs_only(fstype))
+ break;
+
+ /* found, return mountpoint */
+ point = strdup(cpoint);
+ break;
+ }
+
+ /* last chance: check if major:minor of block device match */
+ if (rstat)
+ continue;
+
+ if (!S_ISBLK(s.st_mode))
+ continue;
+
+ if (major == major(s.st_rdev) &&
+ minor == minor(s.st_rdev)) {
+ if (root_only && fs_rootfs_only(fstype))
+ break;