blkid: blkid_probe_lookup_value() - strange partition types
0
votes
1
answer
503
views
I need to check filesystem type on a thumb drive in my C++ application. It must be done before mounting a new partition. I also prefer not to call
system()
function. I tried to use the following test code:
#include
#include
int main()
{
blkid_probe pr;
const char *ptname;
const char* devname = "/dev/sdb1";
pr = blkid_new_probe_from_filename(devname);
if (!pr)
printf("faild to open device\n");
else
{
blkid_probe_enable_partitions(pr, true);
blkid_do_fullprobe(pr);
blkid_probe_lookup_value(pr, "PTTYPE", &ptname, NULL);
printf("%s partition type detected\n", ptname);
blkid_free_probe(pr);
}
}
When I plug in thumb drive with ntfs
this piece of code shows that my partions is dos. When I plug in thumb drive with fat
or ext4
the code returns strange string but the same for these two filesystems:
AWAVI��AUATL�%�
.
What causes these strange outputs? Maybe there is a better way to check a filesystem?
Thank you in advance for any help.
Asked by user6758
(23 rep)
May 12, 2021, 08:08 PM
Last activity: May 13, 2021, 03:51 AM
Last activity: May 13, 2021, 03:51 AM