Whamcloud - gitweb
debugfs: initialize inode to 0 in list_dir_proc() if no inode nr
authorEric Sandeen <sandeen@redhat.com>
Sun, 25 Sep 2011 04:49:58 +0000 (00:49 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 25 Sep 2011 05:55:28 +0000 (01:55 -0400)
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>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/ls.c

index ed75fd1..b4036de 100644 (file)
@@ -74,15 +74,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;