[PATCH 1/4] fs/mount: add autodetection type support

Sascha Hauer s.hauer at pengutronix.de
Mon Aug 13 14:49:57 EDT 2012


On Sun, Aug 12, 2012 at 08:10:40PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> if NULL is pass as type mount will try to autodetect the filesystem type
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  fs/Kconfig   |    5 +++++
>  fs/fs.c      |   28 ++++++++++++++++++++++++++++
>  include/fs.h |    5 +++++
>  3 files changed, 38 insertions(+)
> 
> diff --git a/fs/Kconfig b/fs/Kconfig
> index b75820f..4c66543 100644
> --- a/fs/Kconfig
> +++ b/fs/Kconfig
> @@ -1,6 +1,11 @@
>  
>  menu "Filesystem support            "
>  
> +config FS
> +	bool
> +	default y
> +	select FILETYPE
> +
>  config FS_AUTOMOUNT
>  	bool
>  
> diff --git a/fs/fs.c b/fs/fs.c
> index 0b376a5..e80d907 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -954,6 +954,28 @@ int register_fs_driver(struct fs_driver_d *fsdrv)
>  }
>  EXPORT_SYMBOL(register_fs_driver);
>  
> +static const char * detect_fs(const char *filename)

static const char *detect_fs(const char *filename)

please

> +{
> +	enum filetype type = file_name_detect_type(filename);
> +	struct driver_d *drv;
> +	struct fs_driver_d *fdrv;
> +
> +	if (type == filetype_unknown)
> +		return NULL;
> +
> +	for_each_driver(drv) {
> +		if (drv->bus != &fs_bus)
> +			continue;
> +
> +		fdrv = drv_to_fs_driver(drv);
> +
> +		if(type == fdrv->type)

if (

> +			return drv->name;
> +	}
> +
> +	return NULL;
> +}
> +
>  /*
>   * Mount a device to a directory.
>   * We do this by registering a new device on which the filesystem
> @@ -985,6 +1007,12 @@ int mount(const char *device, const char *fsname, const char *_path)
>  		}
>  	}
>  
> +	if (!fsname)
> +		fsname = detect_fs(device);
> +
> +	if (!fsname)
> +		return -ENOENT;

Should be -ENODEV I think. At least that's what Linux mount returns in
this case.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list