Fix for file injection is broken on centos computes with Cirros images LP #1587960
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / fis / 0004-sorted_list.patch
1 --- fis.orig/fis.c      2010-05-12 11:09:22.000000000 -0700
2 +++ fis/fis.c   2010-05-12 11:05:45.000000000 -0700
3 @@ -401,9 +401,24 @@
4    dir_t dir;
5    load_dir(fd,offset,&size,swap_endianness,&dir);
6    fprintf(stdout,"Name              FLASH addr  Mem addr    Length      Entry point Checksum\n");
7 -  FOR_EACH_DIR_ENTRY(dir,i) {
8 -    dump_desc(stdout,get(i));
9 -  }
10 +  uint32_t last_addr = 0;
11 +  bool image_found;
12 +  do {
13 +    uint32_t lowest_addr = 0xffffffff;
14 +    iter_t index;
15 +    image_found = false;
16 +    FOR_EACH_DIR_ENTRY(dir,i) {
17 +      const struct fis_image_desc *d = get(i);
18 +      if ((d->flash_base >= last_addr) && (d->flash_base < lowest_addr)) {
19 +        lowest_addr = d->flash_base;
20 +        image_found = true;
21 +        index = i;
22 +      }
23 +    }
24 +    if (image_found)
25 +      dump_desc(stdout,get(index));
26 +    last_addr = lowest_addr + 1;
27 +  } while (image_found == true);
28  }
29  
30