Print this page
10076 make usr/src/test smatch clean


  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright (c) 2013 by Delphix. All rights reserved.
  29  */
  30 



  31 
  32 #include <sys/types.h>
  33 #include <sys/stat.h>
  34 #include <utime.h>
  35 #include <stdio.h>
  36 #include <stdlib.h>
  37 #include <unistd.h>
  38 #include <strings.h>
  39 #include <errno.h>
  40 #include <fcntl.h>
  41 #include <libgen.h>
  42 
  43 #define ST_ATIME 0
  44 #define ST_CTIME 1
  45 #define ST_MTIME 2
  46 
  47 #define ALL_MODE (mode_t)(S_IRWXU|S_IRWXG|S_IRWXO)
  48 
  49 typedef struct timetest {
  50         int     type;


 305         }
 306         (void) close(fd);
 307 
 308         for (i = 0; i < NCOMMAND; i++) {
 309                 time_t t1, t2;
 310 
 311                 /*
 312                  * Get original time before operating.
 313                  */
 314                 ret = get_file_time(tfile, timetest_table[i].type, &t1);
 315                 if (ret != 0) {
 316                         (void) fprintf(stderr, "get_file_time(%s %d) = %d\n",
 317                             tfile, timetest_table[i].type, ret);
 318                         return (1);
 319                 }
 320 
 321                 /*
 322                  * Sleep 2 seconds, then invoke command on given file
 323                  */
 324                 (void) sleep(2);
 325                 timetest_table[i].func(tfile);
 326 
 327                 /*
 328                  * Get time after operating.
 329                  */
 330                 ret = get_file_time(tfile, timetest_table[i].type, &t2);
 331                 if (ret != 0) {
 332                         (void) fprintf(stderr, "get_file_time(%s %d) = %d\n",
 333                             tfile, timetest_table[i].type, ret);
 334                         return (1);
 335                 }
 336 
 337                 if (t1 == t2) {
 338                         (void) fprintf(stderr, "%s: t1(%ld) == t2(%ld)\n",
 339                             timetest_table[i].name, (long)t1, (long)t2);
 340                         return (1);
 341                 } else {
 342                         (void) fprintf(stderr, "%s: t1(%ld) != t2(%ld)\n",
 343                             timetest_table[i].name, (long)t1, (long)t2);
 344                 }
 345         }


  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright (c) 2013 by Delphix. All rights reserved.
  29  */
  30 
  31 /*
  32  * Copyright (c) 2018, Joyent, Inc.
  33  */
  34 
  35 #include <sys/types.h>
  36 #include <sys/stat.h>
  37 #include <utime.h>
  38 #include <stdio.h>
  39 #include <stdlib.h>
  40 #include <unistd.h>
  41 #include <strings.h>
  42 #include <errno.h>
  43 #include <fcntl.h>
  44 #include <libgen.h>
  45 
  46 #define ST_ATIME 0
  47 #define ST_CTIME 1
  48 #define ST_MTIME 2
  49 
  50 #define ALL_MODE (mode_t)(S_IRWXU|S_IRWXG|S_IRWXO)
  51 
  52 typedef struct timetest {
  53         int     type;


 308         }
 309         (void) close(fd);
 310 
 311         for (i = 0; i < NCOMMAND; i++) {
 312                 time_t t1, t2;
 313 
 314                 /*
 315                  * Get original time before operating.
 316                  */
 317                 ret = get_file_time(tfile, timetest_table[i].type, &t1);
 318                 if (ret != 0) {
 319                         (void) fprintf(stderr, "get_file_time(%s %d) = %d\n",
 320                             tfile, timetest_table[i].type, ret);
 321                         return (1);
 322                 }
 323 
 324                 /*
 325                  * Sleep 2 seconds, then invoke command on given file
 326                  */
 327                 (void) sleep(2);
 328                 (void) timetest_table[i].func(tfile);
 329 
 330                 /*
 331                  * Get time after operating.
 332                  */
 333                 ret = get_file_time(tfile, timetest_table[i].type, &t2);
 334                 if (ret != 0) {
 335                         (void) fprintf(stderr, "get_file_time(%s %d) = %d\n",
 336                             tfile, timetest_table[i].type, ret);
 337                         return (1);
 338                 }
 339 
 340                 if (t1 == t2) {
 341                         (void) fprintf(stderr, "%s: t1(%ld) == t2(%ld)\n",
 342                             timetest_table[i].name, (long)t1, (long)t2);
 343                         return (1);
 344                 } else {
 345                         (void) fprintf(stderr, "%s: t1(%ld) != t2(%ld)\n",
 346                             timetest_table[i].name, (long)t1, (long)t2);
 347                 }
 348         }