All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] debugfs: initialize inode to 0 in list_dir_proc() if no inode nr
@ 2011-09-17  1:36 Eric Sandeen
  2011-09-25  4:50 ` Ted Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Sandeen @ 2011-09-17  1:36 UTC (permalink / raw)
  To: ext4 development

If (!ino), the inode will be uninitialized when we print it
in the PARSE_OPT case.

So do the same as the LONG_OPT case, and memset it to 0 if
(!ino).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/debugfs/ls.c b/debugfs/ls.c
index e01fd20..f21e96e 100644
--- a/debugfs/ls.c
+++ b/debugfs/ls.c
@@ -73,15 +73,18 @@ static int list_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)),
 		lbr = rbr = ' ';
 	}
 	if (ls->options & PARSE_OPT) {
-		if (ino && debugfs_read_inode(ino, &inode, name)) return 0;
+		if (ino) {
+			if (debugfs_read_inode(ino, &inode, name))
+				return 0;
+		} else
+			memset(&inode, 0, sizeof(struct ext2_inode));
 		fprintf(ls->f,"/%u/%06o/%d/%d/%s/",ino,inode.i_mode,inode.i_uid, inode.i_gid,name);
 		if (LINUX_S_ISDIR(inode.i_mode))
 			fprintf(ls->f, "/");
 		else
 			fprintf(ls->f, "%lld/", EXT2_I_SIZE(&inode));
 		fprintf(ls->f, "\n");
-	}
-	else if (ls->options & LONG_OPT) {
+	} else if (ls->options & LONG_OPT) {
 		if (ino) {
 			if (debugfs_read_inode(ino, &inode, name))
 				return 0;


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

* Re: [PATCH] debugfs: initialize inode to 0 in list_dir_proc() if no inode nr
  2011-09-17  1:36 [PATCH] debugfs: initialize inode to 0 in list_dir_proc() if no inode nr Eric Sandeen
@ 2011-09-25  4:50 ` Ted Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Ted Ts'o @ 2011-09-25  4:50 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: ext4 development

On Fri, Sep 16, 2011 at 08:36:02PM -0500, Eric Sandeen wrote:
> If (!ino), the inode will be uninitialized when we print it
> in the PARSE_OPT case.
> 
> So do the same as the LONG_OPT case, and memset it to 0 if
> (!ino).
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Applied, thanks

					- Ted

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

end of thread, other threads:[~2011-09-25  4:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-17  1:36 [PATCH] debugfs: initialize inode to 0 in list_dir_proc() if no inode nr Eric Sandeen
2011-09-25  4:50 ` Ted Ts'o

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.