svn commit: r240785 - projects/mtree/contrib/mtree

Brooks Davis brooks at FreeBSD.org
Fri Sep 21 19:22:44 UTC 2012


Author: brooks
Date: Fri Sep 21 19:22:43 2012
New Revision: 240785
URL: http://svn.freebsd.org/changeset/base/240785

Log:
  Allow uid and uname or gid and gname to both be printed while
  preserving the behavior of falling back to [ug]id when the name is not
  resolvable.

Modified:
  projects/mtree/contrib/mtree/create.c

Modified: projects/mtree/contrib/mtree/create.c
==============================================================================
--- projects/mtree/contrib/mtree/create.c	Fri Sep 21 19:18:39 2012	(r240784)
+++ projects/mtree/contrib/mtree/create.c	Fri Sep 21 19:22:43 2012	(r240785)
@@ -187,14 +187,14 @@ statf(int indent, FTSENT *p)
 		if (keys & F_UNAME &&
 		    (name = user_from_uid(p->fts_statp->st_uid, 1)) != NULL)
 			output(indent, &offset, "uname=%s", name);
-		else /* if (keys & F_UID) */
+		if (keys & F_UID || (keys & F_UNAME && name == NULL))
 			output(indent, &offset, "uid=%u", p->fts_statp->st_uid);
 	}
 	if (keys & (F_GID | F_GNAME) && p->fts_statp->st_gid != gid) {
 		if (keys & F_GNAME &&
 		    (name = group_from_gid(p->fts_statp->st_gid, 1)) != NULL)
 			output(indent, &offset, "gname=%s", name);
-		else /* if (keys & F_GID) */
+		if (keys & F_GID || (keys & F_GNAME && name == NULL))
 			output(indent, &offset, "gid=%u", p->fts_statp->st_gid);
 	}
 	if (keys & F_MODE && (p->fts_statp->st_mode & MBITS) != mode)
@@ -385,14 +385,14 @@ statd(FTS *t, FTSENT *parent, uid_t *pui
 			if (keys & F_UNAME &&
 			    (name = user_from_uid(saveuid, 1)) != NULL)
 				printf(" uname=%s", name);
-			else /* if (keys & F_UID) */
+			if (keys & F_UID || (keys & F_UNAME && name == NULL))
 				printf(" uid=%lu", (u_long)saveuid);
 		}
 		if (keys & (F_GID | F_GNAME)) {
 			if (keys & F_GNAME &&
 			    (name = group_from_gid(savegid, 1)) != NULL)
 				printf(" gname=%s", name);
-			else /* if (keys & F_UID) */
+			if (keys & F_GID || (keys & F_GNAME && name == NULL))
 				printf(" gid=%lu", (u_long)savegid);
 		}
 		if (keys & F_MODE)


More information about the svn-src-projects mailing list