| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: fdisk.c,v 1.133 2011/08/27 20:49:03 christos Exp $ */ | | 1 | /* $NetBSD: fdisk.c,v 1.134 2011/08/28 15:46:26 gson Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Mach Operating System | | 4 | * Mach Operating System |
5 | * Copyright (c) 1992 Carnegie Mellon University | | 5 | * Copyright (c) 1992 Carnegie Mellon University |
6 | * All Rights Reserved. | | 6 | * All Rights Reserved. |
7 | * | | 7 | * |
8 | * Permission to use, copy, modify and distribute this software and its | | 8 | * Permission to use, copy, modify and distribute this software and its |
9 | * documentation is hereby granted, provided that both the copyright | | 9 | * documentation is hereby granted, provided that both the copyright |
10 | * notice and this permission notice appear in all copies of the | | 10 | * notice and this permission notice appear in all copies of the |
11 | * software, derivative works or modified versions, and any portions | | 11 | * software, derivative works or modified versions, and any portions |
12 | * thereof, and that both notices appear in supporting documentation. | | 12 | * thereof, and that both notices appear in supporting documentation. |
13 | * | | 13 | * |
14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | | 14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | /* | | 29 | /* |
30 | * 14-Dec-89 Robert Baron (rvb) at Carnegie-Mellon University | | 30 | * 14-Dec-89 Robert Baron (rvb) at Carnegie-Mellon University |
31 | * Copyright (c) 1989 Robert. V. Baron | | 31 | * Copyright (c) 1989 Robert. V. Baron |
32 | * Created. | | 32 | * Created. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #if HAVE_NBTOOL_CONFIG_H | | 35 | #if HAVE_NBTOOL_CONFIG_H |
36 | #include "nbtool_config.h" | | 36 | #include "nbtool_config.h" |
37 | #endif | | 37 | #endif |
38 | | | 38 | |
39 | #include <sys/cdefs.h> | | 39 | #include <sys/cdefs.h> |
40 | | | 40 | |
41 | #ifndef lint | | 41 | #ifndef lint |
42 | __RCSID("$NetBSD: fdisk.c,v 1.133 2011/08/27 20:49:03 christos Exp $"); | | 42 | __RCSID("$NetBSD: fdisk.c,v 1.134 2011/08/28 15:46:26 gson Exp $"); |
43 | #endif /* not lint */ | | 43 | #endif /* not lint */ |
44 | | | 44 | |
45 | #define MBRPTYPENAMES | | 45 | #define MBRPTYPENAMES |
46 | #include <sys/types.h> | | 46 | #include <sys/types.h> |
47 | #include <sys/param.h> | | 47 | #include <sys/param.h> |
48 | #include <sys/stat.h> | | 48 | #include <sys/stat.h> |
49 | #include <ctype.h> | | 49 | #include <ctype.h> |
50 | #include <err.h> | | 50 | #include <err.h> |
51 | #include <errno.h> | | 51 | #include <errno.h> |
52 | #include <fcntl.h> | | 52 | #include <fcntl.h> |
53 | #include <paths.h> | | 53 | #include <paths.h> |
54 | #include <stdarg.h> | | 54 | #include <stdarg.h> |
55 | #include <stddef.h> | | 55 | #include <stddef.h> |
| @@ -282,36 +282,36 @@ static int read_disk(daddr_t, void *); | | | @@ -282,36 +282,36 @@ static int read_disk(daddr_t, void *); |
282 | static int write_disk(daddr_t, void *); | | 282 | static int write_disk(daddr_t, void *); |
283 | static int get_params(void); | | 283 | static int get_params(void); |
284 | static int read_s0(daddr_t, struct mbr_sector *); | | 284 | static int read_s0(daddr_t, struct mbr_sector *); |
285 | static int write_mbr(void); | | 285 | static int write_mbr(void); |
286 | static int read_gpt(daddr_t, struct gpt_hdr *); | | 286 | static int read_gpt(daddr_t, struct gpt_hdr *); |
287 | static int delete_gpt(struct gpt_hdr *); | | 287 | static int delete_gpt(struct gpt_hdr *); |
288 | static int yesno(const char *, ...); | | 288 | static int yesno(const char *, ...); |
289 | static int64_t decimal(const char *, int64_t, int, int64_t, int64_t); | | 289 | static int64_t decimal(const char *, int64_t, int, int64_t, int64_t); |
290 | #define DEC_SEC 1 /* asking for a sector number */ | | 290 | #define DEC_SEC 1 /* asking for a sector number */ |
291 | #define DEC_RND 2 /* round to end of first track */ | | 291 | #define DEC_RND 2 /* round to end of first track */ |
292 | #define DEC_RND_0 4 /* convert 0 to size of a track */ | | 292 | #define DEC_RND_0 4 /* convert 0 to size of a track */ |
293 | #define DEC_RND_DOWN 8 /* subtract 1 track */ | | 293 | #define DEC_RND_DOWN 8 /* subtract 1 track */ |
294 | #define DEC_RND_DOWN_2 16 /* subtract 2 tracks */ | | 294 | #define DEC_RND_DOWN_2 16 /* subtract 2 tracks */ |
295 | static void string(const char *, int, char *); | | | |
296 | static int ptn_id(const char *, int *); | | 295 | static int ptn_id(const char *, int *); |
297 | static int type_match(const void *, const void *); | | 296 | static int type_match(const void *, const void *); |
298 | static const char *get_type(int); | | 297 | static const char *get_type(int); |
299 | static int get_mapping(int, unsigned int *, unsigned int *, unsigned int *, unsigned long *); | | 298 | static int get_mapping(int, unsigned int *, unsigned int *, unsigned int *, unsigned long *); |
300 | #ifdef BOOTSEL | | 299 | #ifdef BOOTSEL |
301 | static daddr_t configure_bootsel(daddr_t); | | 300 | static daddr_t configure_bootsel(daddr_t); |
302 | static void install_bootsel(int); | | 301 | static void install_bootsel(int); |
303 | static daddr_t get_default_boot(void); | | 302 | static daddr_t get_default_boot(void); |
304 | static void set_default_boot(daddr_t); | | 303 | static void set_default_boot(daddr_t); |
| | | 304 | static void string(const char *, int, char *); |
305 | #endif | | 305 | #endif |
306 | | | 306 | |
307 | static void | | 307 | static void |
308 | initvar_disk(const char **diskp) | | 308 | initvar_disk(const char **diskp) |
309 | { | | 309 | { |
310 | #if !HAVE_NBTOOL_CONFIG_H | | 310 | #if !HAVE_NBTOOL_CONFIG_H |
311 | int mib[2]; | | 311 | int mib[2]; |
312 | size_t len; | | 312 | size_t len; |
313 | char *root_device; | | 313 | char *root_device; |
314 | | | 314 | |
315 | mib[0] = CTL_KERN; | | 315 | mib[0] = CTL_KERN; |
316 | mib[1] = KERN_ROOT_DEVICE; | | 316 | mib[1] = KERN_ROOT_DEVICE; |
317 | if (sysctl(mib, 2, NULL, &len, NULL, 0) == -1 || | | 317 | if (sysctl(mib, 2, NULL, &len, NULL, 0) == -1 || |