Message ID | 1482347505-11200-1-git-send-email-samuel.voss@rockwellcollins.com |
---|---|
State | Rejected, archived |
Headers | show |
On Wed, Dec 21, 2016 at 01:11:45PM -0600, Samuel Voss wrote: > From: Clayton Shotwell <clayton.shotwell@rockwellcollins.com> > > The recent modification to the "ls -p" function can print out characters > that the other ls functions do not print out. Adding a slight change to > use the same print function for all of the ls options. > > Signed-off-by: Clayton Shotwell <clayton.shotwell@rockwellcollins.com> > Signed-off-by: Samuel Voss <samuel.voss@rockwellcollins.com> This was deliberate. The "-p" option for debugfs's ls command is intended for used when piping to a shell script, and the use of '/' is because it is _rare_ for that character to show up file names. If I were doing it all over again (ls -p has been around for a very long time), I'd use the just-added print_c_string() function in which encodes special characters using C strings (e.g., \001\000\n\t, etc.) and then use an unencoded "RS" ASCII character (\036) as the record separator between each field. But since there are existing shell/perl/python scripts and other programs out there depending on the output of debugfs's ls -p, I don't want to change the output at this point. Cheers, - Ted
diff --git a/debugfs/ls.c b/debugfs/ls.c index 057e3f6..cb40627 100644 --- a/debugfs/ls.c +++ b/debugfs/ls.c @@ -122,8 +122,10 @@ static int list_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)), 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, thislen, dirent->name); + fprintf(ls->f,"/%u/%06o/%d/%d/", ino, inode.i_mode, + inode.i_uid, inode.i_gid); + print_filename(ls->f, dirent, options); + fputc('/', ls->f); if (LINUX_S_ISDIR(inode.i_mode)) fprintf(ls->f, "/"); else