1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
44 #include <sys/types.h>
51 int main(int argc, char **argv)
53 char *dname1, *dname2;
54 int fddev1, fddev2, rc;
58 if (argc < 2 || argc > 3) {
59 fprintf(stderr, "usage: %s filename1 [filename2]\n", argv[0]);
69 //create the special file (right now only test on pipe)
70 fprintf(stderr, "creating special file %s\n", dname1);
71 rc = mknod(dname1, 0777|S_IFIFO, 0);
73 fprintf(stderr, "creating %s fails: %s\n",
74 dname1, strerror(errno));
78 // open the special file again
79 fprintf(stderr, "opening file\n");
80 fddev1 = open(dname1, O_RDONLY | O_NONBLOCK);
82 fprintf(stderr, "open %s fails: %s\n",
83 dname1, strerror(errno));
87 // doesn't matter if the two dirs are the same??
88 fddev2 = open(dname2, O_RDONLY | O_NONBLOCK);
90 fprintf(stderr, "open %s fails: %s\n",
91 dname2, strerror(errno));
95 // delete the special file
96 fprintf (stderr, "unlinking %s\n", dname1);
99 fprintf(stderr, "unlink %s error: %s\n",
100 dname1, strerror(errno));
104 if (access(dname2, F_OK) == 0) {
105 fprintf(stderr, "%s still exists\n", dname2);
109 if (access(dname1, F_OK) == 0) {
110 fprintf(stderr, "%s still exists\n", dname1);
114 // fchmod one special file
115 rc = fchmod (fddev1, 0777);
117 fprintf(stderr, "fchmod unlinked special file %s fails: %s\n",
118 dname1, strerror(errno));
122 // fstat two files to check if they are the same
123 rc = fstat(fddev1, &st1);
125 fprintf(stderr, "fstat unlinked special file %s fails: %s\n",
126 dname1, strerror(errno));
130 rc = fstat(fddev2, &st2);
132 fprintf(stderr, "fstat file %s fails: %s\n",
133 dname2, strerror(errno));
138 /* We cannot do this any longer, we do not store open special nodes
139 * on MDS after unlink */
140 if (st1.st_mode != st2.st_mode) { // can we do this?
141 fprintf(stderr, "fstat different value on %s and %s\n", dname1, dname2);
146 fprintf(stderr, "Ok, everything goes well.\n");