Is there any better ways to recognize the fs of partition?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
theflysong
Member
Member
Posts: 27
Joined: Wed Jun 29, 2022 2:17 am
Libera.chat IRC: theflysong

Is there any better ways to recognize the fs of partition?

Post by theflysong »

I read the first sector of partition, then try to find some iconic bytes of some popular fs, in order to recognize the fs.But I don't think it's reliable.Is there any better ways?
By the way, I noticed the system id byte of the partition.Is it useful?
I'm a new man to develop operating system.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Is there any better ways to recognize the fs of partitio

Post by iansjack »

There’s some information here which might help: https://jdebp.uk/FGA/determining-filesystem-type.html
theflysong
Member
Member
Posts: 27
Joined: Wed Jun 29, 2022 2:17 am
Libera.chat IRC: theflysong

Re: Is there any better ways to recognize the fs of partitio

Post by theflysong »

iansjack wrote:There’s some information here which might help: https://jdebp.uk/FGA/determining-filesystem-type.html
Thanks, but I can't access this page no matter whether I use the VPN.Can you give me a screenshot?Or other pages?
I'm a new man to develop operating system.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Is there any better ways to recognize the fs of partitio

Post by iansjack »

I can’t reproduce the whole page as that would be a copyright breach, and it contains futher links. Can you get to https://jdebp.uk/FGA/ and follow the links from there?

Possibly there is some restriction on that site from your locality - where are you?
nullplan
Member
Member
Posts: 1789
Joined: Wed Aug 30, 2017 8:24 am

Re: Is there any better ways to recognize the fs of partitio

Post by nullplan »

The article talks about how various partition types map to various file systems. I wouldn't bother. Far better to just look at the data in the partition. Especially for MBR formatted drives, you have one byte, which is just not enough space to encode FS information reliably. Partition type 0x82 may be some FreeBSD partition, or a Linux swap partition, and the only way to tell is to look at the data. Type 0x83 may be any Linux FS, and Linux supports many file systems.

Best way to do it as far as I know is to attempt to mount the FS with all of your FS drivers. I mean, you must program your FS drivers such that the device data is not trusted, right? So you must verify that all input fields have sensible values. Yes, in the end this comes back down to guessing magic numbers, but far better than to trust that whatever partitioning tool set the partition types correctly, or that a sensible partition type even exists.
Carpe diem!
theflysong
Member
Member
Posts: 27
Joined: Wed Jun 29, 2022 2:17 am
Libera.chat IRC: theflysong

Re: Is there any better ways to recognize the fs of partitio

Post by theflysong »

iansjack wrote:I can’t reproduce the whole page as that would be a copyright breach, and it contains futher links. Can you get to https://jdebp.uk/FGA/ and follow the links from there?

Possibly there is some restriction on that site from your locality - where are you?
I come from China, and, you know, China has many Internet restrictions, in order to ban some illegal infomations, but also prevent us from accessing some technical pages, because they are didn't approved by goverments.So we sometimes use a VPN to access foreign websites, to look up some infomation.Strangely, I can't access this page no matter whether I use a VPN.I guess there are some special restrictions to it?

Luckily, I needn't a VPN to access this website.(the VPN was too expensive)
I'm a new man to develop operating system.
theflysong
Member
Member
Posts: 27
Joined: Wed Jun 29, 2022 2:17 am
Libera.chat IRC: theflysong

Re: Is there any better ways to recognize the fs of partitio

Post by theflysong »

nullplan wrote:The article talks about how various partition types map to various file systems. I wouldn't bother. Far better to just look at the data in the partition. Especially for MBR formatted drives, you have one byte, which is just not enough space to encode FS information reliably. Partition type 0x82 may be some FreeBSD partition, or a Linux swap partition, and the only way to tell is to look at the data. Type 0x83 may be any Linux FS, and Linux supports many file systems.

Best way to do it as far as I know is to attempt to mount the FS with all of your FS drivers. I mean, you must program your FS drivers such that the device data is not trusted, right? So you must verify that all input fields have sensible values. Yes, in the end this comes back down to guessing magic numbers, but far better than to trust that whatever partitioning tool set the partition types correctly, or that a sensible partition type even exists.
Thanks, I think it maybe the only way to deal with this problem.
I'm a new man to develop operating system.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Is there any better ways to recognize the fs of partitio

Post by iansjack »

nullplan wrote:The article talks about how various partition types map to various file systems. I wouldn't bother.
Well, as well as partition types it also discusses the BPB and the magic numbers in the superblock that identify Unix-style filesystems. From the very start it emphasises that the partition type is not a reliable way to determine the filesystem. It has information that would be interesting to anyone wanting to identify a filesystem.

Why that page is inaccessible to China is a mystery.
Post Reply