OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Apr 29, 2024 1:39 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Is there any better ways to recognize the fs of partition?
PostPosted: Sat Jun 24, 2023 8:56 am 
Offline
Member
Member

Joined: Wed Jun 29, 2022 2:17 am
Posts: 27
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.


Top
 Profile  
 
 Post subject: Re: Is there any better ways to recognize the fs of partitio
PostPosted: Sat Jun 24, 2023 10:40 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4597
Location: Chichester, UK
There’s some information here which might help: https://jdebp.uk/FGA/determining-filesystem-type.html


Top
 Profile  
 
 Post subject: Re: Is there any better ways to recognize the fs of partitio
PostPosted: Sun Jun 25, 2023 7:14 am 
Offline
Member
Member

Joined: Wed Jun 29, 2022 2:17 am
Posts: 27
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.


Top
 Profile  
 
 Post subject: Re: Is there any better ways to recognize the fs of partitio
PostPosted: Sun Jun 25, 2023 8:49 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4597
Location: Chichester, UK
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?


Top
 Profile  
 
 Post subject: Re: Is there any better ways to recognize the fs of partitio
PostPosted: Sun Jun 25, 2023 11:56 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1608
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!


Top
 Profile  
 
 Post subject: Re: Is there any better ways to recognize the fs of partitio
PostPosted: Mon Jun 26, 2023 1:26 am 
Offline
Member
Member

Joined: Wed Jun 29, 2022 2:17 am
Posts: 27
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.


Top
 Profile  
 
 Post subject: Re: Is there any better ways to recognize the fs of partitio
PostPosted: Mon Jun 26, 2023 1:29 am 
Offline
Member
Member

Joined: Wed Jun 29, 2022 2:17 am
Posts: 27
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.


Top
 Profile  
 
 Post subject: Re: Is there any better ways to recognize the fs of partitio
PostPosted: Mon Jun 26, 2023 1:48 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4597
Location: Chichester, UK
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], SemrushBot [Bot] and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group