From: Sami Kerola Date: Wed, 20 Nov 2013 00:57:04 +0000 (+0000) Subject: namei: align missing files with rest of the print out X-Git-Tag: v2.25-rc1~712 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd80445017fcc845eebed534782c6e7f13ef8480;p=thirdparty%2Futil-linux.git namei: align missing files with rest of the print out This change should make namei output more readable when multiple arguments are supplied. The old: $ namei -l /usr/foo f: /usr/foo drwxr-xr-x root root / drwxr-xr-x root root usr foo - No such file or directory The new: $ namei -l /usr/foo f: /usr/foo drwxr-xr-x root root / drwxr-xr-x root root usr foo - No such file or directory Signed-off-by: Sami Kerola --- diff --git a/misc-utils/namei.c b/misc-utils/namei.c index a9c83011fa..1152ea7642 100644 --- a/misc-utils/namei.c +++ b/misc-utils/namei.c @@ -367,6 +367,15 @@ print_namei(struct namei *nm, char *path) char md[11]; if (nm->noent) { + int blanks = 1; + if (flags & NAMEI_MODES) + blanks += 9; + if (flags & NAMEI_OWNERS) + blanks += uwidth + gwidth + 2; + if (!(flags & NAMEI_VERTICAL)) + blanks += 1; + blanks += nm->level * 2; + printf("%*s ", blanks, ""); printf(_("%s - No such file or directory\n"), nm->name); return -1; } diff --git a/tests/expected/namei/logic b/tests/expected/namei/logic index 9632db0a9a..8e217d973a 100644 --- a/tests/expected/namei/logic +++ b/tests/expected/namei/logic @@ -10,4 +10,4 @@ f: namei1/namei2/a/b d namei1 d namei2 - a -b - No such file or directory + b - No such file or directory