linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* e2fsprogs: debugfs: set_inode_field fails to set block[IND]...
@ 2014-08-19  4:32 Jun He
  2014-08-19  4:38 ` Darrick J. Wong
  2014-08-19 12:30 ` [PATCH] debugfs: fix set_inode_field block[IND|DIND|TIND] Theodore Ts'o
  0 siblings, 2 replies; 3+ messages in thread
From: Jun He @ 2014-08-19  4:32 UTC (permalink / raw)
  To: linux-ext4

Hi,
I hope this is the right place to report problems of e2fsprogs.

When trying to update block[IND], block[DIND], and block[TIND], it
gives the similar error message:

jhe@node001:~$ sudo debugfs /dev/loop0 -w -R 'set_inode_field
firstfile block[IND] 2'
debugfs 1.42 (29-Nov-2011)
set_inode_field: invalid field specifier: block[IND]

I looked at the code and found the problem in the following code in
find_field() in debugfs/set_fields.c.

    idx = strchr(arg, '[');
    if (idx) {
        *idx++ = 0;
        delim = idx + strlen(idx) - 1;
        if (!*idx || *delim != ']')
            idx = 0;
        else
            *delim = 0;
    }
    /*
     * Can we parse the number?
     */
    if (idx) {
        array_idx = strtol(idx, &tmp, 0);
        if (*tmp)
            idx = 0;
    }


When the field name is something like "block[4]", this works. It sets
'[' and ']' to 0 and converts the number between them.
When the field name is block[IND], it still replaces '[' and ']' with
0. So arg becomes 'block' and will always fail the following test of
  if (strcmp(ss->name, arg) != 0).

One possible fix is to change the max limit for field 'block', use
number to index IND, DIND, and TIND.
Or, name 'block[IND]', 'block[DIND]', and 'block[TIND]' differently
without the '[' ']'. Such as 'block.IND', 'block.DIND', 'block.TIND'.

If it's just a usage problem, please let me know how to use
set_inode_field to set block[IND].. correctly.

Thanks,
Jun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: e2fsprogs: debugfs: set_inode_field fails to set block[IND]...
  2014-08-19  4:32 e2fsprogs: debugfs: set_inode_field fails to set block[IND] Jun He
@ 2014-08-19  4:38 ` Darrick J. Wong
  2014-08-19 12:30 ` [PATCH] debugfs: fix set_inode_field block[IND|DIND|TIND] Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2014-08-19  4:38 UTC (permalink / raw)
  To: Jun He; +Cc: linux-ext4

On Mon, Aug 18, 2014 at 11:32:10PM -0500, Jun He wrote:
> Hi,
> I hope this is the right place to report problems of e2fsprogs.
> 
> When trying to update block[IND], block[DIND], and block[TIND], it
> gives the similar error message:
> 
> jhe@node001:~$ sudo debugfs /dev/loop0 -w -R 'set_inode_field
> firstfile block[IND] 2'
> debugfs 1.42 (29-Nov-2011)
> set_inode_field: invalid field specifier: block[IND]
> 
> I looked at the code and found the problem in the following code in
> find_field() in debugfs/set_fields.c.
> 
>     idx = strchr(arg, '[');
>     if (idx) {
>         *idx++ = 0;
>         delim = idx + strlen(idx) - 1;
>         if (!*idx || *delim != ']')
>             idx = 0;
>         else
>             *delim = 0;
>     }
>     /*
>      * Can we parse the number?
>      */
>     if (idx) {
>         array_idx = strtol(idx, &tmp, 0);
>         if (*tmp)
>             idx = 0;
>     }
> 
> 
> When the field name is something like "block[4]", this works. It sets
> '[' and ']' to 0 and converts the number between them.
> When the field name is block[IND], it still replaces '[' and ']' with
> 0. So arg becomes 'block' and will always fail the following test of
>   if (strcmp(ss->name, arg) != 0).
> 
> One possible fix is to change the max limit for field 'block', use
> number to index IND, DIND, and TIND.
> Or, name 'block[IND]', 'block[DIND]', and 'block[TIND]' differently
> without the '[' ']'. Such as 'block.IND', 'block.DIND', 'block.TIND'.
> 
> If it's just a usage problem, please let me know how to use
> set_inode_field to set block[IND].. correctly.

Seems pretty broken to me.  I'll review any patch you send. :)

FWIW, I've been using modify_inode to mess with those fields.

Not that either command does much good for an extent files.

--D
> 
> Thanks,
> Jun
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] debugfs: fix set_inode_field block[IND|DIND|TIND]
  2014-08-19  4:32 e2fsprogs: debugfs: set_inode_field fails to set block[IND] Jun He
  2014-08-19  4:38 ` Darrick J. Wong
@ 2014-08-19 12:30 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2014-08-19 12:30 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: jhe, Theodore Ts'o

After we determine that we can't parse the array value as an integer,
we need to restore the square brackets to the field name, so that we
can find a match with block[IND], block[DIND], and block[TIND] in the
inode field table.

Reported-by: Jun He <jhe@cs.wisc.edu>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 debugfs/set_fields.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/debugfs/set_fields.c b/debugfs/set_fields.c
index 40dc5e7..6104b2b 100644
--- a/debugfs/set_fields.c
+++ b/debugfs/set_fields.c
@@ -321,8 +321,11 @@ static struct field_set_info *find_field(struct field_set_info *fields,
 	 */
 	if (idx) {
 		array_idx = strtol(idx, &tmp, 0);
-		if (*tmp)
+		if (*tmp) {
+			*(--idx) = '[';
+			*delim = ']';
 			idx = 0;
+		}
 	}
 
 	/*
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-19 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-19  4:32 e2fsprogs: debugfs: set_inode_field fails to set block[IND] Jun He
2014-08-19  4:38 ` Darrick J. Wong
2014-08-19 12:30 ` [PATCH] debugfs: fix set_inode_field block[IND|DIND|TIND] Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).