From: tobias@gambas-buch.de (Tobias Boege)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Creating mkfs for my custom filesystem
Date: Fri, 29 Mar 2013 15:01:06 +0100 [thread overview]
Message-ID: <20130329140106.GB498@aurora> (raw)
In-Reply-To: <CAMSEaH6W11vgFQ-7ZzO_u-npyq+_OMDnopREusWyn3m1TDoBeQ@mail.gmail.com>
On Fri, 29 Mar 2013, Sankar P wrote:
> On Fri, Mar 29, 2013 at 3:28 PM, Tobias Boege <tobias@gambas-buch.de> wrote:
> > On Fri, 29 Mar 2013, Sankar P wrote:
> >> Hi,
> >>
> >> I am trying to write a simple filesystem to learn the basics of it.
> >>
> >> I have decided on a simple layout for my filesystem where the first
> >> block will be the super block and will contain the version
> >> information etc. The second block will contain the list of inodes.
> >> Third block onwards will be data blocks. Each file can grow only up to
> >> a single block size. Thrid block will represent the first file, fourth
> >> block for the second file and so on. Directories will not be
> >> supported.
> >>
> >> Now I want to create a mkfs for my filesystem as mentioned above. But
> >> I am not able to find out how to do the mkfs for my filesystem such
> >> that the generic mkfs utility will understand my filesystem. What APIs
> >> should I be using ?
> >>
> >> Any help is appreciated. Thanks.
> >
> > According to my copy of the mkfs sources, you just have to create a program
> > named "mkfs.ID" where ID identifies your filesystem. Then put that program
> > in a location that the generic mkfs can find, i.e. under $PATH (mkfs seems
> > to make some additions to PATH but you should figure this out yourself).
> >
> > Finally, calling "mkfs -t ID" makes mkfs search for a program named
> > "mkfs.ID" - simple concatenation.
> >
>
> oh okay. But how do I create the superblock ? What are the APIs
> available to do these block level operations from a user space
> application (my mkfs program ) ?
>
Look at how other mkfs.* do it. In general, these programs seem to be fairly
complex. To interface with block devices from userspace: use the standard
system calls, open(), lseek(), write(), ...
For an example, you can look at the e2fsprogs source code. If you get
through the jungle of indirections you will eventually find just a plain
write() call in lib/ext2fs/unix_io.c:raw_write_blk() which is used for data
transfer.
Regards,
Tobi
next prev parent reply other threads:[~2013-03-29 14:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-29 8:27 Creating mkfs for my custom filesystem Sankar P
2013-03-29 9:58 ` Tobias Boege
2013-03-29 10:14 ` Sankar P
2013-03-29 13:23 ` Valdis.Kletnieks at vt.edu
2013-03-29 14:01 ` Tobias Boege [this message]
2013-03-29 15:45 ` Sankar P
[not found] ` <CA+aCy1EC-tRUCVuP-h=UV0k0bPnhcs9mu+cGFSJt_wRxCKuD-w@mail.gmail.com>
2013-03-29 10:26 ` Fwd: " Pranay Srivastava
2013-03-29 10:48 ` Sankar P
2013-03-29 13:23 ` Madper
2013-03-29 17:27 ` Manish Katiyar
2013-03-29 18:17 ` Sankar P
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130329140106.GB498@aurora \
--to=tobias@gambas-buch.de \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).