Linux filesystem configuration infrastructure
Jan Kara
jack at suse.cz
Mon Aug 4 11:00:56 EDT 2014
Hello,
On Mon 04-08-14 10:20:35, Sankar P wrote:
> I have a simple filesystem that I did for learning purpose
> https://github.com/psankar/simplefs
>
> Now, I would like to add a few settings to my filesystem (such as the
> number of blocks that should be allocated in an extent by default,
> maximum fragmentation score after which defrag should be automatically
> handled etc.) I would like to have the ability to not just set these
> settings, but export them to a file and restore these settings later.
> Is there some kind of a settings infrastructure code that is available
> in the linux kernel or should I be developing something specific to my
> filesystem ?
>
> I would also like to have some kind of validation system also as part
> of the settings interface. For example: If a setting can accept only
> ints, trying to set a string to that should be disabled, min and max
> values (range) for values of settings, etc.
>
> I googled and found that sysctl interface and the sysfs interfaces
> seem to be doing something similar. But I was not sure which to pick
> as the wikipedia pages were not as elaborate as I would like.
>
> So my question is: Is there a settings infrastructure provided by the
> linux kernel and is any filesystem (or any other kernel components)
> that make use of such a settings infrastrucutre ?
Yes, sysfs or debugfs is the right interface. You can have a look at e.g.
ext4 which handles quite some sysfs attributes in fs/ext4/super.c (look at
ext4_ktype and structures and functions referenced from there).
Honza
--
Jan Kara <jack at suse.cz>
SUSE Labs, CR
More information about the Kernelnewbies
mailing list