* Trivial ls for comparing two directories after running an rsync.
*
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
- * Copyright (C) 2003-2019 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
int link_times = 0;
int link_owner = 0;
int nsec_times = 0;
-int preserve_perms = 0;
-int preserve_executability = 0;
-int preallocate_files = 0;
-int open_noatime = 0;
-int inplace = 0;
#ifdef SUPPORT_XATTRS
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))
#endif
static int display_atimes = 0;
+#ifdef SUPPORT_CRTIMES
+static int display_crtimes = 0;
+#endif
static void failed(char const *what, char const *where)
{
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);
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);
if (S_ISCHR(buf.st_mode) || S_ISBLK(buf.st_mode)) {
- printf("%5ld,%6ld",
- (long)major(buf.st_rdev),
- (long)minor(buf.st_rdev));
+ printf("%5ld,%6ld", (long)major(buf.st_rdev), (long)minor(buf.st_rdev));
} 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
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
const char **extra_args;
int opt;
- pc = poptGetContext(PROGRAM, argc, (const char **)argv,
- long_options, 0);
+ pc = poptGetContext(PROGRAM, argc, (const char **)argv, long_options, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case 'h':
tls_usage(0);
default:
- fprintf(stderr,
- "%s: %s\n",
+ fprintf(stderr, "%s: %s\n",
poptBadOption(pc, POPT_BADOPTION_NOALIAS),
poptStrerror(opt));
tls_usage(1);