X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fopenfilleddirunlink.c;h=1f58972d48c16d21b9aae95cd188842e61737f17;hb=8ed5937d25e436add1d8a137c71e76303152b801;hp=af61782a12110754dd8bf64797d68a9734795ae8;hpb=e3a7c58aebafce40323db54bf6056029e5af4a70;p=fs%2Flustre-release.git diff --git a/lustre/tests/openfilleddirunlink.c b/lustre/tests/openfilleddirunlink.c index af61782..1f58972 100644 --- a/lustre/tests/openfilleddirunlink.c +++ b/lustre/tests/openfilleddirunlink.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -49,63 +45,62 @@ char fname[1024]; - int main(int argc, char **argv) { - char *dname1; - int fddir1, rc; - int fd; + char *dname1; + int fddir1, rc; + int fd; - if (argc != 2) { - fprintf(stderr, "usage: %s dirname1\n", argv[0]); - exit(1); - } + if (argc != 2) { + fprintf(stderr, "usage: %s dirname1\n", argv[0]); + exit(1); + } - dname1 = argv[1]; + dname1 = argv[1]; - //create the directory - fprintf(stderr, "creating directory %s\n", dname1); - rc = mkdir(dname1, 0744); - if (rc == -1) { - fprintf(stderr, "creating %s fails: %s\n", - dname1, strerror(errno)); - exit(1); - } + /* create the directory */ + fprintf(stderr, "creating directory %s\n", dname1); + rc = mkdir(dname1, 0744); + if (rc == -1) { + fprintf(stderr, "creating %s fails: %s\n", + dname1, strerror(errno)); + exit(1); + } - sprintf(fname, "%s/0", dname1); - fprintf(stderr, "creating file %s\n", fname); - fd = creat(fname, 0666); - if (fd < 0) { - fprintf(stderr, "creation %s fails: %s\n", - fname, strerror(errno)); - exit(1); - } - close(fd); + snprintf(fname, sizeof(fname), "%s/0", dname1); + fprintf(stderr, "creating file %s\n", fname); + fd = creat(fname, 0666); + if (fd < 0) { + fprintf(stderr, "creation %s fails: %s\n", + fname, strerror(errno)); + exit(1); + } + close(fd); - // open the dir again - fprintf(stderr, "opening directory\n"); - fddir1 = open(dname1, O_RDONLY | O_DIRECTORY); - if (fddir1 == -1) { - fprintf(stderr, "open %s fails: %s\n", - dname1, strerror(errno)); - exit(1); - } + /* open the dir again */ + fprintf(stderr, "opening directory\n"); + fddir1 = open(dname1, O_RDONLY | O_DIRECTORY); + if (fddir1 == -1) { + fprintf(stderr, "open %s fails: %s\n", + dname1, strerror(errno)); + exit(1); + } - // delete the dir - fprintf(stderr, "unlinking %s\n", dname1); - rc = rmdir(dname1); - if (rc == 0) { - fprintf(stderr, "unlinked non-empty %s successfully\n", - dname1); - exit(1); - } + /* delete the dir */ + fprintf(stderr, "unlinking %s\n", dname1); + rc = rmdir(dname1); + if (rc == 0) { + fprintf(stderr, "unlinked non-empty %s successfully\n", + dname1); + exit(1); + } - if (access(dname1, F_OK) != 0){ - fprintf(stderr, "can't access %s: %s\n", - dname1, strerror(errno)); - exit(1); - } + if (access(dname1, F_OK) != 0) { + fprintf(stderr, "can't access %s: %s\n", + dname1, strerror(errno)); + exit(1); + } - fprintf(stderr, "Ok, everything goes well.\n"); - return 0; + fprintf(stderr, "Ok, everything goes well.\n"); + return 0; }