//usage: "[-C CYLINDERS] [-H HEADS] [-S SECTORS] [-b SSZ] DISK"
//usage:#define fdisk_full_usage "\n\n"
//usage: "Change partition table\n"
-//usage: "\nOptions:"
//usage: "\n -u Start and End are in sectors (instead of cylinders)"
//usage: "\n -l Show partition table for each DISK, then exit"
//usage: IF_FEATURE_FDISK_BLKSIZE(
}
}
+static void
+reread_partition_table(int leave)
+{
+ int i;
+
+ printf("Calling ioctl() to re-read partition table\n");
+ sync();
+ /* Users with slow external USB disks on a 320MHz ARM system (year 2011)
+ * report that sleep is needed, otherwise BLKRRPART may fail with -EIO:
+ */
+ sleep(1);
+ i = ioctl_or_perror(dev_fd, BLKRRPART, NULL,
+ "WARNING: rereading partition table "
+ "failed, kernel still uses old table");
+#if 0
+ if (dos_changed)
+ printf(
+ "\nWARNING: If you have created or modified any DOS 6.x\n"
+ "partitions, please see the fdisk manual page for additional\n"
+ "information\n");
+#endif
+
+ if (leave) {
+ if (ENABLE_FEATURE_CLEAN_UP)
+ close_dev_fd();
+ exit(i != 0);
+ }
+}
+
static void
write_table(void)
{
ptes[3].changed = 1;
for (i = 3; i < g_partitions; i++) {
struct pte *pe = &ptes[i];
-
if (pe->changed) {
write_part_table_flag(pe->sectorbuffer);
write_sector(pe->offset_from_dev_start, pe->sectorbuffer);
sgi_write_table();
}
else if (LABEL_IS_SUN) {
- int needw = 0;
-
- for (i = 0; i < 8; i++)
- if (ptes[i].changed)
- needw = 1;
- if (needw)
- sun_write_table();
+ for (i = 0; i < 8; i++) {
+ if (ptes[i].changed) {
+ sun_write_table();
+ break;
+ }
+ }
}
- printf("The partition table has been altered!\n\n");
+ printf("The partition table has been altered.\n");
reread_partition_table(1);
}
-
-static void
-reread_partition_table(int leave)
-{
- int i;
-
- printf("Calling ioctl() to re-read partition table\n");
- sync();
- /* sleep(2); Huh? */
- i = ioctl_or_perror(dev_fd, BLKRRPART, NULL,
- "WARNING: rereading partition table "
- "failed, kernel still uses old table");
-#if 0
- if (dos_changed)
- printf(
- "\nWARNING: If you have created or modified any DOS 6.x\n"
- "partitions, please see the fdisk manual page for additional\n"
- "information\n");
-#endif
-
- if (leave) {
- if (ENABLE_FEATURE_CLEAN_UP)
- close_dev_fd();
- exit(i != 0);
- }
-}
#endif /* FEATURE_FDISK_WRITABLE */
#if ENABLE_FEATURE_FDISK_ADVANCED
the process hangs on the attempt to read a music CD.
So try to be careful. This only works since 2.1.73. */
- if (strncmp("/dev/hd", device, 7))
+ if (!is_prefixed_with(device, "/dev/hd"))
return 0;
snprintf(buf, sizeof(buf), "/proc/ide/%s/media", device+5);
procf = fopen_for_read(buf);
if (procf != NULL && fgets(buf, sizeof(buf), procf))
- is_ide = (!strncmp(buf, "cdrom", 5) ||
- !strncmp(buf, "tape", 4));
+ is_ide = (is_prefixed_with(buf, "cdrom") ||
+ is_prefixed_with(buf, "tape"));
else
/* Now when this proc file does not exist, skip the
device when it is read-only. */
printf("\nThe current boot file is: %s\n",
sgi_get_bootfile());
if (read_maybe_empty("Please enter the name of the "
- "new boot file: ") == '\n')
+ "new boot file: ") == '\n')
printf("Boot file unchanged\n");
else
sgi_set_bootfile(line_ptr);
verify();
break;
case 'w':
- write_table(); /* does not return */
+ write_table(); /* does not return */
break;
#if ENABLE_FEATURE_FDISK_ADVANCED
case 'x':