All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlos Maiolino <cmaiolino@redhat.com>
To: Brian Foster <bfoster@redhat.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] xfs_io: implement 'inode' command V6
Date: Mon, 22 Feb 2016 11:25:30 +0100	[thread overview]
Message-ID: <20160222102530.GA3060@redhat.com> (raw)
In-Reply-To: <20160219175508.GD27263@bfoster.bfoster>

Hey,

> > +	if (optind < argc) {
> > +
> > +		if (ret_next) {
> > +			cmd = XFS_IOC_FSBULKSTAT;
> > +		} else {
> > +			if (argc > 2)
> > +				return command_usage(&inode_cmd);
> 
> FYI, this means one can't do the following:
> 
>   xfs_io -c "inode -v 123" <mnt>
> 
> Otherwise it looks good to me:
> 
> Reviewed-by: Brian Foster <bfoster@redhat.com>
> 
Thanks, I'm not sure how I didn't notice this, I thought I had tested all
options with verbose mode.

I believe I can fix this with this:

-                       if (argc > 2)
+                       if (argc > 2 && !verbose)

I must check the amount of arguments, so nobody can pass 2 inode numbers. Bu I
believe with this change I can fix it.

I'm testing it right now, and will send a patch with this change after I test
all the remaining options.

Cheers
> > +			else
> > +				cmd = XFS_IOC_FSBULKSTAT_SINGLE;
> > +		}
> > +
> > +		userino = strtoull(argv[optind], &p, 10);
> > +		if ((*p != '\0')) {
> > +			printf(_("[num] must be a numeric value\n"));
> > +			exitcode = 1;
> > +			return 0;
> > +		}
> > +
> > +		bulkreq.lastip = &userino;
> > +		bulkreq.icount = 1;
> > +		bulkreq.ubuffer = &bstat;
> > +		bulkreq.ocount = &count;
> > +
> > +		if (xfsctl(file->name, file->fd, cmd, &bulkreq)) {
> > +			if (errno == EINVAL) {
> > +				if (!ret_next)
> > +					printf("0\n");
> > +			} else {
> > +				perror("xfsctl");
> > +			}
> > +			exitcode = 1;
> > +			return 0;
> > +		}
> > +
> > +		if (ret_next)
> > +			userino = bstat.bs_ino;
> > +
> > +		if (verbose)
> > +			printf("%llu:%d\n",
> > +			       userino,
> > +			       userino > XFS_MAXINUMBER_32 ? 64 : 32);
> > +		else
> > +			/* Inode in use */
> > +			printf("%llu\n", userino);
> > +		return 0;
> > +
> > +	/* -n option must not be used stand alone */
> > +	} else if (ret_next) {
> > +		return command_usage(&inode_cmd);
> > +	}
> > +
> > +	bulkreq.lastip = &last;
> > +	bulkreq.icount = 1024; /* User-defined maybe!? */
> > +	bulkreq.ubuffer = &igroup;
> > +	bulkreq.ocount = &count;
> > +
> > +	for (;;) {
> > +		if (xfsctl(file->name, file->fd, XFS_IOC_FSINUMBERS,
> > +				&bulkreq)) {
> > +			perror("XFS_IOC_FSINUMBERS");
> > +			exitcode = 1;
> > +			return 0;
> > +		}
> > +
> > +		if (count == 0)
> > +			break;
> > +
> > +		lastgrp = count;
> > +	}
> > +
> > +	lastgrp--;
> > +	lastino = igroup[lastgrp].xi_startino +
> > +		  xfs_highbit64(igroup[lastgrp].xi_allocmask);
> > +
> > +	if (verbose)
> > +		printf("%llu:%d\n", lastino,
> > +			lastino > XFS_MAXINUMBER_32 ? 64 : 32);
> > +	else
> > +		printf("%d\n", lastino > XFS_MAXINUMBER_32 ? 1 : 0);
> > +
> > +	return 0;
> > +}
> > +
> >  void
> >  open_init(void)
> >  {
> > @@ -815,6 +954,16 @@ open_init(void)
> >  		_("get/set preferred extent size (in bytes) for the open file");
> >  	extsize_cmd.help = extsize_help;
> >  
> > +	inode_cmd.name = "inode";
> > +	inode_cmd.cfunc = inode_f;
> > +	inode_cmd.args = _("[-n | -v] [num]");
> > +	inode_cmd.argmin = 0;
> > +	inode_cmd.argmax = 2;
> > +	inode_cmd.flags = CMD_NOMAP_OK;
> > +	inode_cmd.oneline =
> > +		_("Query inode number usage in the filesystem");
> > +	inode_cmd.help = inode_help;
> > +
> >  	add_command(&open_cmd);
> >  	add_command(&stat_cmd);
> >  	add_command(&close_cmd);
> > @@ -822,4 +971,5 @@ open_init(void)
> >  	add_command(&chproj_cmd);
> >  	add_command(&lsproj_cmd);
> >  	add_command(&extsize_cmd);
> > +	add_command(&inode_cmd);
> >  }
> > -- 
> > 2.4.3
> > 
> > _______________________________________________
> > xfs mailing list
> > xfs@oss.sgi.com
> > http://oss.sgi.com/mailman/listinfo/xfs

-- 
Carlos

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

      reply	other threads:[~2016-02-22 10:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-18 16:49 [PATCH] xfs_io: implement 'inode' command V6 Carlos Maiolino
2016-02-18 17:02 ` Bill O'Donnell
2016-02-19 17:55 ` Brian Foster
2016-02-22 10:25   ` Carlos Maiolino [this message]

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=20160222102530.GA3060@redhat.com \
    --to=cmaiolino@redhat.com \
    --cc=bfoster@redhat.com \
    --cc=xfs@oss.sgi.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.