ip: use rtnl_send_check() on flush commands, closes 6962
[oweals/busybox.git] / util-linux / fdisk_osf.c
index 09a68da83758486ac8046123a9c3cd8134dee7a4..1328c1fcdcf374b9ec64eb15d263b433fc8c51dc 100644 (file)
@@ -18,7 +18,7 @@
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 
 #define BSD_LINUX_BOOTDIR "/usr/ucb/mdec"
 
-#if defined(i386) || defined(__sparc__) || defined(__arm__) \
- || defined(__m68k__) || defined(__mips__) || defined(__s390__) \
- || defined(__s390__) || defined(__s390x__) \
- || defined(__sh__) || defined(__x86_64__) || defined(__avr32__)
-# define BSD_LABELSECTOR   1
-# define BSD_LABELOFFSET   0
-#elif defined(__alpha__) || defined(__powerpc__) || defined(__ia64__) \
+#if defined(__alpha__) \
+ || defined(__powerpc__) \
+ || defined(__ia64__) \
  || defined(__hppa__)
 # define BSD_LABELSECTOR   0
 # define BSD_LABELOFFSET   64
 #else
-# error unknown architecture
+# define BSD_LABELSECTOR   1
+# define BSD_LABELOFFSET   0
 #endif
 
 #define BSD_BBSIZE        8192          /* size of boot area, with label */
@@ -369,10 +366,11 @@ bsd_select(void)
                        }
                                printf("Reading disklabel of %s at sector %u\n",
                                        partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR);
-                       if (xbsd_readlabel(xbsd_part) == 0)
+                       if (xbsd_readlabel(xbsd_part) == 0) {
                                if (xbsd_create_disklabel() == 0)
                                        return;
                                break;
+                       }
                }
        }
 
@@ -615,7 +613,7 @@ xbsd_create_disklabel(void)
 
        while (1) {
                c = read_nonempty("Do you want to create a disklabel? (y/n) ");
-               if (c == 'y' || c == 'Y') {
+               if ((c|0x20) == 'y') {
                        if (xbsd_initlabel(
 #if defined(__alpha__) || defined(__powerpc__) || defined(__hppa__) || \
        defined(__s390__) || defined(__s390x__)
@@ -629,7 +627,7 @@ xbsd_create_disklabel(void)
                        }
                        return 0;
                }
-               if (c == 'n')
+               if ((c|0x20) == 'n')
                        return 0;
        }
 }
@@ -711,6 +709,9 @@ sync_disks(void)
 static void
 xbsd_write_bootstrap(void)
 {
+#ifndef MAXPATHLEN
+# define MAXPATHLEN 1024
+#endif
        char path[MAXPATHLEN];
        const char *bootdir = BSD_LINUX_BOOTDIR;
        const char *dkbasename;
@@ -857,7 +858,7 @@ xbsd_initlabel(struct partition *p)
 
        d->d_magic = BSD_DISKMAGIC;
 
-       if (strncmp(disk_device, "/dev/sd", 7) == 0)
+       if (is_prefixed_with(disk_device, "/dev/sd"))
                d->d_type = BSD_DTYPE_SCSI;
        else
                d->d_type = BSD_DTYPE_ST506;
@@ -901,8 +902,7 @@ xbsd_initlabel(struct partition *p)
        pp->p_fstype = BSD_FS_UNUSED;
 #else
        d->d_npartitions = 3;
-       pp = &d->d_partitions[2];             /* Partition C should be
-                                                  the whole disk */
+       pp = &d->d_partitions[2]; /* Partition C should be the whole disk */
        pp->p_offset = 0;
        pp->p_size   = d->d_secperunit;
        pp->p_fstype = BSD_FS_UNUSED;
@@ -938,7 +938,7 @@ xbsd_readlabel(struct partition *p)
                fdisk_fatal(unable_to_read);
 
        memmove(d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
-                  sizeof(struct xbsd_disklabel));
+                       sizeof(struct xbsd_disklabel));
 
        if (d->d_magic != BSD_DISKMAGIC || d->d_magic2 != BSD_DISKMAGIC)
                return 0;
@@ -964,6 +964,7 @@ xbsd_writelabel(struct partition *p)
 #if !defined(__alpha__) && !defined(__powerpc__) && !defined(__hppa__)
        sector = get_start_sect(p) + BSD_LABELSECTOR;
 #else
+       (void)p; /* silence warning */
        sector = BSD_LABELSECTOR;
 #endif