From owner-p4-projects@FreeBSD.ORG Sat Sep 17 23:24:31 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DDDAB16A421; Sat, 17 Sep 2005 23:24:30 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6F7E16A41F for ; Sat, 17 Sep 2005 23:24:30 +0000 (GMT) (envelope-from csjp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4C38343D6A for ; Sat, 17 Sep 2005 23:24:28 +0000 (GMT) (envelope-from csjp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j8HNOSDe072865 for ; Sat, 17 Sep 2005 23:24:28 GMT (envelope-from csjp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j8HNOSOK072862 for perforce@freebsd.org; Sat, 17 Sep 2005 23:24:28 GMT (envelope-from csjp@freebsd.org) Date: Sat, 17 Sep 2005 23:24:28 GMT Message-Id: <200509172324.j8HNOSOK072862@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to csjp@freebsd.org using -f From: "Christian S.J. Peron" To: Perforce Change Reviews Cc: Subject: PERFORCE change 83801 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Sep 2005 23:24:31 -0000 http://perforce.freebsd.org/chv.cgi?CH=83801 Change 83801 by csjp@csjp_xor on 2005/09/17 23:24:26 Introduce -f flag which, if an object has no checksum associated with it, will trigger the calculation and storage of the checksum by the kernel. Affected files ... .. //depot/projects/trustedbsd/mac/usr.sbin/getfhash/getfhash.c#15 edit Differences ... ==== //depot/projects/trustedbsd/mac/usr.sbin/getfhash/getfhash.c#15 (text+ko) ==== @@ -51,6 +51,7 @@ static int eval; static int dflag; +static int fflag; static int rflag; static char *mflag; static int Wflag; @@ -216,9 +217,15 @@ u_char digest[64]; int (*checksum)(const char *, u_char *); +again: error = extattr_get_file(pathname, MAC_CHKEXEC_ATTRN, MAC_CHKEXEC, (void *)&sum, sizeof(sum)); - if (error < 0) { + if (error < 0 && errno == ENOATTR && fflag) { + if (syscall(SYS_mac_syscall, "mac_chkexec", 0, pathname) < 0) + warn("%s", pathname); + else + goto again; + } else if (error < 0) { warn("%s", pathname); return; } @@ -279,11 +286,14 @@ handler = print_hash; else errx(1, "what program am I supposed to be?"); - while ((ch = getopt(argc, argv, "dhm:rW")) != -1) + while ((ch = getopt(argc, argv, "dfhm:rW")) != -1) switch(ch) { case 'd': dflag++; break; + case 'f': + fflag++; + break; case 'm': mflag = optarg; break;