Mention updated config files.
[rsync.git] / tls.c
diff --git a/tls.c b/tls.c
index ed4490bb68507aeca101ffa1f5140be0853c7a0f..e6b0708ad3f0538a9da01c6fcbd8cc985db7d227 100644 (file)
--- a/tls.c
+++ b/tls.c
@@ -2,7 +2,7 @@
  * Trivial ls for comparing two directories after running an rsync.
  *
  * Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
- * Copyright (C) 2003-2020 Wayne Davison
+ * Copyright (C) 2003-2022 Wayne Davison
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -60,7 +60,8 @@ int nsec_times = 0;
 
 static int stat_xattr(const char *fname, STRUCT_STAT *fst)
 {
-       int mode, rdev_major, rdev_minor, uid, gid, len;
+       unsigned int mode;
+       int rdev_major, rdev_minor, uid, gid, len;
        char buf[256];
 
        if (am_root >= 0 || IS_DEVICE(fst->st_mode) || IS_SPECIAL(fst->st_mode))
@@ -108,6 +109,9 @@ static int stat_xattr(const char *fname, STRUCT_STAT *fst)
 #endif
 
 static int display_atimes = 0;
+#ifdef SUPPORT_CRTIMES
+static int display_crtimes = 0;
+#endif
 
 static void failed(char const *what, char const *where)
 {
@@ -143,14 +147,22 @@ static void storetime(char *dest, size_t destsize, time_t t, int nsecs)
 static void list_file(const char *fname)
 {
        STRUCT_STAT buf;
+#ifdef SUPPORT_CRTIMES
+       time_t crtime = 0;
+#endif
        char permbuf[PERMSTRING_SIZE];
        char mtimebuf[50];
        char atimebuf[50];
+       char crtimebuf[50];
        char linkbuf[4096];
        int nsecs;
 
        if (do_lstat(fname, &buf) < 0)
                failed("stat", fname);
+#ifdef SUPPORT_CRTIMES
+       if (display_crtimes && (crtime = get_create_time(fname, &buf)) == 0)
+               failed("get_create_time", fname);
+#endif
 #ifdef SUPPORT_XATTRS
        if (am_root < 0)
                stat_xattr(fname, &buf);
@@ -195,6 +207,12 @@ static void list_file(const char *fname)
                storetime(atimebuf, sizeof atimebuf, S_ISDIR(buf.st_mode) ? 0 : buf.st_atime, -1);
        else
                atimebuf[0] = '\0';
+#ifdef SUPPORT_CRTIMES
+       if (display_crtimes)
+               storetime(crtimebuf, sizeof crtimebuf, crtime, -1);
+       else
+#endif
+               crtimebuf[0] = '\0';
 
        /* TODO: Perhaps escape special characters in fname? */
        printf("%s ", permbuf);
@@ -204,14 +222,17 @@ static void list_file(const char *fname)
        } else
                printf("%15s", do_big_num(buf.st_size, 1, NULL));
 
-       printf(" %6ld.%-6ld %6ld%s%s %s%s\n",
+       printf(" %6ld.%-6ld %6ld%s%s%s %s%s\n",
               (long)buf.st_uid, (long)buf.st_gid, (long)buf.st_nlink,
-              mtimebuf, atimebuf, fname, linkbuf);
+              mtimebuf, atimebuf, crtimebuf, fname, linkbuf);
 }
 
 static struct poptOption long_options[] = {
   /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
   {"atimes",          'U', POPT_ARG_NONE,   &display_atimes, 0, 0, 0},
+#ifdef SUPPORT_CRTIMES
+  {"crtimes",         'N', POPT_ARG_NONE,   &display_crtimes, 0, 0, 0},
+#endif
   {"link-times",      'l', POPT_ARG_NONE,   &link_times, 0, 0, 0 },
   {"link-owner",      'L', POPT_ARG_NONE,   &link_owner, 0, 0, 0 },
 #ifdef SUPPORT_XATTRS
@@ -231,6 +252,9 @@ static void NORETURN tls_usage(int ret)
   fprintf(F,"Trivial file listing program for portably checking rsync\n");
   fprintf(F,"\nOptions:\n");
   fprintf(F," -U, --atimes                display access (last-used) times\n");
+#ifdef SUPPORT_CRTIMES
+  fprintf(F," -N, --crtimes               display create times (newness)\n");
+#endif
   fprintf(F," -l, --link-times            display the time on a symlink\n");
   fprintf(F," -L, --link-owner            display the owner+group on a symlink\n");
 #ifdef SUPPORT_XATTRS