From owner-svn-src-stable-8@FreeBSD.ORG Sun Mar 28 11:22:39 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F389106566B; Sun, 28 Mar 2010 11:22:39 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2E2B48FC18; Sun, 28 Mar 2010 11:22:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2SBMdws006807; Sun, 28 Mar 2010 11:22:39 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2SBMduE006805; Sun, 28 Mar 2010 11:22:39 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201003281122.o2SBMduE006805@svn.freebsd.org> From: Jaakko Heinonen Date: Sun, 28 Mar 2010 11:22:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r205790 - stable/8/usr.bin/touch X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Mar 2010 11:22:39 -0000 Author: jh Date: Sun Mar 28 11:22:38 2010 New Revision: 205790 URL: http://svn.freebsd.org/changeset/base/205790 Log: MFC r198175: - If lstat()/stat() fails with an error other than ENOENT, don't ignore the error and assume that the file doesn't exist. Touch could return success with -c option even if the file existed and time was not set. - If the first utimes_f() call fails with -A option, give up and don't continue trying to set times to current time. [1] - Set exit status to 1 when setting of timestamps fails for a directory or symbolic link even though lstat()/stat() would succeed. - Don't print bogus error message when rw() succeeds. PR: bin/112213 Modified: stable/8/usr.bin/touch/touch.c Directory Properties: stable/8/usr.bin/touch/ (props changed) Modified: stable/8/usr.bin/touch/touch.c ============================================================================== --- stable/8/usr.bin/touch/touch.c Sun Mar 28 06:51:50 2010 (r205789) +++ stable/8/usr.bin/touch/touch.c Sun Mar 28 11:22:38 2010 (r205790) @@ -164,6 +164,11 @@ main(int argc, char *argv[]) for (rval = 0; *argv; ++argv) { /* See if the file exists. */ if (stat_f(*argv, &sb) != 0) { + if (errno != ENOENT) { + rval = 1; + warn("%s", *argv); + continue; + } if (!cflag) { /* Create the file. */ fd = open(*argv, @@ -206,7 +211,7 @@ main(int argc, char *argv[]) continue; /* If the user specified a time, nothing else we can do. */ - if (timeset) { + if (timeset || Aflag) { rval = 1; warn("%s", *argv); continue; @@ -222,11 +227,13 @@ main(int argc, char *argv[]) continue; /* Try reading/writing. */ - if (!S_ISLNK(sb.st_mode) && !S_ISDIR(sb.st_mode) && - rw(*argv, &sb, fflag)) + if (!S_ISLNK(sb.st_mode) && !S_ISDIR(sb.st_mode)) { + if (rw(*argv, &sb, fflag)) + rval = 1; + } else { rval = 1; - else warn("%s", *argv); + } } exit(rval); }