lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date: Mon, 15 Jan 2024 16:55:38 +0100
From: Christian Heusel <christian@...sel.eu>
To: Anton Altaparmakov <anton@...era.com>,
	Namjae Jeon <linkinjeon@...nel.org>,
	linux-ntfs-dev@...ts.sourceforge.net,
	linux-kernel@...r.kernel.org
Cc: kernel-janitors@...r.kernel.org,
	Christian Heusel <christian@...sel.eu>
Subject: [PATCH] ntfs: print symbolic error name instead of error code

Utilize the %pe print specifier in multiple log messages to get the
symbolic error name as a string (i.e "-ENOMEM") instead of the error
code to increase the log messages readablility.

This change was suggested in
https://lore.kernel.org/all/92972476-0b1f-4d0a-9951-af3fc8bc6e65@suswa.mountain/

Signed-off-by: Christian Heusel <christian@...sel.eu>
---
 fs/ntfs/dir.c   | 12 ++++--------
 fs/ntfs/index.c |  6 ++----
 fs/ntfs/mft.c   |  6 +++---
 3 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index 629723a8d712..8df4f233969d 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -88,8 +88,7 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
 	/* Get hold of the mft record for the directory. */
 	m = map_mft_record(dir_ni);
 	if (IS_ERR(m)) {
-		ntfs_error(sb, "map_mft_record() failed with error code %ld.",
-				-PTR_ERR(m));
+		ntfs_error(sb, "map_mft_record() failed with error %pe.", m);
 		return ERR_MREF(PTR_ERR(m));
 	}
 	ctx = ntfs_attr_get_search_ctx(dir_ni, m);
@@ -308,8 +307,7 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
 	page = ntfs_map_page(ia_mapping, vcn <<
 			dir_ni->itype.index.vcn_size_bits >> PAGE_SHIFT);
 	if (IS_ERR(page)) {
-		ntfs_error(sb, "Failed to map directory index page, error %ld.",
-				-PTR_ERR(page));
+		ntfs_error(sb, "Failed to map directory index page, error %pe.", page);
 		err = PTR_ERR(page);
 		goto err_out;
 	}
@@ -639,8 +637,7 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
 	/* Get hold of the mft record for the directory. */
 	m = map_mft_record(dir_ni);
 	if (IS_ERR(m)) {
-		ntfs_error(sb, "map_mft_record() failed with error code %ld.",
-				-PTR_ERR(m));
+		ntfs_error(sb, "map_mft_record() failed with error %pe.", m);
 		return ERR_MREF(PTR_ERR(m));
 	}
 	ctx = ntfs_attr_get_search_ctx(dir_ni, m);
@@ -786,8 +783,7 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
 	page = ntfs_map_page(ia_mapping, vcn <<
 			dir_ni->itype.index.vcn_size_bits >> PAGE_SHIFT);
 	if (IS_ERR(page)) {
-		ntfs_error(sb, "Failed to map directory index page, error %ld.",
-				-PTR_ERR(page));
+		ntfs_error(sb, "Failed to map directory index page, error %pe.", page);
 		err = PTR_ERR(page);
 		goto err_out;
 	}
diff --git a/fs/ntfs/index.c b/fs/ntfs/index.c
index d46c2c03a032..777bbd4548ad 100644
--- a/fs/ntfs/index.c
+++ b/fs/ntfs/index.c
@@ -137,8 +137,7 @@ int ntfs_index_lookup(const void *key, const int key_len,
 	/* Get hold of the mft record for the index inode. */
 	m = map_mft_record(base_ni);
 	if (IS_ERR(m)) {
-		ntfs_error(sb, "map_mft_record() failed with error code %ld.",
-				-PTR_ERR(m));
+		ntfs_error(sb, "map_mft_record() failed with code %pe.", m);
 		return PTR_ERR(m);
 	}
 	actx = ntfs_attr_get_search_ctx(base_ni, m);
@@ -264,8 +263,7 @@ int ntfs_index_lookup(const void *key, const int key_len,
 	page = ntfs_map_page(ia_mapping, vcn <<
 			idx_ni->itype.index.vcn_size_bits >> PAGE_SHIFT);
 	if (IS_ERR(page)) {
-		ntfs_error(sb, "Failed to map index page, error %ld.",
-				-PTR_ERR(page));
+		ntfs_error(sb, "Failed to map index page, error %pe.", page);
 		err = PTR_ERR(page);
 		goto err_out;
 	}
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index 6fd1dc4b08c8..fed9abc3ff1f 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -159,7 +159,7 @@ MFT_RECORD *map_mft_record(ntfs_inode *ni)
 
 	mutex_unlock(&ni->mrec_lock);
 	atomic_dec(&ni->count);
-	ntfs_error(ni->vol->sb, "Failed with error code %lu.", -PTR_ERR(m));
+	ntfs_error(ni->vol->sb, "Failed with error %pe.", m);
 	return m;
 }
 
@@ -285,8 +285,8 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref,
 			return ERR_PTR(-EIO);
 		}
 map_err_out:
-		ntfs_error(base_ni->vol->sb, "Failed to map extent "
-				"mft record, error code %ld.", -PTR_ERR(m));
+		ntfs_error(base_ni->vol->sb,
+			   "Failed to map extent mft record, error %pe.", m);
 		return m;
 	}
 	/* Record wasn't there. Get a new ntfs inode and initialize it. */
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