From owner-freebsd-bugs Tue Mar 24 13:10:05 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA01553 for freebsd-bugs-outgoing; Tue, 24 Mar 1998 13:10:05 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: (from gnats@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA01541; Tue, 24 Mar 1998 13:10:02 -0800 (PST) (envelope-from gnats) Received: from salmon.maths.tcd.ie (mmdf@salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id NAA00713 for ; Tue, 24 Mar 1998 13:06:03 -0800 (PST) (envelope-from dwmalone@hamilton.maths.tcd.ie) Received: from hamilton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 24 Mar 98 21:05:59 +0000 (GMT) Received: (from dwmalone@localhost) by hamilton.maths.tcd.ie (8.8.8/8.8.5) id VAA07810; Tue, 24 Mar 1998 21:05:57 GMT Message-Id: <199803242105.VAA07810@hamilton.maths.tcd.ie> Date: Tue, 24 Mar 1998 21:05:57 GMT From: David Malone Reply-To: dwmalone@hamilton.maths.tcd.ie To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/6124: Getting md5 to reset access times. Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 6124 >Category: bin >Synopsis: No problem - addition to make md5 to reset access times. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Mar 24 13:10:01 PST 1998 >Last-Modified: >Originator: David Malone >Organization: School of Mathematics, Trinity College Dublin. >Release: FreeBSD 3.0-CURRENT i386 >Environment: 2.2-STABLE (as of 2.2.6-RELEASE) and 3.0-CURRENT (98.03.02). >Description: If you are using md5 to checksum a load of files you probably don't want all the access times changed. This is a small patch which adds a "-r" flag which resets the access times to what they were before the file was checksumed. It doesn't take into account the possibility that the file is accessed while being checksumed. The diff's included seem to work OK on both stable and current. >How-To-Repeat: >Fix: *** /usr/src/sbin/md5/md5.c Mon Dec 29 14:05:49 1997 --- md5.c Tue Mar 24 20:51:14 1998 *************** *** 22,27 **** --- 22,28 ---- */ #include + #include #include #include *************** *** 60,72 **** int ch; char *p; char buf[33]; if (argc > 1) { ! while ((ch = getopt(argc, argv, "ps:tx")) != -1) { switch (ch) { case 'p': MDFilter(1); break; case 's': MDString(optarg); break; --- 61,80 ---- int ch; char *p; char buf[33]; + int reset_times = 0; + int times_ok; + struct stat sb; + struct timeval tv[2]; if (argc > 1) { ! while ((ch = getopt(argc, argv, "prs:tx")) != -1) { switch (ch) { case 'p': MDFilter(1); break; + case 'r': + reset_times = 1; + break; case 's': MDString(optarg); break; *************** *** 81,91 **** --- 89,106 ---- } } while (optind < argc) { + times_ok = reset_times && stat(argv[optind],&sb) == 0; p = MD5File(argv[optind], buf); if (!p) perror(argv[optind]); else printf("MD5 (%s) = %s\n", argv[optind], p); + if( times_ok ) { + TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atimespec); + TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec); + + utimes(argv[optind],tv); + } optind++; } } else *************** *** 194,199 **** usage() { ! fprintf(stderr, "usage: md5 [-ptx] [-s string] [files ...]\n"); exit(1); } --- 209,214 ---- usage() { ! fprintf(stderr, "usage: md5 [-rptx] [-s string] [files ...]\n"); exit(1); } *** /usr/src/sbin/md5/md5.1 Mon Dec 29 03:40:37 1997 --- md5.1 Tue Mar 24 20:50:58 1998 *************** *** 6,12 **** .Nd calculate a message-digest fingerprint (checksum) for a file .Sh SYNOPSIS .Nm ! .Op Fl ptx .Op Fl s Ar string .Op Ar file ... .Sh DESCRIPTION --- 6,12 ---- .Nd calculate a message-digest fingerprint (checksum) for a file .Sh SYNOPSIS .Nm ! .Op Fl prtx .Op Fl s Ar string .Op Ar file ... .Sh DESCRIPTION *************** *** 37,42 **** --- 37,44 ---- .Ar string . .It Fl p echos stdin to stdout and appends the MD5 sum to stdout. + .It Fl r + resets the access time on files after reading. .It Fl t runs a built-in time trial. .It Fl x >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message