Blob Blame History Raw
From fdc939f21c5e3c28bb529417de0e20ee3d94c2d8 Mon Sep 17 00:00:00 2001
From: xaizek <xaizek@openmailbox.org>
Date: Fri, 7 Jul 2017 20:25:54 +0300
Subject: [PATCH] Conditionally display device ID in file info
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Check whether major and minor macros are available, they aren't
defined in POSIX.

Thanks to Robert Sarkozi.

Petr Písař: Ported from df383c6adab6342cbb2177527917caed7400b207 to
0.8.2.

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 src/modes/file_info.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/modes/file_info.c b/src/modes/file_info.c
index a541255..b1a9b29 100644
--- a/src/modes/file_info.c
+++ b/src/modes/file_info.c
@@ -316,22 +316,26 @@ show_file_type(FileView *view, int curr_y)
 		const char *const type = (entry->type == FT_CHAR_DEV)
 		                       ? "Character Device"
 		                       : "Block Device";
-		char full_path[PATH_MAX];
-		struct stat st;
 
 		mvwaddstr(menu_win, curr_y, 8, type);
 
-		get_current_full_path(view, sizeof(full_path), full_path);
-		if(os_stat(full_path, &st) == 0)
+#if defined(major) && defined(minor)
 		{
-			char info[64];
+			char full_path[PATH_MAX];
+			struct stat st;
+			get_current_full_path(view, sizeof(full_path), full_path);
+			if(os_stat(full_path, &st) == 0)
+			{
+				char info[64];
 
-			snprintf(info, sizeof(info), "Device Id: 0x%x:0x%x", major(st.st_rdev),
-					minor(st.st_rdev));
+				snprintf(info, sizeof(info), "Device Id: 0x%x:0x%x", major(st.st_rdev),
+						minor(st.st_rdev));
 
-			curr_y += 2;
-			mvwaddstr(menu_win, curr_y, 2, info);
+				curr_y += 2;
+				mvwaddstr(menu_win, curr_y, 2, info);
+			}
 		}
+#endif
 	}
 	else if(entry->type == FT_SOCK)
 	{
-- 
2.20.1