From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 26 18:03:34 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F0791106564A for ; Mon, 26 Apr 2010 18:03:34 +0000 (UTC) (envelope-from eitanadlerlist@gmail.com) Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.25]) by mx1.freebsd.org (Postfix) with ESMTP id 87DD08FC26 for ; Mon, 26 Apr 2010 18:03:34 +0000 (UTC) Received: by ey-out-2122.google.com with SMTP id d26so821539eyd.9 for ; Mon, 26 Apr 2010 11:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=uFN6vP8CjQMb6XID4sSA0bnMNBZe5AYRW3PetoG31uo=; b=xYU+nWhEnK8HYLUwWQGgL8N46XUvQ5li7AtdmIsjKvhop3k7gch4Cqfa1uuwcdIwBL 1MIWgVF+xCdb41arNV/xfBa7v3UQs7L+SAxoOkh9HjPwqQlBFfupYK0QOdoJLfi/s5WN leZOcdDyMWYXnLcooghBgvsiB+XcptR0ZY8eo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=JGSqXRUdx7xFfe4mqV+FYxzH6QeG7u11VPw8gMQdm3RmYsPKI5DW0SIQ3ARkEGKOOC HjTnFk3jUWFuOA3xIdYTPfcXd/QFhV6jZBLZrktjIcjw/xEjacSevmoG2SS579kYm4/U VIQvoNtie5/TyFYjWit/H+6LkKjHx9mUoiXuQ= Received: by 10.239.182.204 with SMTP id r12mr399263hbg.193.1272305010821; Mon, 26 Apr 2010 11:03:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.239.193.77 with HTTP; Mon, 26 Apr 2010 10:57:31 -0700 (PDT) From: Eitan Adler Date: Mon, 26 Apr 2010 20:57:31 +0300 Message-ID: To: FreeBSD Hackers Content-Type: text/plain; charset=UTF-8 Subject: [patch] [RFC] pathchk quiet flag X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Apr 2010 18:03:35 -0000 This path adds a -q flag to stop pathchk from outputting error messages but still return an error code. Index: pathchk.c =================================================================== --- pathchk.c (revision 207232) +++ pathchk.c (working copy) @@ -51,18 +51,20 @@ static void usage(void); static int pflag; /* Perform portability checks */ - -int +static int qflag = 0; /* stop pathchk from talking */ main(int argc, char *argv[]) { int ch, rval; const char *arg; - while ((ch = getopt(argc, argv, "p")) > 0) { + while ((ch = getopt(argc, argv, "pq")) > 0) { switch (ch) { case 'p': pflag = 1; break; + case 'q': + qflag = 1; + break; default: usage(); /*NOTREACHED*/ @@ -85,7 +87,7 @@ usage(void) { - fprintf(stderr, "usage: pathchk [-p] pathname ...\n"); + fprintf(stderr, "usage: pathchk [-qp] pathname ...\n"); exit(1); } @@ -118,20 +120,29 @@ *end = '\0'; if (namemax != -1 && complen > namemax) { - warnx("%s: %s: component too long (limit %ld)", path, - p, namemax); + if (!qflag) + { + warnx("%s: %s: component too long (limit %ld)", path, + p, namemax); + } goto bad; } if (!pflag && stat(pathd, &sb) == -1 && errno != ENOENT) { - warn("%s: %.*s", path, (int)(strlen(pathd) - - complen - 1), pathd); + if (!qflag) + { + warn("%s: %.*s", path, (int)(strlen(pathd) - + complen - 1), pathd); + } goto bad; } if (pflag && (badch = portable(p)) >= 0) { - warnx("%s: %s: component contains non-portable " - "character `%c'", path, p, badch); + if (!qflag) + { + warnx("%s: %s: component contains non-portable " + "character `%c'", path, p, badch); + } goto bad; } @@ -158,7 +169,10 @@ } else pathmax = _POSIX_PATH_MAX; if (pathmax != -1 && strlen(path) >= (size_t)pathmax) { - warnx("%s: path too long (limit %ld)", path, pathmax - 1); + if (!qflag) + { + warnx("%s: path too long (limit %ld)", path, pathmax - 1); + } goto bad; }