]> www.infradead.org Git - mtd-utils.git/commitdiff
fs-tests: integck: do not expect max name length to be 256
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 13 Apr 2011 14:21:05 +0000 (17:21 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Mon, 18 Apr 2011 14:44:46 +0000 (17:44 +0300)
The 'make_name()' function assumes that the maxumum file name length
is 256 bytes, which is wrong. This patch fixes this.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
tests/fs-tests/integrity/integck.c

index 387874c154150c03983cfb133794e14803e90323..61fb12c5944e43cc59343e54cee4aa19c123ba85 100644 (file)
@@ -202,6 +202,11 @@ static uint64_t operation_count = 0; /* Number of operations used to fill
                                         up the file system */
 static unsigned int check_run_no;
 
+/*
+ * A buffer which is used by 'make_name()' to return the generated random name.
+ */
+static char *random_name_buf;
+
 /*
  * Is this 'struct write_info' actually holds information about a truncation?
  */
@@ -1451,7 +1456,6 @@ static void close_open_files(void)
 
 static char *make_name(struct dir_info *dir)
 {
-       static char name[256];
        struct dir_entry_info *entry;
        int found;
 
@@ -1460,20 +1464,20 @@ static char *make_name(struct dir_info *dir)
                if (random_no(5) == 1) {
                        int i, n = random_no(fsinfo.max_name_len) + 1;
 
-                       CHECK(n > 0 && n < 256);
                        for (i = 0; i < n; i++)
-                               name[i] = 'a' + random_no(26);
-                       name[i] = '\0';
+                               random_name_buf[i] = 'a' + random_no(26);
+                       random_name_buf[i] = '\0';
                } else
-                       sprintf(name, "%u", random_no(1000000));
+                       sprintf(random_name_buf, "%u", random_no(1000000));
                for (entry = dir->first; entry; entry = entry->next) {
-                       if (strcmp(entry->name, name) == 0) {
+                       if (strcmp(entry->name, random_name_buf) == 0) {
                                found = 1;
                                break;
                        }
                }
        } while (found);
-       return name;
+
+       return random_name_buf;
 }
 
 static struct file_info *pick_file(void)
@@ -2417,6 +2421,9 @@ int main(int argc, char *argv[])
        /* Seed the random generator with out PID */
        srand(getpid());
 
+       random_name_buf = malloc(fsinfo.max_name_len + 1);
+       CHECK(random_name_buf != NULL);
+
        /* Do the actual test */
        ret = integck();
        if (ret)