comparison 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
comparison
equal deleted inserted replaced
242:924a80747176 243:43642cf7c98c
30 fstat(fd, &st); 30 fstat(fd, &st);
31 if (!S_ISREG(st.st_mode)) { 31 if (!S_ISREG(st.st_mode)) {
32 fprintf(stderr, "error: %s is not a regular file\n", imgfile); 32 fprintf(stderr, "error: %s is not a regular file\n", imgfile);
33 exit(1); 33 exit(1);
34 } 34 }
35 if (st.st_size < total_ffs_size) { 35 if (st.st_size < imgfile_offset) {
36 fprintf(stderr,
37 "error: offset given with -o exceeds the size of the file\n");
38 exit(1);
39 }
40 if (st.st_size - imgfile_offset < total_ffs_size) {
36 fprintf(stderr, 41 fprintf(stderr,
37 "error: %s is shorter than FFS size of 0x%lx bytes\n", 42 "error: %s is shorter than FFS size of 0x%lx bytes\n",
38 imgfile, (u_long)total_ffs_size); 43 imgfile, (u_long)total_ffs_size);
39 exit(1); 44 exit(1);
40 } 45 }
41 image = mmap(NULL, total_ffs_size, PROT_READ, MAP_PRIVATE, fd, 0); 46 image = mmap(NULL, total_ffs_size, PROT_READ, MAP_PRIVATE, fd,
47 imgfile_offset);
42 if (image == MAP_FAILED) { 48 if (image == MAP_FAILED) {
43 perror("mmap"); 49 perror("mmap");
44 exit(1); 50 exit(1);
45 } 51 }
46 } 52 }