[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: pread offset issues with new libc



>>>>> In <[🔎] 20021021183702.GB2295@kitenet.net> 
>>>>>	Joey Hess <joeyh@debian.org> wrote:

>> It seems that longrun and similar programs (procmeter3 longrun support,
>> etc) are broken by the new libc.

>> This program should read the transmeta vendor cpuid:

>> #define CPUID_DEVICE "/dev/cpu/0/cpuid"
>> #define CPUID_TMx86_VENDOR_ID 0x80860000
>>
>> #include <sys/types.h>
>> #include <sys/stat.h>
>> #include <fcntl.h>
>> #include <unistd.h>
>> #include <stdlib.h>
>> #include <stdint.h>
>>
>> main () {
>>         int fd = open(CPUID_DEVICE, O_RDONLY);
>>         uint32_t data[4];
>>
>>         if (pread(fd, &data, 16, CPUID_TMx86_VENDOR_ID) != 16) {
>>                 perror("pread");
>>         }
>> }

>> If I strace this, the pread looks like this:
>>
>> pread(3, 0xbffff834, 16, 18446744071570849792) = -1 EINVAL (Invalid argument)

 pread()'s last argument type is `off_t'.

 off_t is defined as (signed) long int.
 (without __USE_FILE_OFFSET64 define)

 long int is 32bit length on i386 environmet.

 So....

>> #define CPUID_TMx86_VENDOR_ID 0x8086000

 This number is too big.

 I don't know why there is no problem on the glibc 2.2.5 environmet,
but it is a bug of longrun, I think. I'll fix this.

-- 
ISHIKAWA Mutsumi
 <ishikawa@linux.or.jp>, <ishikawa@debian.org>, <ishikawa@netvillage.co.jp>



Reply to: