Re: [PATCH 5/5] mkfs: substitute slashes with spaces in protofiles

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 16, 2023 at 01:53:15PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@xxxxxxxxxx>
> 
> A user requested the ability to specify directory entry names in a
> protofile that have spaces in them.  The protofile format itself does
> not allow spaces (yay 1973-era protofiles!) but it does allow slashes.
> Slashes aren't allowed in directory entry names, so we'll permit this
> one gross hack.
> 
> /
> 0 0
> d--775 1000 1000
> : Descending path /code/t/fstests
>  get/isk.sh   ---775 1000 1000 /code/t/fstests/getdisk.sh
> $
> 
> Will produce "get isk.h" in the root directory.
> 

While I don't really mind this patch, it seems strange to me to simply replace a
slash with a space in lieu of failing the prototype with an 'invalid character'
error message, or something like that.
With this patch, an user could be mistakenly assuming the get/isk.sh path will
be created, and instead, what's gonna be created is a file with a space.
I don't really mind it, but I think we could be misleading users.


> Requested-by: Daan De Meyer <daan.j.demeyer@xxxxxxxxx>
> Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
> ---
>  mkfs/proto.c |   23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/mkfs/proto.c b/mkfs/proto.c
> index 68ecdbf3632..bf8de0189db 100644
> --- a/mkfs/proto.c
> +++ b/mkfs/proto.c
> @@ -171,6 +171,27 @@ getstr(
>  	return NULL;
>  }
> 
> +/* Extract directory entry name from a protofile. */
> +static char *
> +getdirentname(
> +	char	**pp)
> +{
> +	char	*p = getstr(pp);
> +	char	*c = p;
> +
> +	if (!p)
> +		return NULL;
> +
> +	/* Replace slash with space because slashes aren't allowed. */
> +	while (*c) {
> +		if (*c == '/')
> +			*c = ' ';
> +		c++;
> +	}
> +
> +	return p;
> +}
> +
>  static void
>  rsvfile(
>  	xfs_mount_t	*mp,
> @@ -580,7 +601,7 @@ parseproto(
>  			rtinit(mp);
>  		tp = NULL;
>  		for (;;) {
> -			name = getstr(pp);
> +			name = getdirentname(pp);
>  			if (!name)
>  				break;
>  			if (strcmp(name, "$") == 0)
> 

-- 
Carlos Maiolino



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux