diff options
| author | Ron Yorston <rmy@pobox.com> | 2026-03-11 10:14:49 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2026-03-11 10:14:49 +0000 |
| commit | ede205bd07573813337b5706acb0cae3b127a36f (patch) | |
| tree | 1f79073ae9b7fa6fc8bd6b5f090380fd972f77dc /util-linux | |
| parent | b8b19b18ad8f189e1a6f52043dabe8d38d19b883 (diff) | |
| parent | e527bd22dbda697d09d4dff8786c6290d79d577a (diff) | |
| download | busybox-w32-ede205bd07573813337b5706acb0cae3b127a36f.tar.gz busybox-w32-ede205bd07573813337b5706acb0cae3b127a36f.tar.bz2 busybox-w32-ede205bd07573813337b5706acb0cae3b127a36f.zip | |
Merge branch 'busybox' into merge
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/fdisk.c | 17 | ||||
| -rw-r--r-- | util-linux/fdisk_gpt.c | 16 |
2 files changed, 22 insertions, 11 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 6611d3954..5ab350c74 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
| @@ -93,7 +93,7 @@ | |||
| 93 | 93 | ||
| 94 | //usage:#define fdisk_trivial_usage | 94 | //usage:#define fdisk_trivial_usage |
| 95 | //usage: "[-ul" IF_FEATURE_FDISK_BLKSIZE("s") "] " | 95 | //usage: "[-ul" IF_FEATURE_FDISK_BLKSIZE("s") "] " |
| 96 | //usage: "[-C CYLINDERS] [-H HEADS] [-S SECTORS] [-b SSZ] DISK" | 96 | //usage: "[-C CYLINDERS] [-H HEADS] [-S SECTORS] [-b SSZ] [-t PARTTYPE] DISK" |
| 97 | //usage:#define fdisk_full_usage "\n\n" | 97 | //usage:#define fdisk_full_usage "\n\n" |
| 98 | //usage: "Change partition table\n" | 98 | //usage: "Change partition table\n" |
| 99 | //usage: "\n -u Start and End are in sectors (instead of cylinders)" | 99 | //usage: "\n -u Start and End are in sectors (instead of cylinders)" |
| @@ -104,6 +104,7 @@ | |||
| 104 | //but in fact, util-linux 2.41.1 shows the size in KILOBYTES! | 104 | //but in fact, util-linux 2.41.1 shows the size in KILOBYTES! |
| 105 | //usage: ) | 105 | //usage: ) |
| 106 | //usage: "\n -b 2048 (for certain MO disks) use 2048-byte sectors" | 106 | //usage: "\n -b 2048 (for certain MO disks) use 2048-byte sectors" |
| 107 | //usage: "\n -T PARTTYPE Force 'dos' partition if 'gpt' also present" | ||
| 107 | //usage: "\n -C CYLINDERS Set number of cylinders/heads/sectors" | 108 | //usage: "\n -C CYLINDERS Set number of cylinders/heads/sectors" |
| 108 | //usage: "\n -H HEADS Typically 255" | 109 | //usage: "\n -H HEADS Typically 255" |
| 109 | //usage: "\n -S SECTORS Typically 63" | 110 | //usage: "\n -S SECTORS Typically 63" |
| @@ -186,7 +187,8 @@ enum { | |||
| 186 | OPT_l = 1 << 3, | 187 | OPT_l = 1 << 3, |
| 187 | OPT_S = 1 << 4, | 188 | OPT_S = 1 << 4, |
| 188 | OPT_u = 1 << 5, | 189 | OPT_u = 1 << 5, |
| 189 | OPT_s = (1 << 6) * ENABLE_FEATURE_FDISK_BLKSIZE, | 190 | OPT_t = 1 << 6, |
| 191 | OPT_s = (1 << 7) * ENABLE_FEATURE_FDISK_BLKSIZE, | ||
| 190 | }; | 192 | }; |
| 191 | #define USER_SET_SECTOR_SIZE (option_mask32 & OPT_b) | 193 | #define USER_SET_SECTOR_SIZE (option_mask32 & OPT_b) |
| 192 | #define NOWARN_OPT_ls (!ENABLE_FEATURE_FDISK_WRITABLE || (option_mask32 & (OPT_l|OPT_s))) | 194 | #define NOWARN_OPT_ls (!ENABLE_FEATURE_FDISK_WRITABLE || (option_mask32 & (OPT_l|OPT_s))) |
| @@ -464,6 +466,7 @@ struct globals { | |||
| 464 | sector_t extended_offset; /* offset of link pointers */ | 466 | sector_t extended_offset; /* offset of link pointers */ |
| 465 | sector_t total_number_of_sectors; | 467 | sector_t total_number_of_sectors; |
| 466 | 468 | ||
| 469 | const char *opt_t; | ||
| 467 | #if ENABLE_FEATURE_GPT_LABEL | 470 | #if ENABLE_FEATURE_GPT_LABEL |
| 468 | struct gpt_header *gpt_hdr; | 471 | struct gpt_header *gpt_hdr; |
| 469 | char *gpt_part_array; | 472 | char *gpt_part_array; |
| @@ -1209,7 +1212,7 @@ static void | |||
| 1209 | warn_cylinders(void) | 1212 | warn_cylinders(void) |
| 1210 | { | 1213 | { |
| 1211 | if (LABEL_IS_DOS && g_cylinders > 1024 && !NOWARN_OPT_ls) | 1214 | if (LABEL_IS_DOS && g_cylinders > 1024 && !NOWARN_OPT_ls) |
| 1212 | printf("\n" | 1215 | printf( |
| 1213 | "The number of cylinders for this disk is set to %u.\n" | 1216 | "The number of cylinders for this disk is set to %u.\n" |
| 1214 | "There is nothing wrong with that, but this is larger than 1024,\n" | 1217 | "There is nothing wrong with that, but this is larger than 1024,\n" |
| 1215 | "and could in certain setups cause problems with:\n" | 1218 | "and could in certain setups cause problems with:\n" |
| @@ -3064,10 +3067,14 @@ int fdisk_main(int argc UNUSED_PARAM, char **argv) | |||
| 3064 | 3067 | ||
| 3065 | close_dev_fd(); /* needed: fd 3 must not stay closed */ | 3068 | close_dev_fd(); /* needed: fd 3 must not stay closed */ |
| 3066 | 3069 | ||
| 3067 | opt = getopt32(argv, "^" "b:+C:+H:+lS:+u"IF_FEATURE_FDISK_BLKSIZE("s")"\0" | 3070 | //G.opt_t = NULL; |
| 3071 | opt = getopt32(argv, "^" "b:+C:+H:+lS:+ut:"IF_FEATURE_FDISK_BLKSIZE("s")"\0" | ||
| 3068 | /* among -s and -l, the last one takes precedence */ | 3072 | /* among -s and -l, the last one takes precedence */ |
| 3069 | IF_FEATURE_FDISK_BLKSIZE("s-l:l-s"), | 3073 | IF_FEATURE_FDISK_BLKSIZE("s-l:l-s"), |
| 3070 | §or_size, &user_cylinders, &user_heads, &user_sectors); | 3074 | §or_size, // -b |
| 3075 | &user_cylinders, &user_heads, &user_sectors, //-CHS | ||
| 3076 | &G.opt_t | ||
| 3077 | ); | ||
| 3071 | argv += optind; | 3078 | argv += optind; |
| 3072 | 3079 | ||
| 3073 | #if ENABLE_FEATURE_FDISK_BLKSIZE | 3080 | #if ENABLE_FEATURE_FDISK_BLKSIZE |
diff --git a/util-linux/fdisk_gpt.c b/util-linux/fdisk_gpt.c index c085af79c..696b4937c 100644 --- a/util-linux/fdisk_gpt.c +++ b/util-linux/fdisk_gpt.c | |||
| @@ -150,12 +150,13 @@ check_gpt_label(void) | |||
| 150 | struct pte pe; | 150 | struct pte pe; |
| 151 | uint32_t crc; | 151 | uint32_t crc; |
| 152 | 152 | ||
| 153 | current_label_type = LABEL_DOS; | ||
| 154 | |||
| 153 | /* LBA 0 contains the legacy MBR */ | 155 | /* LBA 0 contains the legacy MBR */ |
| 154 | 156 | ||
| 155 | if (!valid_part_table_flag(MBRbuffer) | 157 | if (!valid_part_table_flag(MBRbuffer) |
| 156 | || first->sys_ind != LEGACY_GPT_TYPE | 158 | || first->sys_ind != LEGACY_GPT_TYPE |
| 157 | ) { | 159 | ) { |
| 158 | current_label_type = LABEL_DOS; | ||
| 159 | return 0; | 160 | return 0; |
| 160 | } | 161 | } |
| 161 | 162 | ||
| @@ -165,7 +166,6 @@ check_gpt_label(void) | |||
| 165 | G.gpt_hdr = (void *)pe.sectorbuffer; | 166 | G.gpt_hdr = (void *)pe.sectorbuffer; |
| 166 | 167 | ||
| 167 | if (G.gpt_hdr->magic != SWAP_LE64(GPT_MAGIC)) { | 168 | if (G.gpt_hdr->magic != SWAP_LE64(GPT_MAGIC)) { |
| 168 | current_label_type = LABEL_DOS; | ||
| 169 | return 0; | 169 | return 0; |
| 170 | } | 170 | } |
| 171 | 171 | ||
| @@ -188,7 +188,6 @@ check_gpt_label(void) | |||
| 188 | || SWAP_LE32(G.gpt_hdr->hdr_size) > sector_size | 188 | || SWAP_LE32(G.gpt_hdr->hdr_size) > sector_size |
| 189 | ) { | 189 | ) { |
| 190 | puts("\nwarning: can't parse GPT disklabel"); | 190 | puts("\nwarning: can't parse GPT disklabel"); |
| 191 | current_label_type = LABEL_DOS; | ||
| 192 | return 0; | 191 | return 0; |
| 193 | } | 192 | } |
| 194 | 193 | ||
| @@ -204,10 +203,15 @@ check_gpt_label(void) | |||
| 204 | puts("\nwarning: GPT array CRC is invalid"); | 203 | puts("\nwarning: GPT array CRC is invalid"); |
| 205 | } | 204 | } |
| 206 | 205 | ||
| 207 | puts("Found valid GPT with protective MBR; using GPT"); | 206 | fputs_stdout("Found valid GPT with protective MBR; "); |
| 208 | 207 | ||
| 209 | current_label_type = LABEL_GPT; | 208 | if (!G.opt_t || strcasecmp(G.opt_t, "gpt") == 0) { |
| 210 | return 1; | 209 | puts("using GPT (-t dos to override)"); |
| 210 | current_label_type = LABEL_GPT; | ||
| 211 | return 1; | ||
| 212 | } | ||
| 213 | puts("NOT using it (-t specified)"); | ||
| 214 | return 0; | ||
| 211 | } | 215 | } |
| 212 | 216 | ||
| 213 | #endif /* GPT_LABEL */ | 217 | #endif /* GPT_LABEL */ |
