[PATCH 3/4] hardlink: fix 0-sized file processing

наб <[email protected]>
Newsgroups org.kernel.vger.util-linux
Message-ID <6a5c5b7ea8a584bdec6c82c5d1277fab6ebe4e54.1730139540.git.nabijaczleweli@nabijaczleweli.xyz>
The manual says that -s0 will process 0-sized files normally,
but as it stands (a) hardlink considers 0-sized files unlinkable
(so, with -l, unlistable) and (b) fileeq considers reading an empty
prologue to be an error
---
 lib/fileeq.c          | 2 +-
 misc-utils/hardlink.c | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/fileeq.c b/lib/fileeq.c
index b40eba2b0..1f7f90ccb 100644
--- a/lib/fileeq.c
+++ b/lib/fileeq.c
@@ -465,7 +465,7 @@ static ssize_t get_intro(struct ul_fileeq *eq, struct ul_fileeq_data *data,
 			return -1;
 		rsz = read_all(fd, (char *) data->intro, sizeof(data->intro));
 		DBG(DATA, ul_debugobj(data, " read %zu bytes intro", sizeof(data->intro)));
-		if (rsz <= 0)
+		if (rsz < 0)
 			return -1;
 		data->nblocks = 1;
 	}
diff --git a/misc-utils/hardlink.c b/misc-utils/hardlink.c
index 643df7cf2..8c5f24aad 100644
--- a/misc-utils/hardlink.c
+++ b/misc-utils/hardlink.c
@@ -649,8 +649,7 @@ static int file_xattrs_equal(const struct file *a, const struct file *b)
  */
 static int file_may_link_to(const struct file *a, const struct file *b)
 {
-	return (a->st.st_size != 0 &&
-		a->st.st_size == b->st.st_size &&
+	return (a->st.st_size == b->st.st_size &&
 		a->links != NULL && b->links != NULL &&
 		a->st.st_dev == b->st.st_dev &&
 		a->st.st_ino != b->st.st_ino &&
-- 
2.39.2
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmcf1bUACgkQvP0LAY0m
WPH7Dw//SxP1aetzycX4z1bEb01Z5M5R9NYKt4oMAmGp3xCGwaOheA4o6mkK42b5
mOUPzUa7Q/rdAmS5/8rSHi/358Z0gkAKdEZa6Lz1T82MOkoJLNzvVZXS1YlYX7vt
SI1V+4IKb8nUdEvA/4Ej4NC+xJi14yhLr4MsIZG+AFVhvrNa8av5sRYjAIeS6iKM
SvGMeRvD6iQDzDWxxZ8ywEOi4J1nOto+XsQoa6zS79VqqF5suwnt9omsMfeNwZb3
siqAuD3QHnvWn2rqIkXeMgJjfGY+HNHgayEUxKvXNWJFHj7ZoIe3F99QMM3P77lj
7yCALoPxUEmql10F243h8YLztYcWYpPcLaDYsmKNLIErEg4JkzeG89XiBgXm3wtG
p7UrYY+G/T2tCUNz0D5GYqk6CU7pMD4Eb0qHKebfMO4S56tGnsUA6XmSnJbWCzqd
6yjdDfnYk2v3RdcV7t3mMoqJWI6EQpPpF8Pnu5LQLRlz6tf5heJ3DWocuDhmia52
4RYZC/F2DloEWzcbCHy0z6PupJQ5p/NFRoFMze5rlHGefc6LOwfr1b35U+HPw176
8eG7hJGXi/fIR+uy9akbooHgLhWTZCk7XOawpqQey0XJgAe259e0zg6JI1gS+ff6
sXXgTjoNaOIxezQv8oiibyFOgFiKaPKeemhn46WszBEskKp5DMk=
=y3Uy
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.