1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
13 #include <sys/types.h>
21 int main(int argc, char **argv)
28 fprintf(stderr, "usage: %s dirname1\n", argv[0]);
34 //create the directory
35 fprintf(stderr, "creating directory %s\n", dname1);
36 rc = mkdir(dname1, 0744);
38 fprintf(stderr, "creating %s fails: %s\n",
39 dname1, strerror(errno));
43 sprintf(fname, "%s/0", dname1);
44 fprintf(stderr, "creating file %s\n", fname);
45 fd = creat(fname, 0666);
47 fprintf(stderr, "creation %s fails: %s\n",
48 fname, strerror(errno));
54 fprintf(stderr, "opening directory\n");
55 fddir1 = open(dname1, O_RDONLY | O_DIRECTORY);
57 fprintf(stderr, "open %s fails: %s\n",
58 dname1, strerror(errno));
63 fprintf(stderr, "unlinking %s\n", dname1);
66 fprintf(stderr, "unlinked non-empty %s successfully\n",
71 if (access(dname1, F_OK) != 0){
72 fprintf(stderr, "can't access %s: %s\n",
73 dname1, strerror(errno));
77 fprintf(stderr, "Ok, everything goes well.\n");