0% found this document useful (0 votes)
9 views

Writing a custom Filesystem Format

The document is a forum thread discussing how to write a custom filesystem format, initiated by a user seeking guidance on the topic. Responses highlight the complexity of defining a filesystem and the challenges of getting an operating system to recognize it, suggesting resources and approaches for learning. Key points include the need for additional software or drivers and references to existing literature and tools like Fuse for filesystem development.

Uploaded by

djoleusa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Writing a custom Filesystem Format

The document is a forum thread discussing how to write a custom filesystem format, initiated by a user seeking guidance on the topic. Responses highlight the complexity of defining a filesystem and the challenges of getting an operating system to recognize it, suggesting resources and approaches for learning. Key points include the need for additional software or drivers and references to existing literature and tools like Fuse for filesystem development.

Uploaded by

djoleusa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10


 Forum
 Visual C++ & C++ Programming
 C++ (Non Visual C++ Issues)
 Writing a custom Filesystem Format

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have
to register or Login before you can post: click the register link above to proceed. To start
viewing messages, select the forum that you want to visit from the selection below.
Results 1 to 11 of 11

Thread: Writing a custom Filesystem Format


 Thread Tools
 Display

1. April 12th, 2012, 10:34 PM #1

bitwize

Junior Member

Join Date
Jan 2011
Posts
9

Writing a custom Filesystem Format


There is one thing that I've always wondered about, and yet never seem to find
when searching through google, tutorials, or even looking at programming
textbooks.
The question seems easy enough, but the answer seems elusive.

How do you write your own Filesystem/Format?

I've always wanted to know how to write my own system for the learning
experience.
I've worked on simple ones that read from a flatfile of a defined size, but never
one that was on a fully formatted drive.

Where do I start? Are there any examples/tutorials?


Reply With Quote

2. April 13th, 2012, 04:11 AM #2

monarch_dodra

Elite Member

Join Date
Jun 2009
Location
France
Posts
2,513

Re: Writing a custom Filesystem Format


You don't "write" a filesystem format, you define it. That's the "easy" part.

The hard part is getting the OS to recognize it and interface with it. This requires,
either:
- A third party program that accesses the drives directly
- A driver for the OS
- Kernal inclusion

Needless to say, all of the above are far from trivial, even for professionals, and
well outside the scope of plain old C++.

To put things into perspective, NTFS is still not fully supported on linux type
systems. ext2 is supposedly supported on windows with thrid party drivers, but
ext3 and ext4 aren't.

And I can tell you there is a LOT of pressure to get those working.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it
always makes for excellent reading.

Reply With Quote

3. April 13th, 2012, 02:00 PM #3


CMalcheski

Junior Member

Join Date
Apr 2012
Posts
8

Re: Writing a custom Filesystem Format


Actually the problem with NTFS is that the documentation on the spec was never
supposed to become public. Bits and pieces leaked out over the years; whether or
not Microsoft has finally just released the entire format is not something I've kept
up to date on. I had to write code to pull the paging file off the disk (and what I
found in there would make your skin crawl!!!).

Reply With Quote

4. April 13th, 2012, 04:08 PM #4

bitwize

Junior Member

Join Date
Jan 2011
Posts
9

Re: Writing a custom Filesystem Format


Originally Posted by monarch_dodra

You don't "write" a filesystem format, you define it. That's the "easy" part.

The hard part is getting the OS to recognize it and interface with it. This requires,
either:
- A third party program that accesses the drives directly
- A driver for the OS
- Kernal inclusion

Needless to say, all of the above are far from trivial, even for professionals, and
well outside the scope of plain old C++.
To put things into perspective, NTFS is still not fully supported on linux type
systems. ext2 is supposedly supported on windows with thrid party drivers, but
ext3 and ext4 aren't.

And I can tell you there is a LOT of pressure to get those working.

I'm not referring to the likes of NTFS because, as CMalcheski said, it's a
proprietary Microsoft filesystem that wasn't meant to become public.

I meant something more-or-less basic for testing. I'm just asking mainly about
how to format a drive in a custom format.
I don't mean the OS drive either, just -- for example -- a USB key, or another
partition.

I know it'd require different applications to access/alter/read/write information to


it already.
I'm not saying to entirely incorporate it into the system and make it work with the
basic file manager, I'm saying to build a separate one that will work with the new
partition.

Reply With Quote

5.
6. April 13th, 2012, 04:58 PM #5

S_M_A

Elite Member

Join Date
Oct 2006
Location
Sweden
Posts
3,654

Re: Writing a custom Filesystem Format


Go ahead and make something of you own mind but it doesn't matter, you still
have to do what monarch_dodra says.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
To enhance your chance's of getting an answer be sure to read
http://www.codeguru.com/forum/announ...nouncementid=6
and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

Refresh your memory on formatting tags here


http://www.codeguru.com/forum/misc.php?do=bbcode

Get your free MS compiler here


https://visualstudio.microsoft.com/vs

Reply With Quote

7. April 14th, 2012, 12:00 AM #6

bitwize

Junior Member

Join Date
Jan 2011
Posts
9

Re: Writing a custom Filesystem Format


Originally Posted by S_M_A

Go ahead and make something of you own mind but it doesn't matter, you still
have to do what monarch_dodra says.

