light clean; make sure headers are properly included, types are OK, etc.

use UNALINGNED_ACCESS macro, to determine how to get at fields.
This commit is contained in:
cgd 1994-10-29 07:59:27 +00:00
parent be8c7b9d80
commit f704435aa1
5 changed files with 111 additions and 112 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bootsect.h,v 1.5 1994/10/28 22:40:46 mycroft Exp $ */
/* $NetBSD: bootsect.h,v 1.6 1994/10/29 07:59:27 cgd Exp $ */
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
@ -22,28 +22,28 @@
* first sector of a partitioned hard disk.
*/
struct bootsector33 {
u_char bsJump[3]; /* jump instruction E9xxxx or EBxx90 */
char bsOemName[8]; /* OEM name and version */
char bsBPB[19]; /* BIOS parameter block */
char bsDriveNumber; /* drive number (0x80) */
char bsBootCode[479]; /* pad so structure is 512 bytes long */
u_short bsBootSectSig;
u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */
int8_t bsOemName[8]; /* OEM name and version */
int8_t bsBPB[19]; /* BIOS parameter block */
int8_t bsDriveNumber; /* drive number (0x80) */
int8_t bsBootCode[479]; /* pad so struct is 512b */
u_int16_t bsBootSectSig;
#define BOOTSIG 0xaa55
};
struct bootsector50 {
u_char bsJump[3]; /* jump instruction E9xxxx or EBxx90 */
char bsOemName[8]; /* OEM name and version */
char bsBPB[25]; /* BIOS parameter block */
char bsDriveNumber; /* drive number (0x80) */
char bsReserved1; /* reserved */
char bsBootSignature; /* extended boot signature (0x29) */
u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */
int8_t bsOemName[8]; /* OEM name and version */
int8_t bsBPB[25]; /* BIOS parameter block */
int8_t bsDriveNumber; /* drive number (0x80) */
int8_t bsReserved1; /* reserved */
int8_t bsBootSignature; /* ext. boot signature (0x29) */
#define EXBOOTSIG 0x29
char bsVolumeID[4]; /* volume ID number */
char bsVolumeLabel[11]; /* volume label */
char bsFileSysType[8]; /* file system type (FAT12 or FAT16) */
char bsBootCode[448]; /* pad so structure is 512 bytes long */
u_short bsBootSectSig;
int8_t bsVolumeID[4]; /* volume ID number */
int8_t bsVolumeLabel[11]; /* volume label */
int8_t bsFileSysType[8]; /* fs type (FAT12 or FAT16) */
int8_t bsBootCode[448]; /* pad so structure is 512b */
u_int16_t bsBootSectSig;
#define BOOTSIG 0xaa55
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: bpb.h,v 1.3 1994/06/29 06:35:29 cgd Exp $ */
/* $NetBSD: bpb.h,v 1.4 1994/10/29 07:59:29 cgd Exp $ */
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
@ -20,17 +20,17 @@
* BIOS Parameter Block (BPB) for DOS 3.3
*/
struct bpb33 {
u_short bpbBytesPerSec; /* bytes per sector */
u_char bpbSecPerClust; /* sectors per cluster */
u_short bpbResSectors; /* number of reserved sectors */
u_char bpbFATs; /* number of FATs */
u_short bpbRootDirEnts; /* number of root directory entries */
u_short bpbSectors; /* total number of sectors */
u_char bpbMedia; /* media descriptor */
u_short bpbFATsecs; /* number of sectors per FAT */
u_short bpbSecPerTrack; /* sectors per track */
u_short bpbHeads; /* number of heads */
u_short bpbHiddenSecs; /* number of hidden sectors */
u_int16_t bpbBytesPerSec; /* bytes per sector */
u_int8_t bpbSecPerClust; /* sectors per cluster */
u_int16_t bpbResSectors; /* number of reserved sectors */
u_int8_t bpbFATs; /* number of FATs */
u_int16_t bpbRootDirEnts; /* number of root directory entries */
u_int16_t bpbSectors; /* total number of sectors */
u_int8_t bpbMedia; /* media descriptor */
u_int16_t bpbFATsecs; /* number of sectors per FAT */
u_int16_t bpbSecPerTrack; /* sectors per track */
u_int16_t bpbHeads; /* number of heads */
u_int16_t bpbHiddenSecs; /* number of hidden sectors */
};
/*
@ -38,18 +38,18 @@ struct bpb33 {
* and bpbHugeSectors is not in the 3.3 bpb.
*/
struct bpb50 {
u_short bpbBytesPerSec; /* bytes per sector */
u_char bpbSecPerClust; /* sectors per cluster */
u_short bpbResSectors; /* number of reserved sectors */
u_char bpbFATs; /* number of FATs */
u_short bpbRootDirEnts; /* number of root directory entries */
u_short bpbSectors; /* total number of sectors */
u_char bpbMedia; /* media descriptor */
u_short bpbFATsecs; /* number of sectors per FAT */
u_short bpbSecPerTrack; /* sectors per track */
u_short bpbHeads; /* number of heads */
u_long bpbHiddenSecs; /* number of hidden sectors */
u_long bpbHugeSectors; /* number of sectrs if bpbSectors == 0 */
u_int16_t bpbBytesPerSec; /* bytes per sector */
u_int8_t bpbSecPerClust; /* sectors per cluster */
u_int16_t bpbResSectors; /* number of reserved sectors */
u_int8_t bpbFATs; /* number of FATs */
u_int16_t bpbRootDirEnts; /* number of root directory entries */
u_int16_t bpbSectors; /* total number of sectors */
u_int8_t bpbMedia; /* media descriptor */
u_int16_t bpbFATsecs; /* number of sectors per FAT */
u_int16_t bpbSecPerTrack; /* sectors per track */
u_int16_t bpbHeads; /* number of heads */
u_int32_t bpbHiddenSecs; /* # of hidden sectors */
u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
};
/*
@ -63,40 +63,39 @@ struct bpb50 {
* use the macros for the big-endian case.
*/
#include <machine/endian.h>
#if BYTE_ORDER == LITTLE_ENDIAN /* && can do unaligned accesses */
#define getushort(x) *((u_short *)(x))
#define getulong(x) *((u_long *)(x))
#define putushort(p, v) (*((u_short *)(p)) = (v))
#define putulong(p, v) (*((u_long *)(p)) = (v))
#if (BYTE_ORDER == LITTLE_ENDIAN) && defined(UNALIGNED_ACCESS)
#define getushort(x) *((u_int16_t *)(x))
#define getulong(x) *((u_int32_t *)(x))
#define putushort(p, v) (*((u_int16_t *)(p)) = (v))
#define putulong(p, v) (*((u_int32_t *)(p)) = (v))
#else
#define getushort(x) (((u_char *)(x))[0] + (((u_char *)(x))[1] << 8))
#define getulong(x) (((u_char *)(x))[0] + (((u_char *)(x))[1] << 8) \
+ (((u_char *)(x))[2] << 16) \
+ (((u_char *)(x))[3] << 24))
#define putushort(p, v) (((u_char *)(p))[0] = (v), \
((u_char *)(p))[1] = (v) >> 8)
#define putulong(p, v) (((u_char *)(p))[0] = (v), \
((u_char *)(p))[1] = (v) >> 8, \
((u_char *)(p))[2] = (v) >> 16,\
((u_char *)(p))[3] = (v) >> 24)
#define getushort(x) (((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8))
#define getulong(x) (((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8) \
+ (((u_int8_t *)(x))[2] << 16) \
+ (((u_int8_t *)(x))[3] << 24))
#define putushort(p, v) (((u_int8_t *)(p))[0] = (v), \
((u_int8_t *)(p))[1] = (v) >> 8)
#define putulong(p, v) (((u_int8_t *)(p))[0] = (v), \
((u_int8_t *)(p))[1] = (v) >> 8, \
((u_int8_t *)(p))[2] = (v) >> 16,\
((u_int8_t *)(p))[3] = (v) >> 24)
#endif
/*
* BIOS Parameter Block (BPB) for DOS 3.3
*/
struct byte_bpb33 {
char bpbBytesPerSec[2]; /* bytes per sector */
char bpbSecPerClust; /* sectors per cluster */
char bpbResSectors[2]; /* number of reserved sectors */
char bpbFATs; /* number of FATs */
char bpbRootDirEnts[2]; /* number of root directory entries */
char bpbSectors[2]; /* total number of sectors */
char bpbMedia; /* media descriptor */
char bpbFATsecs[2]; /* number of sectors per FAT */
char bpbSecPerTrack[2]; /* sectors per track */
char bpbHeads[2]; /* number of heads */
char bpbHiddenSecs[2]; /* number of hidden sectors */
int8_t bpbBytesPerSec[2]; /* bytes per sector */
int8_t bpbSecPerClust; /* sectors per cluster */
int8_t bpbResSectors[2]; /* number of reserved sectors */
int8_t bpbFATs; /* number of FATs */
int8_t bpbRootDirEnts[2]; /* number of root directory entries */
int8_t bpbSectors[2]; /* total number of sectors */
int8_t bpbMedia; /* media descriptor */
int8_t bpbFATsecs[2]; /* number of sectors per FAT */
int8_t bpbSecPerTrack[2]; /* sectors per track */
int8_t bpbHeads[2]; /* number of heads */
int8_t bpbHiddenSecs[2]; /* number of hidden sectors */
};
/*
@ -104,16 +103,16 @@ struct byte_bpb33 {
* and bpbHugeSectors is not in the 3.3 bpb.
*/
struct byte_bpb50 {
char bpbBytesPerSec[2]; /* bytes per sector */
char bpbSecPerClust; /* sectors per cluster */
char bpbResSectors[2]; /* number of reserved sectors */
char bpbFATs; /* number of FATs */
char bpbRootDirEnts[2]; /* number of root directory entries */
char bpbSectors[2]; /* total number of sectors */
char bpbMedia; /* media descriptor */
char bpbFATsecs[2]; /* number of sectors per FAT */
char bpbSecPerTrack[2]; /* sectors per track */
char bpbHeads[2]; /* number of heads */
char bpbHiddenSecs[4]; /* number of hidden sectors */
char bpbHugeSectors[4]; /* number of sectrs if bpbSectors == 0 */
int8_t bpbBytesPerSec[2]; /* bytes per sector */
int8_t bpbSecPerClust; /* sectors per cluster */
int8_t bpbResSectors[2]; /* number of reserved sectors */
int8_t bpbFATs; /* number of FATs */
int8_t bpbRootDirEnts[2]; /* number of root directory entries */
int8_t bpbSectors[2]; /* total number of sectors */
int8_t bpbMedia; /* media descriptor */
int8_t bpbFATsecs[2]; /* number of sectors per FAT */
int8_t bpbSecPerTrack[2]; /* sectors per track */
int8_t bpbHeads[2]; /* number of heads */
int8_t bpbHiddenSecs[4]; /* number of hidden sectors */
int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: direntry.h,v 1.7 1994/08/21 18:43:54 ws Exp $ */
/* $NetBSD: direntry.h,v 1.8 1994/10/29 07:59:31 cgd Exp $ */
/*-
* Copyright (C) 1994 Wolfgang Solfrank.
@ -51,24 +51,24 @@
* Structure of a dos directory entry.
*/
struct direntry {
u_char deName[8]; /* filename, blank filled */
#define SLOT_EMPTY 0x00 /* slot has never been used */
#define SLOT_E5 0x05 /* the real value is 0xe5 */
#define SLOT_DELETED 0xe5 /* file in this slot deleted */
u_char deExtension[3]; /* extension, blank filled */
u_char deAttributes; /* file attributes */
#define ATTR_NORMAL 0x00 /* normal file */
#define ATTR_READONLY 0x01 /* file is readonly */
#define ATTR_HIDDEN 0x02 /* file is hidden */
#define ATTR_SYSTEM 0x04 /* file is a system file */
#define ATTR_VOLUME 0x08 /* entry is a volume label */
#define ATTR_DIRECTORY 0x10 /* entry is a directory name */
#define ATTR_ARCHIVE 0x20 /* file is new or modified */
u_char deReserved[10]; /* reserved */
u_char deTime[2]; /* create/last update time */
u_char deDate[2]; /* create/last update date */
u_char deStartCluster[2]; /* starting cluster of file */
u_char deFileSize[4]; /* size of file in bytes */
u_int8_t deName[8]; /* filename, blank filled */
#define SLOT_EMPTY 0x00 /* slot has never been used */
#define SLOT_E5 0x05 /* the real value is 0xe5 */
#define SLOT_DELETED 0xe5 /* file in this slot deleted */
u_int8_t deExtension[3]; /* extension, blank filled */
u_int8_t deAttributes; /* file attributes */
#define ATTR_NORMAL 0x00 /* normal file */
#define ATTR_READONLY 0x01 /* file is readonly */
#define ATTR_HIDDEN 0x02 /* file is hidden */
#define ATTR_SYSTEM 0x04 /* file is a system file */
#define ATTR_VOLUME 0x08 /* entry is a volume label */
#define ATTR_DIRECTORY 0x10 /* entry is a directory name */
#define ATTR_ARCHIVE 0x20 /* file is new or modified */
u_int8_t deReserved[10]; /* reserved */
u_int8_t deTime[2]; /* create/last update time */
u_int8_t deDate[2]; /* create/last update date */
u_int8_t deStartCluster[2]; /* starting cluster of file */
u_int8_t deFileSize[4]; /* size of file in bytes */
};
/*
@ -96,8 +96,8 @@ struct direntry {
#define DD_YEAR_SHIFT 9
#ifdef KERNEL
void unix2dostime __P((struct timespec * tsp, u_short * ddp, u_short * dtp));
void dos2unixtime __P((u_short dd, u_short dt, struct timespec * tsp));
int dos2unixfn __P((u_char dn[11], u_char * un));
void unix2dosfn __P((u_char * un, u_char dn[11], int unlen));
void unix2dostime __P((struct timespec *tsp, u_int16_t *ddp, u_int16_t *dtp));
void dos2unixtime __P((u_int dd, u_int dt, struct timespec *tsp));
int dos2unixfn __P((u_char dn[11], u_char *un));
void unix2dosfn __P((u_char *un, u_char dn[11], int unlen));
#endif /* KERNEL */

View File

@ -1,4 +1,4 @@
/* $NetBSD: msdosfs_conv.c,v 1.8 1994/09/28 11:31:26 mycroft Exp $ */
/* $NetBSD: msdosfs_conv.c,v 1.9 1994/10/29 07:59:33 cgd Exp $ */
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
@ -60,8 +60,8 @@ u_short lastdtime;
void
unix2dostime(tsp, ddp, dtp)
struct timespec *tsp;
u_short *ddp;
u_short *dtp;
u_int16_t *ddp;
u_int16_t *dtp;
{
u_long t;
u_long days;
@ -134,8 +134,8 @@ u_long lastseconds;
*/
void
dos2unixtime(dd, dt, tsp)
u_short dd;
u_short dt;
u_int dd;
u_int dt;
struct timespec *tsp;
{
u_long seconds;

View File

@ -1,4 +1,4 @@
/* $NetBSD: msdosfs_fat.c,v 1.13 1994/09/28 11:31:29 mycroft Exp $ */
/* $NetBSD: msdosfs_fat.c,v 1.14 1994/10/29 07:59:35 cgd Exp $ */
/*-
* Copyright (C) 1994 Wolfgang Solfrank.
@ -361,7 +361,7 @@ updatefats(pmp, bp, fatbn)
* Where n is even. m = n + (n >> 2)
*
*/
extern __inline void
__inline void
usemap_alloc(pmp, cn)
struct msdosfsmount *pmp;
u_long cn;
@ -371,7 +371,7 @@ usemap_alloc(pmp, cn)
pmp->pm_freeclustercount--;
}
extern __inline void
__inline void
usemap_free(pmp, cn)
struct msdosfsmount *pmp;
u_long cn;