public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 2/2] namei: align missing files with rest of the print out
Date: Wed, 20 Nov 2013 00:57:04 +0000	[thread overview]
Message-ID: <1384909024-562-2-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1384909024-562-1-git-send-email-kerolasa@iki.fi>

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@iki.fi>
---
 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


       reply	other threads:[~2013-11-20  0:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1384909024-562-1-git-send-email-kerolasa@iki.fi>
2013-11-20  0:57 ` Sami Kerola [this message]
2013-12-02 10:11   ` [PATCH 2/2] namei: align missing files with rest of the print out Karel Zak
2013-12-02 10:11 ` [PATCH 1/2] losetup, agetty: remove unnecessary if's before free() Karel Zak

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=1384909024-562-2-git-send-email-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@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