I'm not attempting to dispute what he's saying, just trying to understand it, which I
actually get now.
At first I misunderstood what he meant, thinking that drivers would be to integrate
the system into the OS's file manager -- but then I realized that's to recognize the
actually drive/format, and detect how the file system is dealt with before data
manipulation can even be achieved.

I realize that creation of one, in a whole, is not particularly easy by any means --
but it's far from unachievable. I'm just merely trying to learn, that's all. No
disrespect intended.

Reply With Quote

8. April 14th, 2012, 12:23 AM #7

bitwize
Junior Member

Join Date
Jan 2011
Posts
9

Re: Writing a custom Filesystem Format


By chance, searching for how to write my own device driver lead my to the
Windows Driver Kit, which includes a built in API for recognizing file systems.

I wasn't looking specifically for Windows, but I think I'll take a look there.

Reply With Quote

9. April 14th, 2012, 01:37 AM #8

aamir121a

Member

Join Date
Mar 2010
Location
Melbourne Australia
Posts
454

Re: Writing a custom Filesystem Format


At Amazon search for a book Linux kernel development (3rd Edition ) , on page
261 page the book you will find virtual filing system , ( all filing systems under
linux are implemented as such ) Study the interface and implementation
( language C ) after you are mastered this ( you can even submit some patches )
you are then in a position to develop your own. Writing a good filing system as
hard as developing a kernel ( operating system ). Lot of things have to be
mastered , like data structures in C, As you would Digg deep you will find only
the best of developers get to work on these.

Reply With Quote

10.
11. April 14th, 2012, 08:23 AM #9

Eri523

Elite Member

Join Date
Jun 2010
Location
Germany
Posts
2,675

Re: Writing a custom Filesystem Format


This may be some interesting related reading too:
http://wiki.osdev.org/File_Systems, including links to more stuf.

I was thrown out of college for cheating on the metaphysics exam; I looked into
the soul of the boy sitting next to me.

This is a snakeskin jacket! And for me it's a symbol of my individuality, and my


belief... in personal freedom.

Reply With Quote

12. April 14th, 2012, 09:22 AM #10

bitwize

Junior Member

Join Date
Jan 2011
Posts
9

Re: Writing a custom Filesystem Format


Originally Posted by aamir121a
At Amazon search for a book Linux kernel development (3rd Edition ) , on page
261 page the book you will find virtual filing system , ( all filing systems under
linux are implemented as such ) Study the interface and implementation
( language C ) after you are mastered this ( you can even submit some patches )
you are then in a position to develop your own. Writing a good filing system as
hard as developing a kernel ( operating system ). Lot of things have to be
mastered , like data structures in C, As you would Digg deep you will find only
the best of developers get to work on these.

Thank you so much for that! Seriously, I wasn't aware of the book's existence, the
only book I really have is Stroustrup's book the C++ Programming Language.

I love learning about kernal/file system development. I much prefer designing and
working on the back end of systems

Reply With Quote

13. July 23rd, 2012, 03:45 PM #11

irhiggs

Junior Member

Join Date
Jul 2012
Posts
1

Re: Writing a custom Filesystem Format


I signed up to respond to this question...

Check out Fuse. It allows you to slap together your own FS quickly and easily.
http://fuse.sourceforge.net/
Example: http://fuse.sourceforge.net/helloworld.html
You will need to make sure you map your custom functions like so:

Code:

static struct fuse_operations hello_oper = {


.getattr = hello_getattr,
.readdir = hello_readdir,
.open = hello_open,
.read = hello_read,
};
Also, if you want to get your hands dirty, as aamir121a said, the linux kernel
development is a good place to look. As you have already discovered, there isn't
many web resources for this topic, but if you download the linux kernel source
and look at ../fs/ramfs you will see one of the smallest FSs implemented directly
into the kernel.

Reply With Quote

Quick Navigation C++ (Non Visual C++ Issues) Top


« Previous Thread | Next Thread »

Tags for this Thread

custom, file system, question

View Tag Cloud

Posting Permissions

 You may not post new threads


 You may not post replies
 You may not post attachments
 You may not edit your posts

 BB code is On
 Smilies are On
 [IMG] code is On
 [VIDEO] code is On
 HTML code is Off

Forum Rules
 Contact Us
 CodeGuru
Forums
 Privacy Statement
 Top
Click Here to Expand Forum to Full Width

Featured
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously
consider bringing your Android mobile development
expertise to bear on the Windows 8 platform.

 * Porting from Android to Windows 8: The Real Story


Do you have an Android application? How hard would it
really be to port to Windows 8?
 * Guide to Porting Android Applications to Windows 8
If you've already built for Android, learn what do you really
need to know to port your application to Windows Phone 8.
 * HTML5 Development Center
Our portal for articles, videos, and news on HTML5, CSS3,
and JavaScript
 * Windows App Gallery
See the Windows 8.x apps we've spotlighted or submit your
own app to the gallery!

Terms and Conditions | About Us | Privacy Notice | Contact Us | Advertise | California - Do Not
Sell My Info
Copyright 2025 TechnologyAdvice. All Rights Reserved.

Advertiser Disclosure: Some of the products that appear on this site are from companies from
which TechnologyAdvice receives compensation. This compensation may impact how and
where products appear on this site including, for example, the order in which they appear.
TechnologyAdvice does not include all companies or all types of products available in the
marketplace.

All times are GMT -5. The time now is 12:32 PM.
Copyright TechnologyAdvice

You might also like