X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fstatx.c;h=d5c2e88f9800a2a1543805a7bc89ff86d0a63532;hb=refs%2Fchanges%2F35%2F45935%2F4;hp=aa7429b92a669aebbac064f5d142afc95ed8328d;hpb=980f8741339f2bece106f6955b0b076d35211850;p=fs%2Flustre-release.git diff --git a/lustre/tests/statx.c b/lustre/tests/statx.c index aa7429b..d5c2e88 100644 --- a/lustre/tests/statx.c +++ b/lustre/tests/statx.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #ifdef HAVE_SELINUX @@ -86,6 +85,21 @@ ssize_t statx(int dfd, const char *filename, int flags, } #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)) @@ -159,9 +173,10 @@ static char const printf_flags[] = "'-+ #0I"; 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). */ @@ -232,7 +247,7 @@ void usage(char *prog) "\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" @@ -925,8 +940,10 @@ static int out_file_context(char *pformat, size_t prefix_len, strcpy(pformat + prefix_len, "s"); printf(pformat, (scontext ? scontext : "?")); +#ifdef HAVE_SELINUX if (scontext) freecon(scontext); +#endif return rc; } @@ -1291,6 +1308,7 @@ static char *default_format(bool fs, bool terse, bool device) "); free(temp); +#ifdef HAVE_SELINUX if (is_selinux_enabled() > 0) { temp = format; /* TRANSLATORS: This string uses format @@ -1301,7 +1319,7 @@ static char *default_format(bool fs, bool terse, bool device) "Context: %C\n"); free(temp); } - +#endif temp = format; /* TRANSLATORS: This string uses format specifiers from * 'stat --help' without --file-system, and NOT from