File system software???

Matthias Lang <>
Thu Jun 27 13:44:45 CEST 2002


Joe Armstrong writes:
 > On 27 Jun 2002, Gordon Beaton wrote:
 > 
 > > On 27 Jun 2002 08:53:56 GMT, Joe Armstrong wrote:
 > > > Does anybody know of some software I can use for the following:
 > > > 
 > > >   - I want to create a simple file system *within* a bigger file
 > > >   - I want this to be fast and in C
 > > 
 > > mkfs kan build a *real*, mountable filesystem using any ordinary file.
 > > Typically you create a large, empty file with e.g. "dd" then specify
 > > that file as the "device" argument to mkfs.

 >   yes I've  tried this but then you  have to mount the  container via a
 > loopback device - and to mount it you must be root etc.

At least under linux, you do not necessarily need to be root. You can
put an entry in /etc/fstab to allow ordinary users to mount such
loopback filesystems, e.g.

matthias >cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>                       <dump> <pass>
/dev/hdc3       /               ext2    defaults,errors=remount-ro      0      1
/dev/hdc4       /usr/local      ext2    defaults,errors=remount-ro      0
/dev/hdd3       none            swap    sw                      0       0
proc            /proc           proc    defaults                        0      0
/dev/cdrom      /cdrom          iso9660 defaults,ro,users,noauto               00
/tmp/joefs      /mnt            auto    defaults,users,loop=/dev/loop3

matthias> whoami
matthias
matthias> dd if=/dev/zero of=joefs bs=512 count=1000
1000+0 records in
1000+0 records out
matthias> 
matthias >/sbin/mke2fs /tmp/joefs 
mke2fs 1.27 (8-Mar-2002)
/tmp/joefs is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
64 inodes, 500 blocks
25 blocks (5.00%) reserved for the super user
First data block=1
1 block group
8192 blocks per group, 8192 fragments per group
64 inodes per group

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

matthias> mount /mnt
matthias >ls -l /mnt
total 12
drwx------    2 root     root        12288 Jun 27 13:28 lost+found

Be aware that there are some issues with executables, especially
setuid programs when doing things like this... The defaults protect
you from the worst problems.

 >  I forgot to say in my original post that I didn't want to mount the
 > container or to have to have special privileges to use it.

 >   I want to *manipulate* the container by a normal unprivileged
 > user-land program.

A long time ago, in a galaxy far away there was something called
"userfs" which allowed you to do this. It seems to be dead, possibly
because loopback filesystems do everything userfs did at a nicer (?) 
level of abstraction.

I'm left wondering what on earth you want to do which 

  - you can't do in the normal filesystem, using normal files

  - requires you to generate an ordinary filesystem, i.e. not something
    portable like a tarfile or a pkzip archive

Matthias



More information about the erlang-questions mailing list