FreeCalypso > hg > freecalypso-sw
diff ffstools/tiffs-rd/basics.c @ 243:43642cf7c98c
tiffs: added global option for offset of FFS within the file (new -o)
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 27 Jan 2014 03:46:11 +0000 |
parents | 73372cfdaf7f |
children | 475887e6b396 |
line wrap: on
line diff
--- a/ffstools/tiffs-rd/basics.c Mon Jan 27 03:05:56 2014 +0000 +++ b/ffstools/tiffs-rd/basics.c Mon Jan 27 03:46:11 2014 +0000 @@ -32,13 +32,19 @@ fprintf(stderr, "error: %s is not a regular file\n", imgfile); exit(1); } - if (st.st_size < total_ffs_size) { + if (st.st_size < imgfile_offset) { + fprintf(stderr, + "error: offset given with -o exceeds the size of the file\n"); + exit(1); + } + if (st.st_size - imgfile_offset < total_ffs_size) { fprintf(stderr, "error: %s is shorter than FFS size of 0x%lx bytes\n", imgfile, (u_long)total_ffs_size); exit(1); } - image = mmap(NULL, total_ffs_size, PROT_READ, MAP_PRIVATE, fd, 0); + image = mmap(NULL, total_ffs_size, PROT_READ, MAP_PRIVATE, fd, + imgfile_offset); if (image == MAP_FAILED) { perror("mmap"); exit(1);