X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libfstools%2Ffind.c;h=72a2b4c70736adc482cb7d6a21225c241401b16c;hb=4abf9de460253771fabef2b2cdf5d7a8b457bd1d;hp=d9df173025673a6c04484491d2659e0c3b817bb8;hpb=cd3d4999a622af4830e4da974f4baafc085bad4d;p=oweals%2Ffstools.git diff --git a/libfstools/find.c b/libfstools/find.c index d9df173..72a2b4c 100644 --- a/libfstools/find.c +++ b/libfstools/find.c @@ -36,6 +36,9 @@ find_overlay_mount(char *overlay) return ret; } +/* + * Find path of a device mounted to the given point. + */ char* find_mount(char *mp) { @@ -53,6 +56,7 @@ find_mount(char *mp) fclose(fp); return NULL; } + *t = '\0'; t++; s = strstr(t, " "); if (!s) { @@ -63,7 +67,7 @@ find_mount(char *mp) if (!strcmp(t, mp)) { fclose(fp); - return t; + return line; } } @@ -73,7 +77,7 @@ find_mount(char *mp) } char* -find_mount_point(char *block, int mtd_only) +find_mount_point(char *block, int root_only) { FILE *fp = fopen("/proc/mounts", "r"); static char line[256]; @@ -96,11 +100,12 @@ find_mount_point(char *block, int mtd_only) *t = '\0'; t++; - if (mtd_only && - strncmp(t, "jffs2", 6) && - strncmp(t, "ubifs", 6)) { + if (root_only && + strncmp(t, "f2fs", 4) && + strncmp(t, "jffs2", 5) && + strncmp(t, "ubifs", 5)) { fclose(fp); - fprintf(stderr, "block is mounted with wrong fs\n"); + ULOG_ERR("block is mounted with wrong fs\n"); return NULL; } point = p; @@ -122,7 +127,7 @@ find_filesystem(char *fs) int ret = -1; if (!fp) { - fprintf(stderr, "opening /proc/filesystems failed: %s\n", strerror(errno)); + ULOG_ERR("opening /proc/filesystems failed: %s\n", strerror(errno)); goto out; }