"Fossies" - the Fresh Open Source Software Archive

Member "stress-ng-0.13.05/stress-get.c" (11 Oct 2021, 17211 Bytes) of package /linux/privat/stress-ng-0.13.05.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "stress-get.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.13.04_vs_0.13.05.

    1 /*
    2  * Copyright (C) 2013-2021 Canonical, Ltd.
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12  * GNU General Public License for more details.
   13  *
   14  * You should have received a copy of the GNU General Public License
   15  * along with this program; if not, write to the Free Software
   16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
   17  *
   18  * This code is a complete clean re-write of the stress tool by
   19  * Colin Ian King <colin.king@canonical.com> and attempts to be
   20  * backwardly compatible with the stress tool by Amos Waterland
   21  * <apw@rossby.metr.ou.edu> but has more stress tests and more
   22  * functionality.
   23  *
   24  */
   25 #include "stress-ng.h"
   26 
   27 #define _DEFAULT_SOURCE 1
   28 #define _BSD_SOURCE 1
   29 
   30 #define GIDS_MAX    (1024)
   31 #define MOUNTS_MAX  (256)
   32 
   33 static const stress_help_t help[] = {
   34     { NULL, "get N",    "start N workers exercising the get*() system calls" },
   35     { NULL, "get-ops N",    "stop after N get bogo operations" },
   36     { NULL, NULL,       NULL }
   37 };
   38 
   39 typedef struct {
   40     const int who;      /* rusage who field */
   41     const char *name;   /* textual name of who value */
   42     const bool verify;  /* check for valid rusage return */
   43 } stress_rusage_t;
   44 
   45 static const stress_rusage_t rusages[] = {
   46 #if defined(RUSAGE_SELF)
   47     { RUSAGE_SELF,      "RUSAGE_SELF",      true },
   48 #endif
   49 #if defined(RUSAGE_CHILDREN)
   50     { RUSAGE_CHILDREN,  "RUSAGE_CHILDREN",  true },
   51 #endif
   52 #if defined(RUSAGE_THREAD)
   53     { RUSAGE_THREAD,    "RUSAGE_THREAD",    true },
   54 #endif
   55 #if defined(RUSAGE_BOTH)
   56     { RUSAGE_BOTH,      "RUSAGE_BOTH",      true },
   57 #endif
   58     { INT_MIN,      "INT_MIN",      false },
   59     { INT_MAX,      "INT_MAX",      false },
   60 };
   61 
   62 /*
   63  *  The following produce -EINVAL for Haiku, so
   64  *  disable them
   65  */
   66 #if defined(__HAIKU__)
   67 #undef RLIMIT_CPU
   68 #undef RLIMIT_FSIZE
   69 #endif
   70 
   71 static const int rlimits[] = {
   72 #if defined(RLIMIT_AS)
   73     RLIMIT_AS,
   74 #endif
   75 #if defined(RLIMIT_CORE)
   76     RLIMIT_CORE,
   77 #endif
   78 #if defined(RLIMIT_CPU)
   79     RLIMIT_CPU,
   80 #endif
   81 #if defined(RLIMIT_DATA)
   82     RLIMIT_DATA,
   83 #endif
   84 #if defined(RLIMIT_FSIZE)
   85     RLIMIT_FSIZE,
   86 #endif
   87 #if defined(RLIMIT_MEMLOCK)
   88     RLIMIT_MEMLOCK,
   89 #endif
   90 #if defined(RLIMIT_MSGQUEUE)
   91     RLIMIT_MSGQUEUE,
   92 #endif
   93 #if defined(RLIMIT_NICE)
   94     RLIMIT_NICE,
   95 #endif
   96 #if defined(RLIMIT_NOFILE)
   97     RLIMIT_NOFILE,
   98 #endif
   99 #if defined(RLIMIT_RSS)
  100     RLIMIT_RSS,
  101 #endif
  102 #if defined(RLIMIT_RTPRIO)
  103     RLIMIT_RTPRIO,
  104 #endif
  105 #if defined(RLIMIT_RTTIME)
  106     RLIMIT_RTTIME,
  107 #endif
  108 #if defined(RLIMIT_SIGPENDING)
  109     RLIMIT_SIGPENDING,
  110 #endif
  111 #if defined(RLIMIT_STACK)
  112     RLIMIT_STACK
  113 #endif
  114 };
  115 
  116 #if defined(HAVE_GETPRIORITY)
  117 static const int priorities[] = {
  118 #if defined(PRIO_PROCESS)
  119     PRIO_PROCESS,
  120 #endif
  121 #if defined(PRIO_PGRP)
  122     PRIO_PGRP,
  123 #endif
  124 #if defined(PRIO_USER)
  125     PRIO_USER
  126 #endif
  127 };
  128 #endif
  129 
  130 static sigjmp_buf jmp_env;
  131 
  132 static void NORETURN MLOCKED_TEXT stress_segv_handler(int num)
  133 {
  134     (void)num;
  135 
  136     siglongjmp(jmp_env, 1);
  137 }
  138 
  139 /*
  140  *  stress on get*() calls
  141  *  stress system by rapid get*() system calls
  142  */
  143 static int stress_get(const stress_args_t *args)
  144 {
  145     char *mnts[MOUNTS_MAX];
  146     int mounts_max;
  147     const bool verify = (g_opt_flags & OPT_FLAGS_VERIFY);
  148 #if defined(HAVE_SYS_TIMEX_H)
  149 #if defined(HAVE_ADJTIMEX) || defined(HAVE_ADJTIME)
  150     const bool cap_sys_time = stress_check_capability(SHIM_CAP_SYS_TIME);
  151 #endif
  152 #endif
  153 
  154     if (stress_sighandler(args->name, SIGSEGV, stress_segv_handler, NULL) < 0)
  155         return EXIT_NO_RESOURCE;
  156 
  157     mounts_max = stress_mount_get(mnts, MOUNTS_MAX);
  158 
  159     stress_set_proc_state(args->name, STRESS_STATE_RUN);
  160 
  161     do {
  162         char path[PATH_MAX];
  163         char *ptr;
  164         gid_t gids[GIDS_MAX];
  165         unsigned cpu, node;
  166         const pid_t mypid = getpid();
  167         int ret, n, fs_index;
  168         size_t i;
  169 #if defined(HAVE_SYS_TIMEX_H) &&    \
  170     defined(HAVE_ADJTIME)
  171         struct timeval delta;
  172 #endif
  173         struct timeval tv;
  174         struct timezone tz;
  175         struct rlimit rlim;
  176         time_t t, t1, t2;
  177         pid_t pid;
  178         gid_t gid;
  179         uid_t uid;
  180 
  181         (void)mypid;
  182 
  183         if (!keep_stressing_flag())
  184             break;
  185 
  186         pid = getppid();
  187         (void)pid;
  188 
  189         if (!keep_stressing_flag())
  190             break;
  191 
  192 #if defined(HAVE_SWAPCONTEXT) &&        \
  193     defined(HAVE_UCONTEXT_H)
  194         {
  195             ucontext_t context;
  196 
  197             ret = getcontext(&context);
  198             (void)ret;
  199             if (!keep_stressing_flag())
  200                 break;
  201         }
  202 
  203 #if defined(HAVE_SWAPCONTEXT) &&        \
  204     defined(HAVE_UCONTEXT_H)
  205         {
  206             ucontext_t context;
  207 
  208             ret = getcontext(&context);
  209             (void)ret;
  210             if (!keep_stressing_flag())
  211                 break;
  212         }
  213 #endif
  214 #endif
  215 
  216 #if defined(HAVE_GETDOMAINNAME)
  217         {
  218             char name[128];
  219 
  220             ret = getdomainname(name, sizeof(name));
  221             (void)ret;
  222             if (!keep_stressing_flag())
  223                 break;
  224         }
  225 #endif
  226 
  227 #if defined(HAVE_GETHOSTID)
  228         {
  229             long id;
  230 
  231             id = gethostid();
  232             (void)id;
  233             if (!keep_stressing_flag())
  234                 break;
  235         }
  236 #endif
  237 
  238 #if defined(HAVE_GETHOSTNAME)
  239         {
  240             char name[128];
  241 
  242             ret = gethostname(name, sizeof(name));
  243             (void)ret;
  244             if (!keep_stressing_flag())
  245                 break;
  246         }
  247 #endif
  248 
  249         ptr = getcwd(path, sizeof path);
  250         if (verify) {
  251             if (!ptr) {
  252                 pr_fail("%s: getcwd %s failed, errno=%d (%s)\n",
  253                     args->name, path, errno, strerror(errno));
  254             } else {
  255                 /* getcwd returned a string: is it the same as path? */
  256                 if (strncmp(ptr, path, sizeof(path))) {
  257                     pr_fail("%s: getcwd returned a string that "
  258                         "is different from the expected path\n",
  259                         args->name);
  260                 }
  261             }
  262         }
  263         if (!keep_stressing_flag())
  264             break;
  265 
  266         gid = getgid();
  267         (void)gid;
  268 
  269         gid = getegid();
  270         (void)gid;
  271 
  272         uid = getuid();
  273         (void)uid;
  274 
  275         uid = geteuid();
  276         (void)uid;
  277 
  278         if (!keep_stressing_flag())
  279             break;
  280 
  281         /*
  282          *  Zero size should return number of gids to fetch
  283          */
  284         ret = getgroups(0, gids);
  285         (void)ret;
  286 
  287         /*
  288          *  Try to get GIDS_MAX number of gids
  289          */
  290         ret = getgroups(GIDS_MAX, gids);
  291         if (verify && (ret < 0) && (errno != EINVAL))
  292             pr_fail("%s: getgroups failed, errno=%d (%s)\n",
  293                 args->name, errno, strerror(errno));
  294         /*
  295          *  Exercise invalid getgroups calls
  296          */
  297         ret = getgroups(1, gids);
  298         (void)ret;
  299 #if defined(__NR_getgroups)
  300         /*
  301          *  libc may detect a -ve gidsetsize argument and not call
  302          *  the system call. Override this by directly calling the
  303          *  system call if possible. Memset gids to zero to keep
  304          *  valgrind happy.
  305          */
  306         (void)memset(gids, 0, sizeof(gids));
  307         ret = (int)syscall(__NR_getgroups, -1, gids);
  308         (void)ret;
  309 #endif
  310         if (!keep_stressing_flag())
  311             break;
  312 
  313 #if defined(HAVE_GETPGRP)
  314         pid = getpgrp();
  315         (void)pid;
  316 #endif
  317 
  318 #if defined(HAVE_GETPGID)
  319         pid = getpgid(mypid);
  320         (void)pid;
  321 
  322         /*
  323          *  Exercise with an possibly invalid pid
  324          */
  325         pid = stress_get_unused_pid_racy(false);
  326         pid = getpgid(pid);
  327         (void)pid;
  328 
  329         if (!keep_stressing_flag())
  330             break;
  331 #endif
  332 
  333 #if defined(HAVE_GETPRIORITY)
  334         /*
  335          *  Exercise getpriority calls that uses illegal
  336          *  arguments to get more kernel test coverage
  337          */
  338         (void)getpriority(INT_MIN, 0);
  339         (void)getpriority(INT_MAX, 0);
  340         pid = stress_get_unused_pid_racy(false);
  341         (void)getpriority(pid, 0);
  342 
  343         for (i = 0; i < SIZEOF_ARRAY(priorities); i++) {
  344             errno = 0;
  345             ret = getpriority(priorities[i], 0);
  346             if (verify && errno && (errno != EINVAL) && (ret < 0))
  347                 pr_fail("%s: getpriority failed, errno=%d (%s)\n",
  348                     args->name, errno, strerror(errno));
  349             if (!keep_stressing_flag())
  350                 break;
  351         }
  352         /* Exercise getpriority calls using non-zero who argument */
  353         for (i = 0; i < SIZEOF_ARRAY(priorities); i++){
  354             ret = getpriority(priorities[i], ~(id_t)0);
  355             (void)ret;
  356         }
  357 #endif
  358 
  359 #if defined(HAVE_GETRESGID)
  360         {
  361             gid_t rgid, egid, sgid;
  362 
  363             ret = getresgid(&rgid, &egid, &sgid);
  364             if (verify && (ret < 0))
  365                 pr_fail("%s: getresgid failed, errno=%d (%s)\n",
  366                     args->name, errno, strerror(errno));
  367             if (!keep_stressing_flag())
  368                 break;
  369         }
  370 #endif
  371 
  372 #if defined(HAVE_GETRESUID)
  373         {
  374             uid_t ruid, euid, suid;
  375 
  376             ret = getresuid(&ruid, &euid, &suid);
  377             if (verify && (ret < 0))
  378                 pr_fail("%s: getresuid failed, errno=%d (%s)\n",
  379                     args->name, errno, strerror(errno));
  380             if (!keep_stressing_flag())
  381                 break;
  382         }
  383 #endif
  384         /* Invalid getrlimit syscall and ignoring failure */
  385         (void)getrlimit(INT_MAX, &rlim);
  386 
  387         for (i = 0; i < SIZEOF_ARRAY(rlimits); i++) {
  388             ret = getrlimit(rlimits[i], &rlim);
  389             if (verify && (ret < 0))
  390                 pr_fail("%s: getrlimit(%zu, ..) failed, errno=%d (%s)\n",
  391                     args->name, i, errno, strerror(errno));
  392             if (!keep_stressing_flag())
  393                 break;
  394         }
  395 
  396 #if defined(__NR_ugetrlimit)
  397         /*
  398          * Legacy system call, most probably __NR_ugetrlimit
  399          * is not defined, ignore return as it's most probably
  400          * ENOSYS too
  401          */
  402         (void)syscall(__NR_ugetrlimit, INT_MAX, &rlim);
  403         (void)syscall(__NR_ugetrlimit, INT_MIN, &rlim);
  404         (void)syscall(__NR_ugetrlimit, -1, &rlim);
  405 
  406         for (i = 0; i < SIZEOF_ARRAY(rlimits); i++) {
  407             ret = syscall(__NR_ugetrlimit, rlimits[i], &rlim);
  408             (void)ret;
  409         }
  410 #endif
  411 
  412 #if defined(HAVE_PRLIMIT) &&    \
  413     NEED_GLIBC(2,13,0) &&   \
  414     defined(EOVERFLOW)
  415         /* Invalid prlimit syscall and ignoring failure */
  416         (void)prlimit(mypid, INT_MAX, NULL, &rlim);
  417         pid = stress_get_unused_pid_racy(false);
  418         (void)prlimit(pid, INT_MAX, NULL, &rlim);
  419 
  420         for (i = 0; i < SIZEOF_ARRAY(rlimits); i++) {
  421             struct rlimit rlims[2];
  422 
  423             ret = prlimit(mypid, rlimits[i], NULL, &rlims[0]);
  424             if (verify && (ret < 0) && (errno != EOVERFLOW))
  425                 pr_fail("%s: prlimit(%" PRIdMAX ", %zu, ..) failed, errno=%d (%s)\n",
  426                     args->name, (intmax_t)mypid, i, errno, strerror(errno));
  427             if (!ret) {
  428                 ret = prlimit(mypid, rlimits[i], &rlims[0], NULL);
  429                 if (verify && (ret < 0) && (errno != EOVERFLOW))
  430                     pr_fail("%s: prlimit(%" PRIdMAX ", %zu, ..) failed, errno=%d (%s)\n",
  431                         args->name, (intmax_t)mypid, i, errno, strerror(errno));
  432                 ret = prlimit(mypid, rlimits[i], &rlims[0], &rlims[1]);
  433                 if (verify && (ret < 0) && (errno != EOVERFLOW))
  434                     pr_fail("%s: prlimit(%" PRIdMAX", %zu, ..) failed, errno=%d (%s)\n",
  435                         args->name, (intmax_t)mypid, i, errno, strerror(errno));
  436             }
  437 
  438             /* Exercise invalid pids */
  439             (void)prlimit(pid, rlimits[i], NULL, &rlims[0]);
  440             if (!keep_stressing_flag())
  441                 break;
  442         }
  443 #endif
  444 
  445 #if defined(HAVE_LINUX_SYSCTL_H) && \
  446     defined(__NR__sysctl)
  447         {
  448             /*
  449              *  _sysctl is a deprecated API, so it
  450              *  probably will return -ENOSYS
  451              */
  452             int name[] = { KERN_VERSION };
  453             char kern_version[64];
  454             size_t kern_version_len = 0;
  455             struct __sysctl_args sysctl_args;
  456 
  457             (void)memset(&sysctl_args, 0, sizeof(sysctl_args));
  458             sysctl_args.name = name;
  459             sysctl_args.nlen = SIZEOF_ARRAY(name);
  460             sysctl_args.oldval = kern_version;
  461             sysctl_args.oldlenp = &kern_version_len;
  462             sysctl_args.newval = NULL;
  463             sysctl_args.newlen = 0;
  464 
  465             ret = (int)syscall(__NR__sysctl, &sysctl_args);
  466             (void)ret;
  467         }
  468 #endif
  469 
  470         for (i = 0; i < SIZEOF_ARRAY(rusages); i++) {
  471             struct rusage usage;
  472 
  473             ret = shim_getrusage(rusages[i].who, &usage);
  474             if (rusages[i].verify && verify && (ret < 0) && (errno != ENOSYS))
  475                 pr_fail("%s: getrusage(%s, ..) failed, errno=%d (%s)\n",
  476                     args->name, rusages[i].name, errno, strerror(errno));
  477             if (!keep_stressing_flag())
  478                 break;
  479         }
  480 
  481 #if defined(HAVE_GETSID)
  482         ret = getsid(mypid);
  483         if (verify && (ret < 0))
  484             pr_fail("%s: getsid failed, errno=%d (%s)\n",
  485                 args->name, errno, strerror(errno));
  486         pid = stress_get_unused_pid_racy(false);
  487         ret = getsid(pid);
  488         (void)ret;
  489         if (!keep_stressing_flag())
  490             break;
  491 #endif
  492 
  493         (void)shim_gettid();
  494 
  495         (void)shim_getcpu(&cpu, &node, NULL);
  496         (void)shim_getcpu(NULL, &node, NULL);
  497         (void)shim_getcpu(&cpu, NULL, NULL);
  498         (void)shim_getcpu(NULL, NULL, NULL);
  499         if (!keep_stressing_flag())
  500             break;
  501 
  502         t = time(NULL);
  503         if (t == (time_t)-1) {
  504             pr_fail("%s: time failed, errno=%d (%s)\n",
  505                 args->name, errno, strerror(errno));
  506         }
  507         /*
  508          *  Exercise time calls with a pointer to time_t
  509          *  variable and check equality with returned value
  510          *  with it to increase kernel test coverage
  511          */
  512         t1 = time(&t2);
  513         if (memcmp(&t1, &t2, sizeof(t1))) {
  514             pr_fail("%s: time failed, errno=%d (%s)\n",
  515                 args->name, errno, strerror(errno));
  516 
  517         }
  518         /*
  519          *  Exercise the time system call using the syscall()
  520          *  function to increase kernel test coverage
  521          */
  522         t = shim_time(NULL);
  523         if ((t == (time_t)-1) && (errno != ENOSYS))
  524             pr_fail("%s: time failed, errno=%d (%s)\n",
  525                 args->name, errno, strerror(errno));
  526 
  527         t1 = shim_time(&t2);
  528         if ((t == (time_t)-1) && (errno != ENOSYS)) {
  529             if (memcmp(&t1, &t2, sizeof(t1))) {
  530                 pr_fail("%s: time failed, errno=%d (%s)\n",
  531                     args->name, errno, strerror(errno));
  532             }
  533         }
  534 
  535 
  536         /*
  537          *  The following gettimeofday calls probably use the VDSO
  538          *  on Linux
  539          */
  540         ret = gettimeofday(&tv, NULL);
  541         if (ret < 0) {
  542             pr_fail("%s: gettimeval failed, errno=%d (%s)\n",
  543                 args->name, errno, strerror(errno));
  544         }
  545         ret = gettimeofday(&tv, &tz);
  546         if (ret < 0) {
  547             pr_fail("%s: gettimeval failed, errno=%d (%s)\n",
  548                 args->name, errno, strerror(errno));
  549         }
  550 #if 0
  551         /*
  552          * gettimeofday with NULL args works fine on x86-64
  553          * linux, but on s390 will segfault. Disable this
  554          * for now.
  555          */
  556         ret = gettimeofday(NULL, NULL);
  557         if ((ret < 0) && (errno != ENOSYS)) {
  558             pr_fail("%s: gettimeval failed, errno=%d (%s)\n",
  559                 args->name, errno, strerror(errno));
  560         }
  561 #endif
  562 
  563         /*
  564          *  Exercise the gettimeofday by force using the syscall
  565          *  via the shim to force non-use of libc wrapper and/or
  566          *  the vdso
  567          */
  568         ret = shim_gettimeofday(&tv, NULL);
  569         if ((ret < 0) && (errno != ENOSYS)) {
  570             pr_fail("%s: gettimeval failed, errno=%d (%s)\n",
  571                 args->name, errno, strerror(errno));
  572         }
  573         ret = shim_gettimeofday(&tv, &tz);
  574         if ((ret < 0) && (errno != ENOSYS)) {
  575             pr_fail("%s: gettimeval failed, errno=%d (%s)\n",
  576                 args->name, errno, strerror(errno));
  577         }
  578         ret = shim_gettimeofday(NULL, NULL);
  579         if ((ret < 0) && (errno != ENOSYS)) {
  580             pr_fail("%s: gettimeval failed, errno=%d (%s)\n",
  581                 args->name, errno, strerror(errno));
  582         }
  583 
  584 #if defined(HAVE_UNAME) &&  \
  585     defined(HAVE_SYS_UTSNAME_H)
  586         {
  587             struct utsname utsbuf;
  588             static bool uname_segv = false;
  589 
  590             if (!uname_segv) {
  591                 ret = sigsetjmp(jmp_env, 1);
  592                 if (!keep_stressing(args))
  593                     break;
  594                 if (ret != 0) {
  595                     uname_segv = true;
  596                 } else {
  597                     ret = uname(args->mapped->page_none);
  598                     if (ret == 0) {
  599                         pr_fail("%s: uname unexpectedly succeeded with read only utsbuf, "
  600                             "expected -EFAULT, instead got errno=%d (%s)\n",
  601                             args->name, errno, strerror(errno));
  602                     }
  603                 }
  604             }
  605 
  606             ret = uname(&utsbuf);
  607             if (verify && (ret < 0))
  608                 pr_fail("%s: uname failed, errno=%d (%s)\n",
  609                     args->name, errno, strerror(errno));
  610         }
  611 #endif
  612 
  613 #if defined(HAVE_GETPAGESIZE)
  614         ret = getpagesize();
  615         (void)ret;
  616 #endif
  617 
  618 #if defined(HAVE_GETDTABLESIZE)
  619         ret = getdtablesize();
  620         (void)ret;
  621 #endif
  622 
  623 #if defined(HAVE_LOOKUP_DCOOKIE)
  624         {
  625             char buf[PATH_MAX];
  626 
  627             ret = (int)syscall(__NR_lookup_dcookie, buf, sizeof(buf));
  628             (void)ret;
  629         }
  630 #endif
  631 
  632 #if defined(HAVE_SYS_TIMEX_H) &&    \
  633     defined(HAVE_ADJTIMEX)
  634         {
  635             struct timex timexbuf;
  636 
  637             timexbuf.modes = 0;
  638             ret = adjtimex(&timexbuf);
  639             if (cap_sys_time && verify && (ret < 0) && (errno != EPERM))
  640                 pr_fail("%s: adjtimex failed, errno=%d (%s)\n",
  641                     args->name, errno, strerror(errno));
  642         }
  643 #endif
  644 
  645 #if defined(HAVE_SYS_TIMEX_H) &&    \
  646     defined(HAVE_ADJTIME)
  647         (void)memset(&delta, 0, sizeof(delta));
  648         ret = adjtime(&delta, &tv);
  649         if (cap_sys_time && verify && (ret < 0) && (errno != EPERM))
  650             pr_fail("%s: adjtime failed, errno=%d (%s)\n",
  651                 args->name, errno, strerror(errno));
  652 #endif
  653 
  654 #if defined(__NR_lookup_dcookie)
  655         /*
  656          *  Exercise some random cookie lookups, really likely
  657          *  to fail.
  658          */
  659         ret = shim_lookup_dcookie(stress_mwc64(), path, sizeof(path));
  660         (void)ret;
  661 #endif
  662 
  663 #if defined(__NR_sgetmask)
  664         ret = shim_sgetmask();
  665         (void)ret;
  666 #endif
  667 
  668         /* Get number of file system types */
  669         n = shim_sysfs(3);
  670         for (fs_index = 0; fs_index < n; fs_index++) {
  671             char buf[4096];
  672 
  673             ret = shim_sysfs(2, fs_index, buf);
  674             if (!ret) {
  675                 ret = shim_sysfs(1, buf);
  676                 if (verify && (ret != fs_index)) {
  677                     pr_fail("%s: sysfs(1, %s) failed, errno=%d (%s)\n",
  678                         args->name, buf, errno, strerror(errno));
  679                 }
  680             } else {
  681                 if (verify) {
  682                     pr_fail("%s: sysfs(2, %d, buf) failed, errno=%d (%s)\n",
  683                         args->name, fs_index, errno, strerror(errno));
  684                 }
  685             }
  686         }
  687 #if defined(HAVE_SYS_VFS_H) &&  \
  688     defined(HAVE_STATFS) && \
  689     defined(__linux__)
  690         for (i = 0; i < (size_t)mounts_max; i++) {
  691             struct statfs buf;
  692             int fd;
  693 
  694             (void)statfs(mnts[i], &buf);
  695 
  696             fd = open(mnts[i], O_RDONLY);
  697             if (fd >= 0) {
  698                 (void)fstatfs(fd, &buf);
  699                 (void)close(fd);
  700             }
  701         }
  702 #endif
  703 
  704 #if defined(HAVE_SYS_STATVFS_H)
  705         for (i = 0; i < (size_t)mounts_max; i++) {
  706             struct statvfs buf;
  707 
  708             statvfs(mnts[i], &buf);
  709         }
  710 #endif
  711 
  712         inc_counter(args);
  713     } while (keep_stressing(args));
  714 
  715     stress_set_proc_state(args->name, STRESS_STATE_DEINIT);
  716 
  717     stress_mount_free(mnts, mounts_max);
  718 
  719     return EXIT_SUCCESS;
  720 }
  721 
  722 stressor_info_t stress_get_info = {
  723     .stressor = stress_get,
  724     .class = CLASS_OS,
  725     .help = help
  726 };