+ fprintf(help ? stdout : stderr,
+ "Usage: %s [flags] file[s]\n",
+ progname);
+
+ if (!help) {
+ fprintf(stderr, " or try '-h' for help\n");
+ exit(1);
+ }
+
+ printf("Check given files have...\n");
+ printf(" -p permission file must have required permissions\n");
+ printf(" -t dir|file|link file must be of the specified type\n");
+ printf(" -l link_name file must be a link to the given name\n");
+ printf(" -s size file must have the given size\n");
+ printf(" -u user file must be owned by given user\n");
+ printf(" -g group file must be owned by given group\n");
+ printf(" -f follow symlinks\n");
+ printf(" -a file must be absent\n");
+ printf(" -v increase verbosity\n");
+ printf(" -h print help\n");
+ printf(" Exit status is 0 on success, 1 on failure\n");
+}
+
+/* using realpath() implies the paths must be resolved/exist
+ * so this will fail for dangling links
+ */
+int check_canonical(char *lname, char *checklink, int verbose)
+{
+ char *lname_canon;
+ char *checklink_canon;
+
+ lname_canon = realpath(lname, NULL);
+ if (lname_canon == NULL) {
+ if (verbose)
+ printf("%s: can't canonicalize: %s\n",
+ lname, strerror(errno));
+ return 1;
+ }