1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
12 #include <sys/types.h>
19 int main(int argc, char **argv)
21 char *dname1, *dname2;
22 int fddev1, fddev2, rc;
26 if (argc < 2 || argc > 3) {
27 fprintf(stderr, "usage: %s filename1 [filename2]\n", argv[0]);
37 //create the special file (right now only test on pipe)
38 fprintf(stderr, "creating special file %s\n", dname1);
39 rc = mknod(dname1, 0777|S_IFIFO, 0);
41 fprintf(stderr, "creating %s fails: %s\n",
42 dname1, strerror(errno));
46 // open the special file again
47 fprintf(stderr, "opening file\n");
48 fddev1 = open(dname1, O_RDONLY | O_NONBLOCK);
50 fprintf(stderr, "open %s fails: %s\n",
51 dname1, strerror(errno));
55 // doesn't matter if the two dirs are the same??
56 fddev2 = open(dname2, O_RDONLY | O_NONBLOCK);
58 fprintf(stderr, "open %s fails: %s\n",
59 dname2, strerror(errno));
63 // delete the special file
64 fprintf (stderr, "unlinking %s\n", dname1);
67 fprintf(stderr, "unlink %s error: %s\n",
68 dname1, strerror(errno));
72 if (access(dname2, F_OK) == 0) {
73 fprintf(stderr, "%s still exists\n", dname2);
77 if (access(dname1, F_OK) == 0) {
78 fprintf(stderr, "%s still exists\n", dname1);
82 // fchmod one special file
83 rc = fchmod (fddev1, 0777);
85 fprintf(stderr, "fchmod unlinked special file %s fails: %s\n",
86 dname1, strerror(errno));
90 // fstat two files to check if they are the same
91 rc = fstat(fddev1, &st1);
93 fprintf(stderr, "fstat unlinked special file %s fails: %s\n",
94 dname1, strerror(errno));
98 rc = fstat(fddev2, &st2);
100 fprintf(stderr, "fstat file %s fails: %s\n",
101 dname2, strerror(errno));
106 /* We cannot do this any longer, we do not store open special nodes
107 * on MDS after unlink */
108 if (st1.st_mode != st2.st_mode) { // can we do this?
109 fprintf(stderr, "fstat different value on %s and %s\n", dname1, dname2);
114 fprintf(stderr, "Ok, everything goes well.\n");