From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH] debugfs: initialize inode to 0 in list_dir_proc() if no inode nr
Date: Fri, 16 Sep 2011 20:36:02 -0500 [thread overview]
Message-ID: <4E73F982.3020806@redhat.com> (raw)
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;
next reply other threads:[~2011-09-17 1:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-17 1:36 Eric Sandeen [this message]
2011-09-25 4:50 ` [PATCH] debugfs: initialize inode to 0 in list_dir_proc() if no inode nr Ted Ts'o
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=4E73F982.3020806@redhat.com \
--to=sandeen@redhat.com \
--cc=linux-ext4@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;
as well as URLs for NNTP newsgroup(s).