From ba7bc6dba25f50c82f20abe1344935b0907353f9 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Sun, 14 Jul 2013 18:04:27 +0900 Subject: [PATCH] fix mounted fs used/free/reserved display to work again... --- src/bin/e_widget_filepreview.c | 38 +++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/bin/e_widget_filepreview.c b/src/bin/e_widget_filepreview.c index 141259b60..127ee73c0 100644 --- a/src/bin/e_widget_filepreview.c +++ b/src/bin/e_widget_filepreview.c @@ -527,32 +527,50 @@ _e_wid_fprev_preview_file(E_Widget_Data *wd) unsigned long long blknum, blkused, blkres; double mbsize, mbused, mbres; Eina_Bool rdonly = EINA_FALSE; - char buf[PATH_MAX], mpoint[4096], fstype[4096]; + Eina_Bool f_is_dir = EINA_FALSE; + Eina_Bool f_is_dev = EINA_FALSE; + char buf[PATH_MAX], mdev[4096], mpoint[4096], fstype[4096]; FILE *f; - fragsz = stfs.f_frsize; - blknum = stfs.f_blocks; - blkused = stfs.f_blocks - stfs.f_bfree; - blkres = stfs.f_bfree - stfs.f_bavail; - fstype[0] = 0; mpoint[0] = 0; + mdev[0] = 0; f = fopen("/etc/mtab", "r"); if (f) { while (fgets(buf, sizeof(buf), f)) { - if (sscanf(buf, "%*s %4000s %4000s %*s", - mpoint, fstype) == 2) + if (sscanf(buf, "%4000s %4000s %4000s %*s", + mdev, mpoint, fstype) == 3) { - if (!strcmp(mpoint, file)) break; + if (!strcmp(mdev, file)) + { + f_is_dev = EINA_TRUE; + break; + } + if (!strcmp(mpoint, file)) + { + f_is_dir = EINA_TRUE; + break; + } } fstype[0] = 0; mpoint[0] = 0; + mdev[0] = 0; } fclose(f); } - if (blknum > blkres) + if ((f_is_dev) && (!f_is_dir)) + { + if (statvfs(mpoint, &stfs) != 0) ok = EINA_FALSE; + } + + fragsz = stfs.f_frsize; + blknum = stfs.f_blocks; + blkused = stfs.f_blocks - stfs.f_bfree; + blkres = stfs.f_bfree - stfs.f_bavail; + + if ((ok) && (mpoint[0]) && (blknum > blkres)) { is_fs = EINA_TRUE;