public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Carlos Maiolino <cem@kernel.org>
Cc: linux-xfs@vger.kernel.org, daan.j.demeyer@gmail.com
Subject: Re: [PATCH 5/5] mkfs: substitute slashes with spaces in protofiles
Date: Wed, 22 Feb 2023 08:37:03 -0800	[thread overview]
Message-ID: <Y/ZEr72HCRLhiZzk@magnolia> (raw)
In-Reply-To: <20230222090303.h6tujm7y32gjhgal@andromeda>

On Wed, Feb 22, 2023 at 10:03:03AM +0100, Carlos Maiolino wrote:
> On Thu, Feb 16, 2023 at 01:53:15PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > 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.

Hmm.  I agree that it /does/ look weird.  I guess we could invent
suboptions for mkfs -p:

   mkfs.xfs -p slashes_are_spaces=1,/tmp/protofile

Which would turn on this odd looking functionalty?  How does that sound?

Sidebar:

As it is now, the slash gets passed to _addname, with the result that
mkfs will error out.

Another thing I (just) remembered is that the proto.c will also pick up
nulls and pass them to addname, so:

   get\000isk.sh ---775 1000 1000 /code/t/fstests/getdisk.sh

will also cause mkfs to fail the format.  I suppose that will also
require patching...

--D

> 
> > Requested-by: Daan De Meyer <daan.j.demeyer@gmail.com>
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >  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

  reply	other threads:[~2023-02-22 16:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16 21:52 [PATCHSET 0/5] xfsprogs: random fixes for 6.2 Darrick J. Wong
2023-02-16 21:52 ` [PATCH 1/5] xfs_spaceman: fix broken -g behavior in freesp command Darrick J. Wong
2023-02-22  8:40   ` Carlos Maiolino
2023-02-16 21:52 ` [PATCH 2/5] xfs_scrub: fix broken realtime free blocks unit conversions Darrick J. Wong
2023-02-22  8:44   ` Carlos Maiolino
2023-02-16 21:53 ` [PATCH 3/5] xfs_io: set fs_path when opening files on foreign filesystems Darrick J. Wong
2023-02-22  8:46   ` Carlos Maiolino
2023-02-16 21:53 ` [PATCH 4/5] xfs_io: fix bmap command not detecting realtime files with xattrs Darrick J. Wong
2023-02-22  8:48   ` Carlos Maiolino
2023-02-16 21:53 ` [PATCH 5/5] mkfs: substitute slashes with spaces in protofiles Darrick J. Wong
2023-02-22  9:03   ` Carlos Maiolino
2023-02-22 16:37     ` Darrick J. Wong [this message]
2023-02-23  8:48       ` Carlos Maiolino
2023-02-23 22:03         ` Darrick J. Wong

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=Y/ZEr72HCRLhiZzk@magnolia \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=daan.j.demeyer@gmail.com \
    --cc=linux-xfs@vger.kernel.org \
    /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