diff options
author | jncronin <jncronin@21779fe5-bacf-4c11-b3ef-82bd0e1f58e8> | 2015-03-14 13:43:18 +0000 |
---|---|---|
committer | jncronin <jncronin@21779fe5-bacf-4c11-b3ef-82bd0e1f58e8> | 2015-03-14 13:43:18 +0000 |
commit | dddbaa28144314924a4571474b2bd4f1168f18b6 (patch) | |
tree | 88f1476a24a88ad6b92eb13a300316b5b0fd1fa1 | |
parent | a7c0c3ce10b4a6a9a481ea486da625eac6ae3d58 (diff) | |
download | mkgpt-dddbaa28144314924a4571474b2bd4f1168f18b6.tar.gz |
gengc: added rudimentary collector
git-svn-id: https://www.tysos.org/svn/branches/tysila3/tload/mkgpt@600 21779fe5-bacf-4c11-b3ef-82bd0e1f58e8
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | mkgpt.c | 39 |
3 files changed, 38 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am index 04f820f..0e5bc1d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,5 +8,5 @@ LIBS = @LIBS@ bin_PROGRAMS = mkgpt mkgpt_SOURCES = mkgpt.c crc32.c fstypes.c guid.c -noinst_HEADERS = fstypes.h guid.h part.h mkgpt.vcxproj +noinst_HEADERS = fstypes.h guid.h part.h mkgpt.vcxproj README diff --git a/configure.ac b/configure.ac index 2e3c0b3..30319d9 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ([2.68]) -AC_INIT([mkgpt], [0.1]) +AC_INIT([mkgpt], [0.1a]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([mkgpt.c]) diff --git a/mkgpt.c b/mkgpt.c index 6ca6423..af83e8b 100644 --- a/mkgpt.c +++ b/mkgpt.c @@ -40,6 +40,7 @@ int CalculateCrc32 (uint8_t *Data, size_t DataSize, uint32_t *CrcOut); size_t sect_size = 512; long image_sects = 0; +long min_image_sects = 2048; PART *first_part = NULL; PART *last_part = NULL; FILE *output = NULL; @@ -148,6 +149,25 @@ int parse_opts(int argc, char **argv) } i++; } + else if(!strcmp(argv[i], "--minimum-image-size") || !strcmp(argv[i], "-s")) + { + i++; + if(i == argc || argv[i][0] == '-') + { + fprintf(stderr, "minimum image size not specified\n"); + return -1; + } + + min_image_sects = atoi(argv[i]); + + if(min_image_sects < 2048) + { + fprintf(stderr, "minimum image size must be at least 2048 sectors\n"); + return -1; + } + + i++; + } else if(!strcmp(argv[i], "--image-size")) { i++; @@ -313,9 +333,10 @@ int parse_opts(int argc, char **argv) void dump_help(char *fname) { - printf("Usage: %s -o <output_file> [-h] [--sector-size sect_size] [partition def 0] [part def 1] ... [part def n]\n", + printf("Usage: %s -o <output_file> [-h] [--sector-size sect_size] [-s min_image_size] [partition def 0] [part def 1] ... [part def n]\n" + " Partition definition: --part <image_file> --type <type> [--uuid uuid] [--name name]\n" + " Please see the README file for further information\n", fname); - } int parse_guid(char *str, GUID *guid) @@ -380,6 +401,13 @@ int check_parts() header_sectors = header_length / sect_size; if(header_length % sect_size) header_sectors++; + + /* The GPT entry array must be a minimum of 16,384 bytes (reports wikipedia + * and testdisk, but not the UEFI spec) + */ + if(header_sectors < (int)(16384 / sect_size)) + header_sectors = (int)(16384 / sect_size); + cur_sect += header_sectors; first_usable_sector = cur_sect; @@ -433,7 +461,12 @@ int check_parts() needed_file_length = cur_sect + 1 + header_sectors; if(image_sects == 0) - image_sects = needed_file_length; + { + if(needed_file_length > min_image_sects) + image_sects = needed_file_length; + else + image_sects = min_image_sects; + } else if(image_sects < needed_file_length) { fprintf(stderr, "requested image size (%lu) is too small to hold the partitions\n", image_sects * sect_size); |