public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 11/17] fs: add mkdir interface
Date: Tue, 24 Jul 2018 09:56:19 +0900	[thread overview]
Message-ID: <20180724005618.GW11258@linaro.org> (raw)
In-Reply-To: <ad5d0bb1-1d01-a29d-c37f-79459aa10ad9@gmx.de>

On Fri, Jul 20, 2018 at 07:35:18PM +0200, Heinrich Schuchardt wrote:
> On 07/20/2018 04:57 AM, AKASHI Takahiro wrote:
> > "mkdir" interface is added to file operations.
> > This is a preparatory change as mkdir support for FAT file system
> > will be added in next patch.
> > 
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> >  fs/fs.c      | 45 +++++++++++++++++++++++++++++++++++++++++++++
> >  include/fs.h | 10 ++++++++++
> >  2 files changed, 55 insertions(+)
> > 
> > diff --git a/fs/fs.c b/fs/fs.c
> > index 33808d549e..3cb6b21fe9 100644
> > --- a/fs/fs.c
> > +++ b/fs/fs.c
> > @@ -105,6 +105,11 @@ static inline int fs_opendir_unsupported(const char *filename,
> >  	return -EACCES;
> >  }
> >  
> > +static inline int fs_mkdir_unsupported(const char *dirname)
> > +{
> > +	return -1;
> > +}
> > +
> >  struct fstype_info {
> >  	int fstype;
> >  	char *name;
> > @@ -142,6 +147,7 @@ struct fstype_info {
> >  	int (*readdir)(struct fs_dir_stream *dirs, struct fs_dirent **dentp);
> >  	/* see fs_closedir() */
> >  	void (*closedir)(struct fs_dir_stream *dirs);
> > +	int (*mkdir)(const char *dirname);
> >  };
> >  
> >  static struct fstype_info fstypes[] = {
> > @@ -165,6 +171,7 @@ static struct fstype_info fstypes[] = {
> >  		.opendir = fat_opendir,
> >  		.readdir = fat_readdir,
> >  		.closedir = fat_closedir,
> > +		.mkdir = fs_mkdir_unsupported,
> 
> Why should we create a dummy function? Just use NULL as an indicator

because I followed coding style of the existing code here.

> that the interface method is not implemented. See the use of structures
> for the driver model.

Can any file system ever be based on driver model?

> @Simon
> The array fstypes[] should be replaced by a linker list to match the
> driver model.
> 
> >  	},
> >  #endif
> >  #ifdef CONFIG_FS_EXT4
> > @@ -185,6 +192,7 @@ static struct fstype_info fstypes[] = {
> >  #endif
> >  		.uuid = ext4fs_uuid,
> >  		.opendir = fs_opendir_unsupported,
> > +		.mkdir = fs_mkdir_unsupported,
> >  	},
> >  #endif
> >  #ifdef CONFIG_SANDBOX
> > @@ -201,6 +209,7 @@ static struct fstype_info fstypes[] = {
> >  		.write = fs_write_sandbox,
> >  		.uuid = fs_uuid_unsupported,
> >  		.opendir = fs_opendir_unsupported,
> > +		.mkdir = fs_mkdir_unsupported,
> >  	},
> >  #endif
> >  #ifdef CONFIG_CMD_UBIFS
> > @@ -217,6 +226,7 @@ static struct fstype_info fstypes[] = {
> >  		.write = fs_write_unsupported,
> >  		.uuid = fs_uuid_unsupported,
> >  		.opendir = fs_opendir_unsupported,
> > +		.mkdir = fs_mkdir_unsupported,
> >  	},
> >  #endif
> >  #ifdef CONFIG_FS_BTRFS
> > @@ -233,6 +243,7 @@ static struct fstype_info fstypes[] = {
> >  		.write = fs_write_unsupported,
> >  		.uuid = btrfs_uuid,
> >  		.opendir = fs_opendir_unsupported,
> > +		.mkdir = fs_mkdir_unsupported,
> >  	},
> >  #endif
> >  	{
> > @@ -248,6 +259,7 @@ static struct fstype_info fstypes[] = {
> >  		.write = fs_write_unsupported,
> >  		.uuid = fs_uuid_unsupported,
> >  		.opendir = fs_opendir_unsupported,
> > +		.mkdir = fs_mkdir_unsupported,
> >  	},
> >  };
> >  
> > @@ -498,6 +510,20 @@ void fs_closedir(struct fs_dir_stream *dirs)
> >  }
> >  
> >  
> > +int fs_mkdir(const char *dirname)
> > +{
> > +	int ret;
> > +
> > +	struct fstype_info *info = fs_get_info(fs_type);
> > +
> > +	ret = info->mkdir(dirname);
> 
> Please, check if mkdir is NULL before calling.

No other place checks for NULL. Is this really required?

> > +
> > +	fs_type = FS_TYPE_ANY;
> > +	fs_close();
> 
> What do you want to close here if mkdir() is not implemented by the file
> system?

I'm not quite confident here but ->close() be paired with ->probe(),
which is set to be called in fs_set_blk_dev().

Thanks,
-Takahiro AKASHI


> Best regards
> 
> Heinrich
> 
> > +
> > +	return ret;
> > +}
> > +
> >  int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
> >  		int fstype)
> >  {
> > @@ -700,3 +726,22 @@ int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >  	return CMD_RET_SUCCESS;
> >  }
> >  
> > +int do_mkdir(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
> > +								int fstype)
> > +{
> > +	int ret;
> > +
> > +	if (argc != 4)
> > +		return CMD_RET_USAGE;
> > +
> > +	if (fs_set_blk_dev(argv[1], argv[2], fstype))
> > +		return 1;
> > +
> > +	ret = fs_mkdir(argv[3]);
> > +	if (ret) {
> > +		printf("** Unable to create a directory \"%s\" **\n", argv[3]);
> > +		return 1;
> > +	}
> > +
> > +	return 0;
> > +}
> > diff --git a/include/fs.h b/include/fs.h
> > index 163da103b4..fbaee154dd 100644
> > --- a/include/fs.h
> > +++ b/include/fs.h
> > @@ -155,6 +155,14 @@ struct fs_dirent *fs_readdir(struct fs_dir_stream *dirs);
> >   */
> >  void fs_closedir(struct fs_dir_stream *dirs);
> >  
> > +/*
> > + * fs_mkdir - Create a directory
> > + *
> > + * @filename: Name of directory to create
> > + * @return 0 on success, -1 on error conditions
> > + */
> > +int fs_mkdir(const char *filename);
> > +
> >  /*
> >   * Common implementation for various filesystem commands, optionally limited
> >   * to a specific filesystem type via the fstype parameter.
> > @@ -169,6 +177,8 @@ int file_exists(const char *dev_type, const char *dev_part, const char *file,
> >  		int fstype);
> >  int do_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
> >  		int fstype);
> > +int do_mkdir(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
> > +		int fstype);
> >  
> >  /*
> >   * Determine the UUID of the specified filesystem and print it. Optionally it is
> > 
> 

  parent reply	other threads:[~2018-07-24  0:56 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20  2:57 [U-Boot] [PATCH 00/17] fs: fat: extend FAT write operations AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 01/17] fs: fat: extend get_fs_info() for write use AKASHI Takahiro
2018-07-20 18:06   ` Heinrich Schuchardt
2018-07-22  7:43     ` Heinrich Schuchardt
2018-07-20  2:57 ` [U-Boot] [PATCH 02/17] fs: fat: handle "." and ".." of root dir correctly with fat_itr_resolve() AKASHI Takahiro
2018-07-20 18:09   ` Heinrich Schuchardt
2018-07-23  7:55     ` AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 03/17] fs: fat: make directory iterator global for write use AKASHI Takahiro
2018-07-20 18:02   ` Heinrich Schuchardt
2018-07-23  8:06     ` AKASHI Takahiro
2018-07-23  8:18       ` AKASHI Takahiro
2018-08-11 13:34   ` Heinrich Schuchardt
2018-08-20  4:45     ` AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 04/17] fs: fat: assure iterator's ->dent belongs to ->clust AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 05/17] fs: fat: check and normailze file name AKASHI Takahiro
2018-07-31  4:31   ` Heinrich Schuchardt
2018-07-20  2:57 ` [U-Boot] [PATCH 06/17] fs: fat: write returns error code instead of -1 AKASHI Takahiro
2018-07-20 17:55   ` Heinrich Schuchardt
2018-07-23  8:32     ` AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 07/17] fs: fat: support write with sub-directory path AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 08/17] fs: fat: refactor write interface for a file offset AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 09/17] fs: fat: support write with non-zero offset AKASHI Takahiro
2018-07-20 17:46   ` Heinrich Schuchardt
2018-07-23  8:41     ` AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 10/17] cmd: fat: add offset parameter to fatwrite AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 11/17] fs: add mkdir interface AKASHI Takahiro
2018-07-20 17:35   ` Heinrich Schuchardt
2018-07-23 23:48     ` Simon Glass
2018-07-23 23:56       ` Tom Rini
2018-07-24  1:45         ` AKASHI Takahiro
2018-07-25  2:45           ` Simon Glass
2018-07-24  0:56     ` AKASHI Takahiro [this message]
2018-07-20  2:57 ` [U-Boot] [PATCH 12/17] fs: fat: remember the starting cluster number of directory AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 13/17] fs: fat: support mkdir AKASHI Takahiro
2018-07-20 17:14   ` Heinrich Schuchardt
2018-07-24  2:01     ` AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 14/17] cmd: fat: add fatmkdir command AKASHI Takahiro
2018-07-20 17:09   ` Heinrich Schuchardt
2018-07-24  2:07     ` AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 15/17] efi_loader: file: support creating a directory AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 16/17] efi_loader: implement a pseudo "file delete" AKASHI Takahiro
2018-07-20  2:57 ` [U-Boot] [PATCH 17/17] fs-test: fix false positive error at Test Case 12 AKASHI Takahiro
2018-07-29  7:02   ` Heinrich Schuchardt
2018-07-31  7:55     ` AKASHI Takahiro
2018-07-20  9:48 ` [U-Boot] [PATCH 00/17] fs: fat: extend FAT write operations Heinrich Schuchardt
2018-07-22  6:44   ` Heinrich Schuchardt
2018-07-23  7:35     ` AKASHI Takahiro
2018-07-23 14:46     ` Tom Rini
2018-08-06 22:34       ` Heinrich Schuchardt
2018-08-07  5:38         ` AKASHI Takahiro
2018-08-07  5:52           ` AKASHI Takahiro
2018-08-07  5:53           ` Heinrich Schuchardt

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=20180724005618.GW11258@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    /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