[PATCH 2/2] namei: align missing files with rest of the print out

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <kerolasa@xxxxxx>
---
 misc-utils/namei.c         | 9 +++++++++
 tests/expected/namei/logic | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/misc-utils/namei.c b/misc-utils/namei.c
index a9c8301..1152ea7 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 9632db0..8e217d9 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
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux