cgsecurity / testdisk

TestDisk & PhotoRec
https://www.cgsecurity.org/
GNU General Public License v2.0
1.58k stars 195 forks source link

Minor: % calculated incorrectly? #12

Closed keflavich closed 7 years ago

keflavich commented 8 years ago

I'm running an Analyse, and the percentage doesn't seem to be updating correctly:

Disk /dev/disk2s1 - 8001 GB / 7452 GiB - 1953503744 sectors
Analyse sector   101449728/1953503743: 00%

101449728/1953503743 = 0.0519, so it should say 5% instead of 0%

I can't see any problem in the associated line: https://github.com/cgsecurity/testdisk/blob/d01e793ca4019f06480484a9d89942df6e6ddd8b/src/godmode.c#L629, but maybe there's a subtle rounding issue here? Are the order of operations somehow wrong, perhaps calculating 100/disk size as zero? That looks like it shouldn't happen, but it's all I can think of.

cgsecurity commented 8 years ago

Can you confirm that the problem is fixed by using

wprintw(stdscr,"Analyse sector %11llu/%llu: %02u%%",
          (long long unsigned)(search_location / disk_car->sector_size),
          (long long unsigned)((disk_car->disk_size-1)/disk_car->sector_size),
            (unsigned int)(search_location*100/disk_car->disk_size));
keflavich commented 8 years ago

I'll check later today if my current process finishes; however I don't know how long that's likely to be:

Analyse sector  1023967232/1953503743: 00%

now I'm 500% done...

keflavich commented 8 years ago

@cgsecurity do you have any idea how I might translate my current #'s into a % complete? If this is going to take another day, I'll let it finish, but if it's a week I should cancel.

cgsecurity commented 8 years ago

1023967232/1953503743=52% (not 500%). It looks like you are half way to completion

keflavich commented 8 years ago

Thanks, that was dumb - looks like a copy & paste error on my part.

keflavich commented 8 years ago

It finished with the message "The following partition can't be recovered:", unfortunately.

I still would like to test your fix for the percentage, but there is no configure in the repository, so I am unable to follow these instructions.

I tried running autoconf to generate the configure from configure.ac and received this error:

$ autoconf
configure.ac:17: error: possibly undefined macro: AM_INIT_AUTOMAKE
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:314: error: possibly undefined macro: AM_CONDITIONAL

I'm on a Mac, and I believe I have the requisite tools installed, but I have little experience compiling C code. Could you perhaps update the documentation to include building the configure file, or just add it to the repository?

keflavich commented 8 years ago

I successfully built a ./configure file using the command autoconf -ibut then hit a QT related issue, which isn't one of the listed dependencies, so I suspect I did something wrong:

./configure: line 8208: syntax error near unexpected token `QTGUI,'
./configure: line 8208: `  PKG_CHECK_MODULES(QTGUI, Qt5Gui  >= 5.0.0,,use_qt=false)'
cgsecurity commented 8 years ago

My fault, Qt5 wasn't listed in https://www.cgsecurity.org/wiki/TestDisk_Compilation. Corrected.

I have uploaded a new 7.1-WIP with the fix for wprintw. Can you try it ?

keflavich commented 8 years ago

Hmm, ok, how can I configure (or make the configure file) excluding qt? I don't need QPhotoRec, just testdisk, but I still have the QT-related error.

Also, the installation instructions say to do ./configure; make, but ./compile.sh seems to be the correct script to run.

EDIT: nevermind; I had to autoreconf -i to make configure in order to make compile.sh work.

keflavich commented 8 years ago

I commented out the offending lines 8208 and 8209 and re-ran configure, which seems to have worked.

keflavich commented 8 years ago

Looks like your edit fixes the problem: Analyse sector 7813988352/7814037166: 99%

Thanks!