Whamcloud - gitweb
b=1501
authorpschwan <pschwan>
Wed, 2 Jul 2003 23:26:55 +0000 (23:26 +0000)
committerpschwan <pschwan>
Wed, 2 Jul 2003 23:26:55 +0000 (23:26 +0000)
- return -ENOTDIR from mds_open() if we're trying to open a
  non-directory with O_DIRECTORY
- add tests/o_directory.c and make it in sanity test 38

lustre/mdc/mdc_lib.c
lustre/tests/o_directory.c [new file with mode: 0644]

index 1396f8d..806a830 100644 (file)
@@ -98,8 +98,7 @@ void mds_create_pack(struct ptlrpc_request *req, int offset,
 void mds_open_pack(struct ptlrpc_request *req, int offset,
                    struct mdc_op_data *op_data,
                    __u32 mode, __u64 rdev, __u32 uid, __u32 gid, __u64 time,
-                   __u32 flags,
-                   const void *data, int datalen)
+                   __u32 flags, const void *data, int datalen)
 {
         struct mds_rec_create *rec;
         char *tmp;
diff --git a/lustre/tests/o_directory.c b/lustre/tests/o_directory.c
new file mode 100644 (file)
index 0000000..d4b2c1b
--- /dev/null
@@ -0,0 +1,51 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+
+/* for O_DIRECTORY */
+#define _GNU_SOURCE
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+int main(int argc, char **argv)
+{
+        int fd, rc;
+
+        if (argc != 2) {
+                printf("Usage: %s <filename>\n", argv[0]);
+                exit(1);
+        }
+
+        fd = open(argv[1], O_RDONLY | O_CREAT, 0600);
+        if (fd == -1) {
+                printf("Error opening %s for create: %s\n", argv[1],
+                       strerror(errno));
+                exit(1);
+        }
+        rc = close(fd);
+        if (rc < 0) {
+                printf("Error closing %s: %s\n", argv[1], strerror(errno));
+                exit(1);
+        }
+
+        fd = open(argv[1], O_DIRECTORY);
+        if (fd >= 0) {
+                printf("opening %s as directory should have returned an "
+                       "error!\n", argv[1]);
+                exit(1);
+        }
+        if (errno != ENOTDIR) {
+                printf("opening %s as directory, expected -ENOTDIR and got "
+                       "%s\n", argv[1], strerror(errno));
+                exit(1);
+        }
+
+        return 0;
+}