Hi Rafael!
Rafael J. Wysocki wrote:
The most recent version of the suspend package, located at:
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-utils.git
has all of these problems fixed.
I've taken a short look at this code and it isn't completely fixed. The
value shift in the functions reset_signature(), mark_signature(),
open_resume_dev() and read_image() is still only calculated as a 32 bit
value:
off64_t shift = (resume_offset + 1) * page_size - size;
Since resume_offset and page_size are both 32 bit values, the c compiler
will do the multiplication as a 32 bit value and in the end convert the
result to 64 bit. To solve the problem, one of the values must be
converted to 64 bit before the multiplication. I'd suggest using this:
off64_t shift = ( (off64_t) resume_offset + 1) * page_size - size;
I've attached a test program which calculates the value in both ways and
prints the result. Here is the output it generates:
SHIFT=1578110966
SHIFT=409600004086
I'd really appreciate if you could release a new version of the package.
Most users and linux distributors prefer to get the latest stable
version of software instead of downloading a (possibly unstable)
development version from a repository. The latest released version (0.8)
is two years old now and it probably contains many more bugs which have
been fixed since then.
Regards
Jakob
#define _LARGEFILE64_SOURCE
#include <sys/types.h>
#include <unistd.h>
int main(){
int resume_offset = 100000000;
int page_size = 4096;
int size = 10;
off64_t shift = (resume_offset + 1) * page_size - size;
printf("SHIFT=%lld\n",shift);
shift = ( (off64_t) resume_offset + 1) * page_size - size;
printf("SHIFT=%lld\n",shift);
}
_______________________________________________
linux-pm mailing list
linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/linux-pm