From dbfbe688d0bf0224d7a6db2371ca13dba041aecd Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sat, 11 Jul 1998 03:48:25 +0000 Subject: always return TOC information in big-endian order; problem noted by csapuntz@lcs.mit.edu --- sys/dev/atapi/acd.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'sys') diff --git a/sys/dev/atapi/acd.c b/sys/dev/atapi/acd.c index 43273d1cd5a..886f72de68c 100644 --- a/sys/dev/atapi/acd.c +++ b/sys/dev/atapi/acd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acd.c,v 1.30 1998/06/09 13:29:57 provos Exp $ */ +/* $OpenBSD: acd.c,v 1.31 1998/07/11 03:48:24 deraadt Exp $ */ /* * Copyright (c) 1996 Manuel Bouyer. All rights reserved. @@ -796,12 +796,8 @@ acdioctl(dev, cmd, addr, flag, p) error = acd_read_toc(acd, 0, 0, &hdr, sizeof(hdr)); if (error) return error; - if (acd->ad_link->quirks & AQUIRK_LITTLETOC) { -#if BYTE_ORDER == BIG_ENDIAN + if (acd->ad_link->quirks & AQUIRK_LITTLETOC) bswap((u_int8_t *)&hdr.len, sizeof(hdr.len)); -#endif - } else - hdr.len = ntohs(hdr.len); bcopy(&hdr, addr, sizeof(hdr)); return 0; } @@ -830,26 +826,16 @@ acdioctl(dev, cmd, addr, flag, p) th->ending_track - th->starting_track + 1; ntracks >= 0; ntracks--) { toc.tab[ntracks].addr_type = CD_LBA_FORMAT; - if (acd->ad_link->quirks & AQUIRK_LITTLETOC) { -#if BYTE_ORDER == BIG_ENDIAN + if (acd->ad_link->quirks & AQUIRK_LITTLETOC) bswap((u_int8_t*) &toc.tab[ntracks].addr.addr, - sizeof(toc.tab[ntracks].addr.addr) - ); -#endif - } else - toc.tab[ntracks].addr.lba = - ntohl(toc.tab[ntracks].addr.lba); + sizeof(toc.tab[ntracks].addr.addr)); } } - if (acd->ad_link->quirks & AQUIRK_LITTLETOC) { -#if BYTE_ORDER == BIG_ENDIAN + if (acd->ad_link->quirks & AQUIRK_LITTLETOC) bswap((u_int8_t*)&th->len, sizeof(th->len)); -#endif - } else - th->len = ntohs(th->len); - len = min(len, th->len - sizeof(struct ioc_toc_header)); + len = min(len, ntohs(th->len) - sizeof(struct ioc_toc_header)); return copyout(toc.tab, te->data, len); } -- cgit v1.2.3