4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2011 Gary Mills
25 * Copyright (c) 1999 by Sun Microsystems, Inc.
26 * All rights reserved.
29 #ifndef _PCFS_COMMON_H
30 #define _PCFS_COMMON_H
33 * Common routines for the pcfs user-level utilities
40 #include <sys/isa_defs.h>
41 #include <sys/types.h>
43 #include <sys/sysmacros.h>
46 #define IN_RANGE(n, x, y) (((n) >= (x)) && ((n) <= (y)))
49 * A macro implementing a ceiling function for integer divides.
51 #define idivceil(dvend, dvsor) \
52 ((dvend)/(dvsor) + (((dvend)%(dvsor) == 0) ? 0 : 1))
55 * These defines should move into a kernel header file eventually
56 * and pcfs_mount may want to refuse to mount FAT32's that aren't "clean"
58 * If Windows shuts down properly it sets the fourth bit of the 8th
59 * and final reserved byte at the start of the FAT.
61 #define WIN_SHUTDOWN_STATUS_BYTE 7
62 #define WIN_SHUTDOWN_BIT_MASK 0x8
65 * Define some special logical drives we use.
67 #define BOOT_PARTITION_DRIVE 99
68 #define PRIMARY_DOS_DRIVE 1
73 extern off64_t
findPartitionOffset(int fd
, char *ldrive
);
74 extern char *stat_actual_disk(char *diskname
, struct stat
*info
, char **suffix
);
75 extern void header_for_dump(void);
76 extern void store_16_bits(uchar_t
**bp
, uint32_t v
);
77 extern void store_32_bits(uchar_t
**bp
, uint32_t v
);
78 extern void read_16_bits(uchar_t
*bp
, uint32_t *value
);
79 extern void read_32_bits(uchar_t
*bp
, uint32_t *value
);
80 extern void missing_arg(char *option
);
81 extern void dump_bytes(uchar_t
*b
, int n
);
82 extern void bad_arg(char *option
);
83 extern void usage(void);
87 * The assumption here is that _BIG_ENDIAN implies sparc, and
88 * so in addition to swapping bytes we also have to construct
89 * packed structures by hand to avoid bus errors due to improperly
93 extern void swap_pack_grab32bpb(bpb_t
*wbpb
, struct _boot_sector
*bsp
);
94 extern void swap_pack_grabbpb(bpb_t
*wbpb
, struct _boot_sector
*bsp
);
95 #endif /* _BIG_ENDIAN */
101 #endif /* _PCFS_COMMON_H */