Whamcloud - gitweb
Branch HEAD
authorjohann <johann>
Thu, 10 May 2007 15:44:31 +0000 (15:44 +0000)
committerjohann <johann>
Thu, 10 May 2007 15:44:31 +0000 (15:44 +0000)
b=12229
i=adilger
i=nathan

lustre/ChangeLog
lustre/liblustre/dir.c
lustre/liblustre/tests/sanity.c

index 0a38a14..7bb2653 100644 (file)
@@ -14,6 +14,13 @@ tbd         Cluster File Systems, Inc. <info@clusterfs.com>
        * Note that reiserfs quotas are disabled on SLES 10 in this kernel.
        * bug fixes
 
        * Note that reiserfs quotas are disabled on SLES 10 in this kernel.
        * bug fixes
 
+Severity   : normal
+Frequency  : liblustre clients only
+Bugzilla   : 12229
+Description: getdirentries does not give error when run on compute nodes
+Details    : getdirentries does not fail when the size specified as an argument
+            is too small to contain at least one entry
+
 Severity   : enhancement
 Bugzilla   : 11548
 Description: Add LNET router traceability for debug purposes
 Severity   : enhancement
 Bugzilla   : 11548
 Description: Add LNET router traceability for debug purposes
index 9f7797d..87b7536 100644 (file)
@@ -252,6 +252,14 @@ ssize_t llu_iop_filldirentries(struct inode *ino, _SYSIO_OFF_T *basep,
                                                 le32_to_cpu(de->inode), d_type, &filled);
                                 if (over) {
                                         free_page(page);
                                                 le32_to_cpu(de->inode), d_type, &filled);
                                 if (over) {
                                         free_page(page);
+                                        /*
+                                         * if buffer overflow with no data
+                                         * returned yet, then report error
+                                         * instead of eof
+                                         */
+                                        if (filled == 0)
+                                                RETURN(-EINVAL);
+
                                         GOTO(done, 0);
                                 }
                         }
                                         GOTO(done, 0);
                                 }
                         }
index 16014bc..e46f480 100644 (file)
@@ -1333,6 +1333,46 @@ int t55(char *name)
         LEAVE();
 }
 
         LEAVE();
 }
 
+/*
+ * getdirentries should return -1 and set errno to EINVAL when the size
+ * specified as an argument is too small to contain at least one entry
+ * (see bugzilla ticket 12229)
+ */
+int t56(char *name)
+{
+        int fd;
+        size_t nbytes;
+        off_t basep = 0;
+        ssize_t rc = 0;
+        struct dirent dir;
+
+        ENTRY("getdirentries should fail if nbytes is too small");
+
+        /* Set count to be very small.  The result should be EINVAL */
+        nbytes = 8;
+
+        /* open the directory and call getdirentries */
+        fd = t_opendir(lustre_path);
+
+        rc = getdirentries(fd, (char *)&dir, nbytes, &basep);
+
+        if (rc != -1) {
+                printf("Test failed: getdirentries returned %d\n", rc);
+                t_close(fd);
+                return -1;
+        }
+        if (errno != EINVAL) {
+                printf("Test failed: getdirentries returned %d but errno is set"
+                                " to %d (should be EINVAL)\n", rc, errno);
+                t_close(fd);
+                return -1;
+        }
+        t_close(fd);
+
+        LEAVE();
+}
+
+
 extern void __liblustre_setup_(void);
 extern void __liblustre_cleanup_(void);
 
 extern void __liblustre_setup_(void);
 extern void __liblustre_cleanup_(void);
 
@@ -1380,6 +1420,7 @@ struct testlist {
         { t53, "53" },
         { t54, "54" },
         { t55, "55" },
         { t53, "53" },
         { t54, "54" },
         { t55, "55" },
+        { t56, "56" },
         { NULL, NULL }
 };
 
         { NULL, NULL }
 };