From 43decb5384df1140a7b2f1b40afdc1179b5e37f8 Mon Sep 17 00:00:00 2001 From: Gary Palmer Date: Sun, 19 Feb 1995 10:36:17 +0000 Subject: [PATCH] Bruces fixes for large filesystems Submitted by: Bruce Evans --- sys/i386/include/param.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/i386/include/param.h b/sys/i386/include/param.h index a127d5f58a62..ed5f67fd5ad8 100644 --- a/sys/i386/include/param.h +++ b/sys/i386/include/param.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)param.h 5.8 (Berkeley) 6/28/91 - * $Id: param.h,v 1.16 1994/09/18 22:05:22 bde Exp $ + * $Id: param.h,v 1.17 1995/01/23 19:21:49 davidg Exp $ */ #ifndef _MACHINE_PARAM_H_ @@ -134,18 +134,18 @@ /* bytes to clicks */ #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) -#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ - ((unsigned)(bytes) >> DEV_BSHIFT) -#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ - ((unsigned)(db) << DEV_BSHIFT) - /* - * Map a ``block device block'' to a file system block. - * This should be device dependent, and will be if we - * add an entry to cdevsw/bdevsw for that purpose. - * For now though just use DEV_BSIZE. + * This is messy and perhaps slow because `bytes' may be an off_t. We + * have to shift an unsigned type to avoid sign extension and we don't + * want to widen `bytes' unnecessarily. Assume that off_t is long long + * and daddr_t is unsigned long. */ -#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) +#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ + (sizeof (bytes) > sizeof(long) \ + ? (unsigned long)((unsigned long long)(bytes) >> DEV_BSHIFT) \ + : (unsigned long)((unsigned long)(bytes) >> DEV_BSHIFT)) +#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ + ((unsigned long long)(db) << DEV_BSHIFT) /* * Mach derived conversion macros