#include <inttypes.h>
#include <fcntl.h>
#include <locale.h>
-#include <libiberty.h>
#include <linux/lustre/lustre_user.h>
#ifdef HAVE_SELINUX
#ifdef __NR_statx
#ifndef HAVE_STATX
+
+#define AT_STATX_SYNC_TYPE 0x6000
+#define AT_STATX_FORCE_SYNC 0x2000
+#define AT_STATX_DONT_SYNC 0x4000
+
static __attribute__((unused))
ssize_t statx(int dfd, const char *filename, int flags,
unsigned int mask, struct statx *buffer)
}
#endif /* HAVE_STATX */
+#define xstrdup(str) strdup(str)
+static inline
+char *xasprintf(const char *fmt, const char *old_fmt, const char *str)
+{
+ char *tmp = NULL;
+
+ if (asprintf(&tmp, fmt, old_fmt, str) < 0) {
+ fprintf(stderr, "asprintf allocation failed\n");
+ exit(1);
+ }
+
+ return tmp;
+}
+
+
/* coreutils/lib/intprops.h */
#define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED(__typeof__(t))
static char const fmt_terse_fs[] = "%n %i %l %t %s %S %b %f %a %c %d\n";
static char const fmt_terse_regular[] = "%n %s %b %f %u %g %D %i %h %t %T"
" %X %Y %Z %W %o\n";
+#ifdef HAVE_SELINUX
static char const fmt_terse_selinux[] = "%n %s %b %f %u %g %D %i %h %t %T"
" %X %Y %Z %W %o %C\n";
-
+#endif
static char *format;
/* Whether to follow symbolic links; True for --dereference (-L). */
return ch;
}
-void usage(char *prog)
+static void usage(char *prog)
{
printf("Usage: %s [options] <FILE>...\n", prog);
printf("Display file status via statx() syscall.\n"
"\t%%n file name\n"
"\t%%N quoted file name with dereference if symbolic link\n"
"\t%%o optimal I/O transfer size hint\n"
- "\t%%q Mask to show what's supported in stx_attributes\n"
+ "\t%%p Mask to show what's supported in stx_attributes\n"
"\t%%r Flags conveying information about the file: "
"stx_attributes\n"
"\t%%s total size, in bytes\n"
strcpy(pformat + prefix_len, "s");
printf(pformat, (scontext ? scontext : "?"));
+#ifdef HAVE_SELINUX
if (scontext)
freecon(scontext);
+#endif
return rc;
}
");
free(temp);
+#ifdef HAVE_SELINUX
if (is_selinux_enabled() > 0) {
temp = format;
/* TRANSLATORS: This string uses format
"Context: %C\n");
free(temp);
}
-
+#endif
temp = format;
/* TRANSLATORS: This string uses format specifiers from
* 'stat --help' without --file-system, and NOT from