xref: /titanic_50/usr/src/cmd/fs.d/pcfs/fsck/pcfs_common.h (revision 2df1fe9ca32bb227b9158c67f5c00b54c20b10fd)
1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1999 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _PCFS_COMMON_H
28 #define	_PCFS_COMMON_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Common routines for the pcfs user-level utilities
34  */
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <sys/isa_defs.h>
41 #include <sys/types.h>
42 #include <sys/stat.h>
43 #include "pcfs_bpb.h"
44 
45 /*
46  *  A macro implementing a ceiling function for integer divides.
47  */
48 #define	idivceil(dvend, dvsor) \
49 	((dvend)/(dvsor) + (((dvend)%(dvsor) == 0) ? 0 : 1))
50 
51 /*
52  * These defines should move into a kernel header file eventually
53  * and pcfs_mount may want to refuse to mount FAT32's that aren't "clean"
54  *
55  *	If Windows shuts down properly it sets the fourth bit of the 8th
56  *	and final reserved byte at the start of the FAT.
57  */
58 #define	WIN_SHUTDOWN_STATUS_BYTE	7
59 #define	WIN_SHUTDOWN_BIT_MASK		0x8
60 
61 /*
62  *  Define some special logical drives we use.
63  */
64 #define	BOOT_PARTITION_DRIVE	99
65 #define	PRIMARY_DOS_DRIVE	1
66 
67 /*
68  * Function prototypes
69  */
70 extern off64_t findPartitionOffset(int fd, char *ldrive);
71 extern char *stat_actual_disk(char *diskname, struct stat *info, char **suffix);
72 extern void header_for_dump(void);
73 extern void store_16_bits(uchar_t **bp, uint32_t v);
74 extern void store_32_bits(uchar_t **bp, uint32_t v);
75 extern void read_16_bits(uchar_t *bp, uint32_t *value);
76 extern void read_32_bits(uchar_t *bp, uint32_t *value);
77 extern void missing_arg(char *option);
78 extern void dump_bytes(uchar_t *b, int n);
79 extern void bad_arg(char *option);
80 extern void usage(void);
81 extern int  is_z_a_power_of_x_le_y(int x, int y, int z);
82 extern int  yes(void);
83 
84 /*
85  *	The assumption here is that _BIG_ENDIAN implies sparc, and
86  *	so in addition to swapping bytes we also have to construct
87  *	packed structures by hand to avoid bus errors due to improperly
88  *	aligned pointers.
89  */
90 #ifdef _BIG_ENDIAN
91 extern void swap_pack_grab32bpb(bpb_t *wbpb, struct _boot_sector *bsp);
92 extern void swap_pack_grabbpb(bpb_t *wbpb, struct _boot_sector *bsp);
93 #endif	/* _BIG_ENDIAN */
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* _PCFS_COMMON_H */
100