Strangeness in hdparm.c?
Tito
farmatito at tiscali.it
Mon May 29 07:01:34 PDT 2006
On Monday 29 May 2006 07:48, Rob Landley wrote:
> The function identify_from_stdin() reads 1280 bytes, and then processes 1600
> bytes. Huh?
>
> Rob
Latest hdparm 6.6 does this:
static int identify_from_stdin (void)
{
unsigned short sbuf[800];
unsigned char buf[1600], *b = (unsigned char *)buf;
int i, count;
// skip leading cruft
while (1 == read(0, buf, 1) && (*buf < '0' || *buf > '9') && (*buf < 'a' || *buf > 'f'))
while (1 == read(0, buf, 1) && *buf != '\n');
count = read(0, buf+1, 1279);
if (count != 1279) {
fprintf(stderr, "read(1279 bytes) failed (rc=%d)", count);
perror("");
exit(errno);
}
for (i = 0; count >= 4; ++i) {
sbuf[i] = (fromhex(b[0]) << 12) | (fromhex(b[1]) << 8) | (fromhex(b[2]) << 4) | fromhex(b[3]);
__le16_to_cpus((__u16 *)(&sbuf[i]));
b += 5;
count -= 5;
}
identify(sbuf);
return 0;
}
Should we busyboxify and sync?
Ciao,
Tito
More information about the busybox
mailing list