diff options
| author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-03-07 18:26:23 +0000 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-03-07 18:26:23 +0000 | 
| commit | cbd8b0d401add58a06d82c7a5d7fb22b53d80714 (patch) | |
| tree | ab53ee84bc763deb56a519edc538e48c51140fe9 /hardinfo2/arch/linux/common | |
| parent | fd6deac8ca43c7f9d47c0829183648d92e26aac8 (diff) | |
Close #6694 (Crash), fix compilation with GTK+2.6
Diffstat (limited to 'hardinfo2/arch/linux/common')
| -rw-r--r-- | hardinfo2/arch/linux/common/filesystem.h | 69 | 
1 files changed, 34 insertions, 35 deletions
| diff --git a/hardinfo2/arch/linux/common/filesystem.h b/hardinfo2/arch/linux/common/filesystem.h index 37e5a730..79784c8f 100644 --- a/hardinfo2/arch/linux/common/filesystem.h +++ b/hardinfo2/arch/linux/common/filesystem.h @@ -43,7 +43,7 @@ static void  scan_filesystems(void)  {      FILE *mtab; -    gchar buf[128]; +    gchar buf[1024];      struct statfs sfs;      g_free(fs_list); @@ -53,49 +53,48 @@ scan_filesystems(void)      if (!mtab)  	return; -    while (fgets(buf, 128, mtab)) { +    while (fgets(buf, 1024, mtab)) {  	gfloat size, used, avail;  	gchar **tmp;  	tmp = g_strsplit(buf, " ", 0); -	statfs(tmp[1], &sfs); +	if (!statfs(tmp[1], &sfs)) { +		size = (float) sfs.f_bsize * (float) sfs.f_blocks; +		avail = (float) sfs.f_bsize * (float) sfs.f_bavail; +		used = size - avail; -	size = (float) sfs.f_bsize * (float) sfs.f_blocks; -	avail = (float) sfs.f_bsize * (float) sfs.f_bavail; -	used = size - avail; +		gchar *strsize = fs_human_readable(size), +		      *stravail = fs_human_readable(avail), +	  	      *strused = fs_human_readable(used); -	gchar *strsize = fs_human_readable(size), -	    *stravail = fs_human_readable(avail), -	    *strused = fs_human_readable(used); +		gchar *strhash; +		if ((strhash = g_hash_table_lookup(moreinfo, tmp[0]))) { +		    g_hash_table_remove(moreinfo, tmp[0]); +		    g_free(strhash); +		} -	gchar *strhash; -	if ((strhash = g_hash_table_lookup(moreinfo, tmp[0]))) { -	    g_hash_table_remove(moreinfo, tmp[0]); -	    g_free(strhash); -	} - -	strhash = g_strdup_printf("[%s]\n" -				  "Filesystem=%s\n" -				  "Mounted As=%s\n" -				  "Mount Point=%s\n" -				  "Size=%s\n" -				  "Used=%s\n" -				  "Available=%s\n", -				  tmp[0], -				  tmp[2], -				  strstr(tmp[3], -					 "rw") ? "Read-Write" : -				  "Read-Only", tmp[1], strsize, strused, -				  stravail); -	g_hash_table_insert(moreinfo, g_strdup(tmp[0]), strhash); +		strhash = g_strdup_printf("[%s]\n" +					  "Filesystem=%s\n" +					  "Mounted As=%s\n" +					  "Mount Point=%s\n" +					  "Size=%s\n" +					  "Used=%s\n" +					  "Available=%s\n", +					  tmp[0], +					  tmp[2], +					  strstr(tmp[3], "rw") ? "Read-Write" : +					  "Read-Only", tmp[1], strsize, strused, +					  stravail); +		g_hash_table_insert(moreinfo, g_strdup(tmp[0]), strhash); -	fs_list = g_strdup_printf("%s$%s$%s=%s total, %s free\n", -				  fs_list, -				  tmp[0], tmp[0], strsize, stravail); +		fs_list = g_strdup_printf("%s$%s$%s=%s total, %s free\n", +					  fs_list, +					  tmp[0], tmp[0], strsize, stravail); -	g_free(strsize); -	g_free(stravail); -	g_free(strused); +		g_free(strsize); +		g_free(stravail); +		g_free(strused); +	}  	g_strfreev(tmp);      } | 
