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

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

 



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

Attachment: signature.asc
Description: PGP signature


[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