[PATCH] mtree should not output size if the file is not a regular file

From: Xin Li <delphij_at_delphij.net>
Date: Mon, 09 Sep 2013 14:35:02 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi,

I think it doesn't make sense to emit size information for non-regular
files like directories, symlinks, etc. although both our and NetBSD's
mtree would emit it.

Comments?

Index: usr.sbin/mtree/create.c
===================================================================
- --- usr.sbin/mtree/create.c	(revision 255424)
+++ usr.sbin/mtree/create.c	(working copy)
_at__at_ -208,7 +208,7 _at__at_ statf(int indent, FTSENT *p)
 		output(indent, &offset, "mode=%#o", p->fts_statp->st_mode & MBITS);
 	if (keys & F_NLINK && p->fts_statp->st_nlink != 1)
 		output(indent, &offset, "nlink=%u", p->fts_statp->st_nlink);
- -	if (keys & F_SIZE)
+	if (keys & F_SIZE && S_ISREG(p->fts_statp->st_mode))
 		output(indent, &offset, "size=%jd",
 		    (intmax_t)p->fts_statp->st_size);
 	if (keys & F_TIME)

Cheers,
- -- 
Xin LI <delphij_at_delphij.net>    https://www.delphij.net/
FreeBSD - The Power to Serve!           Live free or die
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (FreeBSD)

iQEcBAEBCgAGBQJSLj8GAAoJEG80Jeu8UPuzfr4H/RU/qxwVIBAdiXzaD7CvPnCr
3fl+wMIaugYYyZCOWXu1cW4NS8eq5PGPtkJyXCjxGjnyjIpJgZ9XWxZMzdNR4ID0
qLuDOStThE3jjQ/11vx4G4qwsd7iB/BE0O8dfpf68VQu50b40IRl6nDRfHrUETuZ
wYFT+tbm6EiJlNif6Y9XNFJhdAuow3oPEexx6fxv5AUaC9ZeyoSZQdCJoDcfOsXm
gEnB1IJiS5hRXckimvTrq8pjnfj+u6oTAj9U4klAx0yDk6VZuZPIWaYOnPZJr7BR
rVuiRbLFnc2yIPyFFq7y3guqCJpRvOwRuOF/N5vj3qSCYJXmIasXkUjUM6hsxA0=
=hteB
-----END PGP SIGNATURE-----
Received on Mon Sep 09 2013 - 19:35:02 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:41 UTC