Back to index

glibc  2.9
tst-mntent2.c
Go to the documentation of this file.
00001 #include <mntent.h>
00002 #include <stdio.h>
00003 #include <string.h>
00004 
00005 
00006 int
00007 main (void)
00008 {
00009   int result = 0;
00010   struct mntent mef;
00011 
00012   mef.mnt_fsname = strdupa ("/dev/sdf6");
00013   mef.mnt_dir = strdupa ("/some dir");
00014   mef.mnt_type = strdupa ("ext3");
00015   mef.mnt_opts = strdupa ("opt1,opt2,noopt=6,rw,norw,brw");
00016   mef.mnt_freq = 1;
00017   mef.mnt_passno = 2;
00018 
00019 #define TEST(opt, found) \
00020   if (!!hasmntopt (&mef, (opt)) != (found))                           \
00021     {                                                          \
00022       printf ("Option %s was %sfound\n", (opt), (found) ? "not " : "");      \
00023       result = 1;                                              \
00024     }
00025 
00026   TEST ("opt1", 1)
00027   TEST ("opt2", 1)
00028   TEST ("noopt", 1)
00029   TEST ("rw", 1)
00030   TEST ("norw", 1)
00031   TEST ("brw", 1)
00032   TEST ("opt", 0)
00033   TEST ("oopt", 0)
00034   TEST ("w", 0)
00035   TEST ("r", 0)
00036   TEST ("br", 0)
00037   TEST ("nor", 0)
00038   TEST ("or", 0)
00039 
00040   return result;
00041 }