Mark __libc_resp with attribute_tls_model_ie for consistency with __resp
[glibc/nacl-glibc.git] / misc / tst-mntent.c
blob802b56e437de6bf535eb2cb73eec67ca94928e33
1 /* Test case by Horst von Brand <vonbrand@sleipnir.valparaiso.cl>
2 and Ulrich Drepper <drepper@cygnus.com>. */
3 #include <mntent.h>
4 #include <stdio.h>
5 #include <string.h>
8 int
9 main (int argc, char *argv[])
11 int result = 0;
12 struct mntent mef;
13 struct mntent *mnt = &mef;
14 FILE *fp;
16 mef.mnt_fsname = strdupa ("/dev/hda1");
17 mef.mnt_dir = strdupa ("/some dir");
18 mef.mnt_type = strdupa ("ext2");
19 mef.mnt_opts = strdupa ("defaults");
20 mef.mnt_freq = 1;
21 mef.mnt_passno = 2;
23 if (hasmntopt (mnt, "defaults"))
24 printf ("Found!\n");
25 else
27 printf ("Didn't find it\n");
28 result = 1;
31 fp = tmpfile ();
32 if (fp == NULL)
34 printf ("Cannot open temporary file: %m\n");
35 result = 1;
37 else
39 char buf[1024];
41 /* Write the name entry. */
42 addmntent (fp, &mef);
44 /* Prepare for reading. */
45 rewind (fp);
47 /* First, read it raw. */
48 if (fgets (buf, sizeof (buf), fp) == NULL)
50 printf ("Cannot read temporary file: %m");
51 result = 1;
53 else
54 if (strcmp (buf, "/dev/hda1 /some\\040dir ext2 defaults 1 2\n") != 0)
56 puts ("Raw file data not correct");
57 result = 1;
60 /* Prepare for reading, part II. */
61 rewind (fp);
63 /* Now read it cooked. */
64 mnt = getmntent (fp);
66 if (strcmp (mnt->mnt_fsname, "/dev/hda1") != 0
67 || strcmp (mnt->mnt_dir, "/some dir") != 0
68 || strcmp (mnt->mnt_type, "ext2") != 0
69 || strcmp (mnt->mnt_opts, "defaults") != 0
70 || mnt->mnt_freq != 1
71 || mnt->mnt_passno != 2)
73 puts ("Error while reading written entry back in");
74 result = 1;
78 return result;