diff options
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/fdisk.c | 68 | ||||
-rw-r--r-- | util-linux/fdisk_osf.c | 53 | ||||
-rw-r--r-- | util-linux/fdisk_sgi.c | 4 | ||||
-rw-r--r-- | util-linux/fdisk_sun.c | 4 | ||||
-rw-r--r-- | util-linux/mount.c | 2 |
5 files changed, 64 insertions, 67 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 2af5a41b9..e4f7e5455 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c @@ -220,8 +220,8 @@ static int get_boot(enum action what); } -static int32_t get_start_sect(const struct partition *p); -static int32_t get_nr_sects(const struct partition *p); +static unsigned get_start_sect(const struct partition *p); +static unsigned get_nr_sects(const struct partition *p); /* * per partition table entry data @@ -338,7 +338,9 @@ read_hex(const struct systypes *sys) continue; } v = bb_strtoul(line_ptr, NULL, 16); - if (errno || v > 0xff) continue; + if (v > 0xff) + /* Bad input also triggers this */ + continue; return v; } } @@ -393,15 +395,15 @@ STATIC_OSF void xbsd_print_disklabel(int); #define SGI_XLV 0x0c #define SGI_XVM 0x0d #define SGI_ENTIRE_DISK SGI_VOLUME -#if defined(CONFIG_FEATURE_SGI_LABEL) || defined(CONFIG_FEATURE_SUN_LABEL) +#if ENABLE_FEATURE_SGI_LABEL || ENABLE_FEATURE_SUN_LABEL static uint16_t -__swap16(uint16_t x) +fdisk_swap16(uint16_t x) { return (x << 8) | (x >> 8); } static uint32_t -__swap32(uint32_t x) +fdisk_swap32(uint32_t x) { return (x << 24) | ((x & 0xFF00) << 8) | @@ -578,7 +580,7 @@ set_start_sect(struct partition *p, unsigned start_sect) } #endif -static int32_t +static unsigned get_start_sect(const struct partition *p) { return read4_little_endian(p->start4); @@ -586,13 +588,13 @@ get_start_sect(const struct partition *p) #if ENABLE_FEATURE_FDISK_WRITABLE static void -set_nr_sects(struct partition *p, int32_t nr_sects) +set_nr_sects(struct partition *p, unsigned nr_sects) { store4_little_endian(p->size4, nr_sects); } #endif -static int32_t +static unsigned get_nr_sects(const struct partition *p) { return read4_little_endian(p->size4); @@ -1770,13 +1772,13 @@ change_sysid(void) #endif /* CONFIG_FEATURE_FDISK_WRITABLE */ -/* check_consistency() and long2chs() added Sat Mar 6 12:28:16 1993, +/* check_consistency() and linear2chs() added Sat Mar 6 12:28:16 1993, * faith@cs.unc.edu, based on code fragments from pfdisk by Gordon W. Ross, * Jan. 1990 (version 1.2.1 by Gordon W. Ross Aug. 1990; Modified by S. * Lubkin Oct. 1991). */ static void -long2chs(ulong ls, unsigned *c, unsigned *h, unsigned *s) +linear2chs(unsigned ls, unsigned *c, unsigned *h, unsigned *s) { int spc = heads * sectors; @@ -1808,10 +1810,10 @@ check_consistency(const struct partition *p, int partition) pes = p->end_sector & 0x3f; /* compute logical beginning (c, h, s) */ - long2chs(get_start_sect(p), &lbc, &lbh, &lbs); + linear2chs(get_start_sect(p), &lbc, &lbh, &lbs); /* compute logical ending (c, h, s) */ - long2chs(get_start_sect(p) + get_nr_sects(p) - 1, &lec, &leh, &les); + linear2chs(get_start_sect(p) + get_nr_sects(p) - 1, &lec, &leh, &les); /* Same physical / logical beginning? */ if (cylinders <= 1024 && (pbc != lbc || pbh != lbh || pbs != lbs)) { @@ -2479,46 +2481,40 @@ write_table(void) static void reread_partition_table(int leave) { - int error = 0; int i; - printf(_("Calling ioctl() to re-read partition table.\n")); + printf(_("Calling ioctl() to re-read partition table\n")); sync(); - sleep(2); - if ((i = ioctl(fd, BLKRRPART)) != 0) { - error = errno; - } else { + sleep(2); /* Huh? */ + i = ioctl(fd, BLKRRPART); +#if 0 + else { /* some kernel versions (1.2.x) seem to have trouble rereading the partition table, but if asked to do it twice, the second time works. - biro@yggdrasil.com */ sync(); sleep(2); - if ((i = ioctl(fd, BLKRRPART)) != 0) - error = errno; + i = ioctl(fd, BLKRRPART); } +#endif if (i) { - printf(_("\nWARNING: Re-reading the partition table " - "failed with error %d: %s.\n" - "The kernel still uses the old table.\n" - "The new table will be used " - "at the next reboot.\n"), - error, strerror(error)); + bb_perror_msg("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) { - close(fd); - - printf(_("Syncing disks.\n")); - sync(); - sleep(4); /* for sync() */ - exit(!!i); + if (ENABLE_FEATURE_CLEAN_UP) + close(fd); + exit(i != 0); } } #endif /* CONFIG_FEATURE_FDISK_WRITABLE */ @@ -2544,7 +2540,6 @@ print_buffer(char *pbuffer) puts(""); } - static void print_raw(void) { @@ -2728,7 +2723,8 @@ try(const char *device, int user_specified) if (!user_specified) if (is_ide_cdrom_or_tape(device)) return; - if ((fd = open(disk_device, type_open)) >= 0) { + fd = open(disk_device, type_open); + if (fd >= 0) { gb = get_boot(try_only); if (gb > 0) { /* I/O error */ close(fd); @@ -2861,7 +2857,7 @@ int fdisk_main(int argc, char **argv) type_open = O_RDONLY; if (argc > 0) { int k; -#if __GNUC__ +#if defined(__GNUC__) /* avoid gcc warning: variable `k' might be clobbered by `longjmp' */ (void)&k; diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c index bff2371e4..3d654d392 100644 --- a/util-linux/fdisk_osf.c +++ b/util-linux/fdisk_osf.c @@ -253,7 +253,7 @@ static void xbsd_change_fstype(void); static int xbsd_get_part_index(int max); static int xbsd_check_new_partition(int *i); static void xbsd_list_types(void); -static u_short xbsd_dkcksum(struct xbsd_disklabel *lp); +static uint16_t xbsd_dkcksum(struct xbsd_disklabel *lp); static int xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d); static int xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d); static int xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d); @@ -650,37 +650,38 @@ xbsd_edit_disklabel(void) d = &xbsd_dlabel; #if defined (__alpha__) || defined (__ia64__) - d->d_secsize = (u_long) edit_int((u_long) d->d_secsize ,_("bytes/sector")); - d->d_nsectors = (u_long) edit_int((u_long) d->d_nsectors ,_("sectors/track")); - d->d_ntracks = (u_long) edit_int((u_long) d->d_ntracks ,_("tracks/cylinder")); - d->d_ncylinders = (u_long) edit_int((u_long) d->d_ncylinders ,_("cylinders")); + d->d_secsize = edit_int(d->d_secsize ,_("bytes/sector")); + d->d_nsectors = edit_int(d->d_nsectors ,_("sectors/track")); + d->d_ntracks = edit_int(d->d_ntracks ,_("tracks/cylinder")); + d->d_ncylinders = edit_int(d->d_ncylinders ,_("cylinders")); #endif - /* d->d_secpercyl can be != d->d_nsectors * d->d_ntracks */ + /* d->d_secpercyl can be != d->d_nsectors * d->d_ntracks */ while (1) { - d->d_secpercyl = (u_long) edit_int((u_long) d->d_nsectors * d->d_ntracks, + d->d_secpercyl = edit_int(d->d_nsectors * d->d_ntracks, _("sectors/cylinder")); if (d->d_secpercyl <= d->d_nsectors * d->d_ntracks) break; printf(_("Must be <= sectors/track * tracks/cylinder (default).\n")); } - d->d_rpm = (u_short) edit_int((u_short) d->d_rpm ,_("rpm")); - d->d_interleave = (u_short) edit_int((u_short) d->d_interleave,_("interleave")); - d->d_trackskew = (u_short) edit_int((u_short) d->d_trackskew ,_("trackskew")); - d->d_cylskew = (u_short) edit_int((u_short) d->d_cylskew ,_("cylinderskew")); - d->d_headswitch = (u_long) edit_int((u_long) d->d_headswitch ,_("headswitch")); - d->d_trkseek = (u_long) edit_int((u_long) d->d_trkseek ,_("track-to-track seek")); + d->d_rpm = edit_int(d->d_rpm ,_("rpm")); + d->d_interleave = edit_int(d->d_interleave,_("interleave")); + d->d_trackskew = edit_int(d->d_trackskew ,_("trackskew")); + d->d_cylskew = edit_int(d->d_cylskew ,_("cylinderskew")); + d->d_headswitch = edit_int(d->d_headswitch,_("headswitch")); + d->d_trkseek = edit_int(d->d_trkseek ,_("track-to-track seek")); d->d_secperunit = d->d_secpercyl * d->d_ncylinders; } static int -xbsd_get_bootstrap (char *path, void *ptr, int size) +xbsd_get_bootstrap(char *path, void *ptr, int size) { int fdb; - if ((fdb = open (path, O_RDONLY)) < 0) { + fdb = open(path, O_RDONLY); + if (fdb < 0) { perror(path); return 0; } @@ -736,7 +737,7 @@ xbsd_write_bootstrap(void) snprintf(path, sizeof(path), "%s/boot%s", bootdir, dkbasename); if (!xbsd_get_bootstrap(path, &disklabelbuffer[xbsd_dlabel.d_secsize], - (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize)) + (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize)) return; e = d + sizeof(struct xbsd_disklabel); @@ -748,9 +749,9 @@ xbsd_write_bootstrap(void) memmove(d, &dl, sizeof(struct xbsd_disklabel)); -#if defined (__powerpc__) || defined (__hppa__) +#if defined(__powerpc__) || defined(__hppa__) sector = 0; -#elif defined (__alpha__) +#elif defined(__alpha__) sector = 0; alpha_bootblock_checksum(disklabelbuffer); #else @@ -762,11 +763,11 @@ xbsd_write_bootstrap(void) if (BSD_BBSIZE != write(fd, disklabelbuffer, BSD_BBSIZE)) fdisk_fatal(unable_to_write); -#if defined (__alpha__) +#if defined(__alpha__) printf(_("Bootstrap installed on %s.\n"), disk_device); #else printf(_("Bootstrap installed on %s.\n"), - partname (disk_device, xbsd_part_index+1, 0)); + partname(disk_device, xbsd_part_index+1, 0)); #endif sync_disks(); @@ -812,7 +813,7 @@ xbsd_check_new_partition(int *i) } } - *i = xbsd_get_part_index (BSD_MAXPARTITIONS); + *i = xbsd_get_part_index(BSD_MAXPARTITIONS); if (*i >= xbsd_dlabel.d_npartitions) xbsd_dlabel.d_npartitions = (*i) + 1; @@ -831,14 +832,14 @@ xbsd_list_types(void) list_types(xbsd_fstypes); } -static u_short +static uint16_t xbsd_dkcksum(struct xbsd_disklabel *lp) { - u_short *start, *end; - u_short sum = 0; + uint16_t *start, *end; + uint16_t sum = 0; - start = (u_short *) lp; - end = (u_short *) &lp->d_partitions[lp->d_npartitions]; + start = (uint16_t *) lp; + end = (uint16_t *) &lp->d_partitions[lp->d_npartitions]; while (start < end) sum ^= *start++; return sum; diff --git a/util-linux/fdisk_sgi.c b/util-linux/fdisk_sgi.c index 548a70bdc..7687103c9 100644 --- a/util-linux/fdisk_sgi.c +++ b/util-linux/fdisk_sgi.c @@ -84,8 +84,8 @@ typedef struct { #define SGI_INFO_MAGIC 0x00072959 #define SGI_INFO_MAGIC_SWAPPED 0x59290700 -#define SGI_SSWAP16(x) (sgi_other_endian ? __swap16(x) : (uint16_t)(x)) -#define SGI_SSWAP32(x) (sgi_other_endian ? __swap32(x) : (uint32_t)(x)) +#define SGI_SSWAP16(x) (sgi_other_endian ? fdisk_swap16(x) : (uint16_t)(x)) +#define SGI_SSWAP32(x) (sgi_other_endian ? fdisk_swap32(x) : (uint32_t)(x)) #define sgilabel ((sgi_partition *)MBRbuffer) #define sgiparam (sgilabel->devparam) diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c index 1e8f2e525..af85fb2c4 100644 --- a/util-linux/fdisk_sun.c +++ b/util-linux/fdisk_sun.c @@ -2,8 +2,8 @@ #define SUN_LABEL_MAGIC 0xDABE #define SUN_LABEL_MAGIC_SWAPPED 0xBEDA -#define SUN_SSWAP16(x) (sun_other_endian ? __swap16(x) : (uint16_t)(x)) -#define SUN_SSWAP32(x) (sun_other_endian ? __swap32(x) : (uint32_t)(x)) +#define SUN_SSWAP16(x) (sun_other_endian ? fdisk_swap16(x) : (uint16_t)(x)) +#define SUN_SSWAP32(x) (sun_other_endian ? fdisk_swap32(x) : (uint32_t)(x)) /* Copied from linux/major.h */ #define FLOPPY_MAJOR 2 diff --git a/util-linux/mount.c b/util-linux/mount.c index 35665a2b5..661e26f19 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -439,7 +439,7 @@ struct ppathcnf { short pc_name_max; short pc_path_max; short pc_pipe_buf; - u_char pc_vdisable; + uint8_t pc_vdisable; char pc_xxx; short pc_mask[2]; }; |