int qt_probe() { struct s_devinfo blkdev[FSA_MAX_BLKDEVICES]; int diskcount; int partcount; char temp[1024]; //char cFormat[1024]; int res; int i; int j = 0; // ---- 0. get info from /proc/partitions + libblkid if ((res=partlist_getlist(blkdev, FSA_MAX_BLKDEVICES, &diskcount, &partcount))<1) { printf("keine Disk und Partition entdeckt\n"); return -1; } // ---- 2. show filesystem information if (partcount>0) { for (i=0; i < res; i++) { if (blkdev[i].devtype==BLKDEV_FILESYSDEV) { partition[i][0] = partlist_getinfo(temp, sizeof(temp), &blkdev[i], 0), strlen(partlist_getinfo(temp, sizeof(temp), &blkdev[i], 0)); // qDebug() << " partition[i][0]" << partition[i][0] << partition[i][1] << partition[i][3] ; if (partition[i][0] != "" && partition[i][0] != "ramzswap0" && partition[i][0] != "" && partition[i][0] != "loop0" && partition[i][0] != "" && partition[i][0] != "zram0"){ j = j + 1; //Daten in ein Array übernehmen vielleicht für einen bessere Formatierung im Listfeld //Device partition[j][0]= partlist_getinfo(temp, sizeof(temp), &blkdev[i], 0), strlen(partlist_getinfo(temp, sizeof(temp), &blkdev[i], 0)); // File system partition[j][1]= partlist_getinfo(temp, sizeof(temp), &blkdev[i], 1), strlen(partlist_getinfo(temp, sizeof(temp), &blkdev[i], 1)); // Size partition[j][2]= partlist_getinfo(temp, sizeof(temp), &blkdev[i], 3), strlen(partlist_getinfo(temp, sizeof(temp), &blkdev[i], 3)); //UUID partition[j][3]= partlist_getinfo(temp, sizeof(temp), &blkdev[i], 7), strlen(partlist_getinfo(temp, sizeof(temp), &blkdev[i], 7)); //Bezeichnung partition[j][4]= partlist_getinfo(temp, sizeof(temp), &blkdev[i], 2), strlen(partlist_getinfo(temp, sizeof(temp), &blkdev[i], 2)); } } } } else { printf("Es wurde keine Festplatte erkannt!\n"); } return 0; }
int oper_probe(bool details) { struct s_devinfo blkdev[FSA_MAX_BLKDEVICES]; int diskcount; int partcount; char temp[1024]; int res; int i, j; // ---- 0. get info from /proc/partitions + libblkid if ((res=partlist_getlist(blkdev, FSA_MAX_BLKDEVICES, &diskcount, &partcount))<1) { msgprintf(MSG_FORCE, "Failed to detect disks and filesystems\n"); return -1; } // ---- 1. show physical disks if (diskcount>0) { msgprintf(MSG_FORCE, "[======DISK======] [=============NAME==============] [====SIZE====] [MAJ] [MIN]\n"); for (i=0; i < res; i++) if (blkdev[i].devtype==BLKDEV_PHYSDISK) msgprintf(MSG_FORCE, "[%-16s] [%-31s] [%12s] [%3d] [%3d]\n", blkdev[i].devname, blkdev[i].name, blkdev[i].txtsize, blkdev[i].major, blkdev[i].minor); msgprintf(MSG_FORCE, "\n"); } else { msgprintf(MSG_FORCE, "No physical disk found\n"); } // ---- 2. show filesystem information if (partcount>0) { // show title for filesystems for (j=0; partinfo[j].title[0]; j++) { if (details==true || partinfo[j].detailed==false) msgprintf(MSG_FORCE, "%s", partinfo[j].title); } msgprintf(MSG_FORCE, "\n"); // show filesystems data for (i=0; i < res; i++) { if (blkdev[i].devtype==BLKDEV_FILESYSDEV) { for (j=0; partinfo[j].title[0]; j++) { if (details==true || partinfo[j].detailed==false) msgprintf(MSG_FORCE, partinfo[j].format, partlist_getinfo(temp, sizeof(temp), &blkdev[i], j)); } msgprintf(MSG_FORCE, "\n"); } } } else { msgprintf(MSG_FORCE, "No filesystem found\n"); } return 0; }