u_short, ulong exterminated

fdiskXXX: add a bit of sanity (not enough by far)
This commit is contained in:
Denis Vlasenko 2006-12-19 20:32:02 +00:00
parent f58906b646
commit 28703015ab
11 changed files with 90 additions and 95 deletions

View File

@ -81,14 +81,14 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
struct unipair *up; struct unipair *up;
int ct = 0, maxct; int ct = 0, maxct;
int glyph; int glyph;
u_short unicode; uint16_t unicode;
maxct = tailsz; /* more than enough */ maxct = tailsz; /* more than enough */
up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair)); up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
for (glyph = 0; glyph < fontsize; glyph++) { for (glyph = 0; glyph < fontsize; glyph++) {
while (tailsz >= 2) { while (tailsz >= 2) {
unicode = (((u_short) inbuf[1]) << 8) + inbuf[0]; unicode = (((uint16_t) inbuf[1]) << 8) + inbuf[0];
tailsz -= 2; tailsz -= 2;
inbuf += 2; inbuf += 2;
if (unicode == PSF_SEPARATOR) if (unicode == PSF_SEPARATOR)

View File

@ -29,7 +29,7 @@ int loadkmap_main(int argc, char **argv)
{ {
struct kbentry ke; struct kbentry ke;
int i, j, fd; int i, j, fd;
u_short ibuff[NR_KEYS]; uint16_t ibuff[NR_KEYS];
char flags[MAX_NR_KEYMAPS]; char flags[MAX_NR_KEYMAPS];
char buff[7]; char buff[7];
@ -46,7 +46,7 @@ int loadkmap_main(int argc, char **argv)
for (i = 0; i < MAX_NR_KEYMAPS; i++) { for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) { if (flags[i] == 1) {
xread(0, ibuff, NR_KEYS * sizeof(u_short)); xread(0, ibuff, NR_KEYS * sizeof(uint16_t));
for (j = 0; j < NR_KEYS; j++) { for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j; ke.kb_index = j;
ke.kb_table = i; ke.kb_table = i;

View File

@ -985,7 +985,7 @@ static void config(int sig ATTRIBUTE_UNUSED)
} else } else
#endif #endif
{ {
u_short port = htons(atoi(sep->se_service)); uint16_t port = htons(atoi(sep->se_service));
// FIXME: atoi_or_else(str, 0) would be handy here // FIXME: atoi_or_else(str, 0) would be handy here
if (!port) { if (!port) {
/*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname)); /*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname));
@ -1037,8 +1037,8 @@ static void config(int sig ATTRIBUTE_UNUSED)
register_rpc(sep); register_rpc(sep);
} else } else
#endif #endif
{ {
u_short port = htons(atoi(sep->se_service)); uint16_t port = htons(atoi(sep->se_service));
if (!port) { if (!port) {
/*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname)); /*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname));

View File

@ -316,8 +316,8 @@ static int pmtu; /* Path MTU Discovery (RFC1191) */
static char *hostname; static char *hostname;
static u_short ident; static uint16_t ident;
static u_short port = 32768 + 666; /* start udp dest port # for probe packets */ static uint16_t port = 32768 + 666; /* start udp dest port # for probe packets */
static int waittime = 5; /* time to wait for response (in seconds) */ static int waittime = 5; /* time to wait for response (in seconds) */
static int nflag; /* print addresses numerically */ static int nflag; /* print addresses numerically */
@ -539,12 +539,12 @@ wait_for_reply(int sock, struct sockaddr_in *fromp, const struct timeval *tp)
/* /*
* Checksum routine for Internet Protocol family headers (C Version) * Checksum routine for Internet Protocol family headers (C Version)
*/ */
static u_short static uint16_t
in_cksum(u_short *addr, int len) in_cksum(uint16_t *addr, int len)
{ {
int nleft = len; int nleft = len;
u_short *w = addr; uint16_t *w = addr;
u_short answer; uint16_t answer;
int sum = 0; int sum = 0;
/* /*
@ -589,7 +589,7 @@ send_probe(int seq, int ttl, struct timeval *tp)
*/ */
if (doipcksum) { if (doipcksum) {
outip->ip_sum = outip->ip_sum =
in_cksum((u_short *)outip, sizeof(*outip) + optlen); in_cksum((uint16_t *)outip, sizeof(*outip) + optlen);
if (outip->ip_sum == 0) if (outip->ip_sum == 0)
outip->ip_sum = 0xffff; outip->ip_sum = 0xffff;
} }
@ -610,7 +610,7 @@ send_probe(int seq, int ttl, struct timeval *tp)
if (useicmp) { if (useicmp) {
/* Always calculate checksum for icmp packets */ /* Always calculate checksum for icmp packets */
outicmp->icmp_cksum = 0; outicmp->icmp_cksum = 0;
outicmp->icmp_cksum = in_cksum((u_short *)outicmp, outicmp->icmp_cksum = in_cksum((uint16_t *)outicmp,
packlen - (sizeof(*outip) + optlen)); packlen - (sizeof(*outip) + optlen));
if (outicmp->icmp_cksum == 0) if (outicmp->icmp_cksum == 0)
outicmp->icmp_cksum = 0xffff; outicmp->icmp_cksum = 0xffff;
@ -628,7 +628,7 @@ send_probe(int seq, int ttl, struct timeval *tp)
ui->ui_pr = oui->ui_pr; ui->ui_pr = oui->ui_pr;
ui->ui_len = outudp->len; ui->ui_len = outudp->len;
outudp->check = 0; outudp->check = 0;
outudp->check = in_cksum((u_short *)ui, packlen); outudp->check = in_cksum((uint16_t *)ui, packlen);
if (outudp->check == 0) if (outudp->check == 0)
outudp->check = 0xffff; outudp->check = 0xffff;
*outip = tip; *outip = tip;
@ -637,11 +637,11 @@ send_probe(int seq, int ttl, struct timeval *tp)
#if ENABLE_FEATURE_TRACEROUTE_VERBOSE #if ENABLE_FEATURE_TRACEROUTE_VERBOSE
/* XXX undocumented debugging hack */ /* XXX undocumented debugging hack */
if (verbose > 1) { if (verbose > 1) {
const u_short *sp; const uint16_t *sp;
int nshorts, i; int nshorts, i;
sp = (u_short *)outip; sp = (uint16_t *)outip;
nshorts = (u_int)packlen / sizeof(u_short); nshorts = (u_int)packlen / sizeof(uint16_t);
i = 0; i = 0;
printf("[ %d bytes", packlen); printf("[ %d bytes", packlen);
while (--nshorts >= 0) { while (--nshorts >= 0) {
@ -906,7 +906,7 @@ traceroute_main(int argc, char *argv[])
#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE #if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
int lsrr = 0; int lsrr = 0;
#endif #endif
u_short off = 0; uint16_t off = 0;
struct IFADDRLIST *al; struct IFADDRLIST *al;
char *device = NULL; char *device = NULL;
int max_ttl = 30; int max_ttl = 30;
@ -1137,17 +1137,15 @@ traceroute_main(int argc, char *argv[])
outicmp = (struct icmp *)outp; outicmp = (struct icmp *)outp;
outicmp->icmp_type = ICMP_ECHO; outicmp->icmp_type = ICMP_ECHO;
outicmp->icmp_id = htons(ident); outicmp->icmp_id = htons(ident);
outdata = (struct outdata *)(outp + 8); /* XXX magic number */ outdata = (struct outdata *)(outp + 8); /* XXX magic number */
} else } else
#endif #endif
{ {
outip->ip_p = IPPROTO_UDP; outip->ip_p = IPPROTO_UDP;
outudp = (struct udphdr *)outp; outudp = (struct udphdr *)outp;
outudp->source = htons(ident); outudp->source = htons(ident);
outudp->len = outudp->len = htons((uint16_t)(packlen - (sizeof(*outip) + optlen)));
htons((u_short)(packlen - (sizeof(*outip) + optlen)));
outdata = (struct outdata *)(outudp + 1); outdata = (struct outdata *)(outudp + 1);
} }

View File

@ -15,9 +15,9 @@
struct arpMsg { struct arpMsg {
/* Ethernet header */ /* Ethernet header */
u_char h_dest[6]; /* destination ether addr */ uint8_t h_dest[6]; /* destination ether addr */
u_char h_source[6]; /* source ether addr */ uint8_t h_source[6]; /* source ether addr */
u_short h_proto; /* packet type ID field */ uint16_t h_proto; /* packet type ID field */
/* ARP packet */ /* ARP packet */
uint16_t htype; /* hardware type (must be ARPHRD_ETHER) */ uint16_t htype; /* hardware type (must be ARPHRD_ETHER) */

View File

@ -103,7 +103,7 @@ static void xid_del(u_int32_t xid)
*/ */
static int get_dhcp_packet_type(struct dhcpMessage *p) static int get_dhcp_packet_type(struct dhcpMessage *p)
{ {
u_char *op; uint8_t *op;
/* it must be either a BOOTREQUEST or a BOOTREPLY */ /* it must be either a BOOTREQUEST or a BOOTREPLY */
if (p->op != BOOTREQUEST && p->op != BOOTREPLY) if (p->op != BOOTREQUEST && p->op != BOOTREPLY)

View File

@ -220,8 +220,8 @@ static int get_boot(enum action what);
} }
static int32_t get_start_sect(const struct partition *p); static unsigned get_start_sect(const struct partition *p);
static int32_t get_nr_sects(const struct partition *p); static unsigned get_nr_sects(const struct partition *p);
/* /*
* per partition table entry data * per partition table entry data
@ -338,7 +338,9 @@ read_hex(const struct systypes *sys)
continue; continue;
} }
v = bb_strtoul(line_ptr, NULL, 16); v = bb_strtoul(line_ptr, NULL, 16);
if (errno || v > 0xff) continue; if (v > 0xff)
/* Bad input also triggers this */
continue;
return v; return v;
} }
} }
@ -393,15 +395,15 @@ STATIC_OSF void xbsd_print_disklabel(int);
#define SGI_XLV 0x0c #define SGI_XLV 0x0c
#define SGI_XVM 0x0d #define SGI_XVM 0x0d
#define SGI_ENTIRE_DISK SGI_VOLUME #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 static uint16_t
__swap16(uint16_t x) fdisk_swap16(uint16_t x)
{ {
return (x << 8) | (x >> 8); return (x << 8) | (x >> 8);
} }
static uint32_t static uint32_t
__swap32(uint32_t x) fdisk_swap32(uint32_t x)
{ {
return (x << 24) | return (x << 24) |
((x & 0xFF00) << 8) | ((x & 0xFF00) << 8) |
@ -578,7 +580,7 @@ set_start_sect(struct partition *p, unsigned start_sect)
} }
#endif #endif
static int32_t static unsigned
get_start_sect(const struct partition *p) get_start_sect(const struct partition *p)
{ {
return read4_little_endian(p->start4); return read4_little_endian(p->start4);
@ -586,13 +588,13 @@ get_start_sect(const struct partition *p)
#if ENABLE_FEATURE_FDISK_WRITABLE #if ENABLE_FEATURE_FDISK_WRITABLE
static void 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); store4_little_endian(p->size4, nr_sects);
} }
#endif #endif
static int32_t static unsigned
get_nr_sects(const struct partition *p) get_nr_sects(const struct partition *p)
{ {
return read4_little_endian(p->size4); return read4_little_endian(p->size4);
@ -1770,13 +1772,13 @@ change_sysid(void)
#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ #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, * 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. * Jan. 1990 (version 1.2.1 by Gordon W. Ross Aug. 1990; Modified by S.
* Lubkin Oct. 1991). */ * Lubkin Oct. 1991). */
static void static void
long2chs(ulong ls, unsigned *c, unsigned *h, unsigned *s) linear2chs(unsigned ls, unsigned *c, unsigned *h, unsigned *s)
{ {
int spc = heads * sectors; int spc = heads * sectors;
@ -1808,10 +1810,10 @@ check_consistency(const struct partition *p, int partition)
pes = p->end_sector & 0x3f; pes = p->end_sector & 0x3f;
/* compute logical beginning (c, h, s) */ /* 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) */ /* 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? */ /* Same physical / logical beginning? */
if (cylinders <= 1024 && (pbc != lbc || pbh != lbh || pbs != lbs)) { if (cylinders <= 1024 && (pbc != lbc || pbh != lbh || pbs != lbs)) {
@ -2479,46 +2481,40 @@ write_table(void)
static void static void
reread_partition_table(int leave) reread_partition_table(int leave)
{ {
int error = 0;
int i; int i;
printf(_("Calling ioctl() to re-read partition table.\n")); printf(_("Calling ioctl() to re-read partition table\n"));
sync(); sync();
sleep(2); sleep(2); /* Huh? */
if ((i = ioctl(fd, BLKRRPART)) != 0) { i = ioctl(fd, BLKRRPART);
error = errno; #if 0
} else { else {
/* some kernel versions (1.2.x) seem to have trouble /* some kernel versions (1.2.x) seem to have trouble
rereading the partition table, but if asked to do it rereading the partition table, but if asked to do it
twice, the second time works. - biro@yggdrasil.com */ twice, the second time works. - biro@yggdrasil.com */
sync(); sync();
sleep(2); sleep(2);
if ((i = ioctl(fd, BLKRRPART)) != 0) i = ioctl(fd, BLKRRPART);
error = errno;
} }
#endif
if (i) { if (i) {
printf(_("\nWARNING: Re-reading the partition table " bb_perror_msg("WARNING: rereading partition table "
"failed with error %d: %s.\n" "failed, kernel still uses old table");
"The kernel still uses the old table.\n"
"The new table will be used "
"at the next reboot.\n"),
error, strerror(error));
} }
#if 0
if (dos_changed) if (dos_changed)
printf( printf(
_("\nWARNING: If you have created or modified any DOS 6.x\n" _("\nWARNING: If you have created or modified any DOS 6.x\n"
"partitions, please see the fdisk manual page for additional\n" "partitions, please see the fdisk manual page for additional\n"
"information.\n")); "information.\n"));
#endif
if (leave) { if (leave) {
close(fd); if (ENABLE_FEATURE_CLEAN_UP)
close(fd);
printf(_("Syncing disks.\n")); exit(i != 0);
sync();
sleep(4); /* for sync() */
exit(!!i);
} }
} }
#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ #endif /* CONFIG_FEATURE_FDISK_WRITABLE */
@ -2544,7 +2540,6 @@ print_buffer(char *pbuffer)
puts(""); puts("");
} }
static void static void
print_raw(void) print_raw(void)
{ {
@ -2728,7 +2723,8 @@ try(const char *device, int user_specified)
if (!user_specified) if (!user_specified)
if (is_ide_cdrom_or_tape(device)) if (is_ide_cdrom_or_tape(device))
return; return;
if ((fd = open(disk_device, type_open)) >= 0) { fd = open(disk_device, type_open);
if (fd >= 0) {
gb = get_boot(try_only); gb = get_boot(try_only);
if (gb > 0) { /* I/O error */ if (gb > 0) { /* I/O error */
close(fd); close(fd);
@ -2861,7 +2857,7 @@ int fdisk_main(int argc, char **argv)
type_open = O_RDONLY; type_open = O_RDONLY;
if (argc > 0) { if (argc > 0) {
int k; int k;
#if __GNUC__ #if defined(__GNUC__)
/* avoid gcc warning: /* avoid gcc warning:
variable `k' might be clobbered by `longjmp' */ variable `k' might be clobbered by `longjmp' */
(void)&k; (void)&k;

View File

@ -253,7 +253,7 @@ static void xbsd_change_fstype(void);
static int xbsd_get_part_index(int max); static int xbsd_get_part_index(int max);
static int xbsd_check_new_partition(int *i); static int xbsd_check_new_partition(int *i);
static void xbsd_list_types(void); 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_initlabel(struct partition *p, struct xbsd_disklabel *d);
static int xbsd_readlabel(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); static int xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d);
@ -650,37 +650,38 @@ xbsd_edit_disklabel(void)
d = &xbsd_dlabel; d = &xbsd_dlabel;
#if defined (__alpha__) || defined (__ia64__) #if defined (__alpha__) || defined (__ia64__)
d->d_secsize = (u_long) edit_int((u_long) d->d_secsize ,_("bytes/sector")); d->d_secsize = edit_int(d->d_secsize ,_("bytes/sector"));
d->d_nsectors = (u_long) edit_int((u_long) d->d_nsectors ,_("sectors/track")); d->d_nsectors = edit_int(d->d_nsectors ,_("sectors/track"));
d->d_ntracks = (u_long) edit_int((u_long) d->d_ntracks ,_("tracks/cylinder")); d->d_ntracks = edit_int(d->d_ntracks ,_("tracks/cylinder"));
d->d_ncylinders = (u_long) edit_int((u_long) d->d_ncylinders ,_("cylinders")); d->d_ncylinders = edit_int(d->d_ncylinders ,_("cylinders"));
#endif #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) { 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")); _("sectors/cylinder"));
if (d->d_secpercyl <= d->d_nsectors * d->d_ntracks) if (d->d_secpercyl <= d->d_nsectors * d->d_ntracks)
break; break;
printf(_("Must be <= sectors/track * tracks/cylinder (default).\n")); printf(_("Must be <= sectors/track * tracks/cylinder (default).\n"));
} }
d->d_rpm = (u_short) edit_int((u_short) d->d_rpm ,_("rpm")); d->d_rpm = edit_int(d->d_rpm ,_("rpm"));
d->d_interleave = (u_short) edit_int((u_short) d->d_interleave,_("interleave")); d->d_interleave = edit_int(d->d_interleave,_("interleave"));
d->d_trackskew = (u_short) edit_int((u_short) d->d_trackskew ,_("trackskew")); d->d_trackskew = edit_int(d->d_trackskew ,_("trackskew"));
d->d_cylskew = (u_short) edit_int((u_short) d->d_cylskew ,_("cylinderskew")); d->d_cylskew = edit_int(d->d_cylskew ,_("cylinderskew"));
d->d_headswitch = (u_long) edit_int((u_long) d->d_headswitch ,_("headswitch")); d->d_headswitch = edit_int(d->d_headswitch,_("headswitch"));
d->d_trkseek = (u_long) edit_int((u_long) d->d_trkseek ,_("track-to-track seek")); d->d_trkseek = edit_int(d->d_trkseek ,_("track-to-track seek"));
d->d_secperunit = d->d_secpercyl * d->d_ncylinders; d->d_secperunit = d->d_secpercyl * d->d_ncylinders;
} }
static int static int
xbsd_get_bootstrap (char *path, void *ptr, int size) xbsd_get_bootstrap(char *path, void *ptr, int size)
{ {
int fdb; int fdb;
if ((fdb = open (path, O_RDONLY)) < 0) { fdb = open(path, O_RDONLY);
if (fdb < 0) {
perror(path); perror(path);
return 0; return 0;
} }
@ -736,7 +737,7 @@ xbsd_write_bootstrap(void)
snprintf(path, sizeof(path), "%s/boot%s", bootdir, dkbasename); snprintf(path, sizeof(path), "%s/boot%s", bootdir, dkbasename);
if (!xbsd_get_bootstrap(path, &disklabelbuffer[xbsd_dlabel.d_secsize], 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; return;
e = d + sizeof(struct xbsd_disklabel); e = d + sizeof(struct xbsd_disklabel);
@ -748,9 +749,9 @@ xbsd_write_bootstrap(void)
memmove(d, &dl, sizeof(struct xbsd_disklabel)); memmove(d, &dl, sizeof(struct xbsd_disklabel));
#if defined (__powerpc__) || defined (__hppa__) #if defined(__powerpc__) || defined(__hppa__)
sector = 0; sector = 0;
#elif defined (__alpha__) #elif defined(__alpha__)
sector = 0; sector = 0;
alpha_bootblock_checksum(disklabelbuffer); alpha_bootblock_checksum(disklabelbuffer);
#else #else
@ -762,11 +763,11 @@ xbsd_write_bootstrap(void)
if (BSD_BBSIZE != write(fd, disklabelbuffer, BSD_BBSIZE)) if (BSD_BBSIZE != write(fd, disklabelbuffer, BSD_BBSIZE))
fdisk_fatal(unable_to_write); fdisk_fatal(unable_to_write);
#if defined (__alpha__) #if defined(__alpha__)
printf(_("Bootstrap installed on %s.\n"), disk_device); printf(_("Bootstrap installed on %s.\n"), disk_device);
#else #else
printf(_("Bootstrap installed on %s.\n"), printf(_("Bootstrap installed on %s.\n"),
partname (disk_device, xbsd_part_index+1, 0)); partname(disk_device, xbsd_part_index+1, 0));
#endif #endif
sync_disks(); 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) if (*i >= xbsd_dlabel.d_npartitions)
xbsd_dlabel.d_npartitions = (*i) + 1; xbsd_dlabel.d_npartitions = (*i) + 1;
@ -831,14 +832,14 @@ xbsd_list_types(void)
list_types(xbsd_fstypes); list_types(xbsd_fstypes);
} }
static u_short static uint16_t
xbsd_dkcksum(struct xbsd_disklabel *lp) xbsd_dkcksum(struct xbsd_disklabel *lp)
{ {
u_short *start, *end; uint16_t *start, *end;
u_short sum = 0; uint16_t sum = 0;
start = (u_short *) lp; start = (uint16_t *) lp;
end = (u_short *) &lp->d_partitions[lp->d_npartitions]; end = (uint16_t *) &lp->d_partitions[lp->d_npartitions];
while (start < end) while (start < end)
sum ^= *start++; sum ^= *start++;
return sum; return sum;

View File

@ -84,8 +84,8 @@ typedef struct {
#define SGI_INFO_MAGIC 0x00072959 #define SGI_INFO_MAGIC 0x00072959
#define SGI_INFO_MAGIC_SWAPPED 0x59290700 #define SGI_INFO_MAGIC_SWAPPED 0x59290700
#define SGI_SSWAP16(x) (sgi_other_endian ? __swap16(x) : (uint16_t)(x)) #define SGI_SSWAP16(x) (sgi_other_endian ? fdisk_swap16(x) : (uint16_t)(x))
#define SGI_SSWAP32(x) (sgi_other_endian ? __swap32(x) : (uint32_t)(x)) #define SGI_SSWAP32(x) (sgi_other_endian ? fdisk_swap32(x) : (uint32_t)(x))
#define sgilabel ((sgi_partition *)MBRbuffer) #define sgilabel ((sgi_partition *)MBRbuffer)
#define sgiparam (sgilabel->devparam) #define sgiparam (sgilabel->devparam)

View File

@ -2,8 +2,8 @@
#define SUN_LABEL_MAGIC 0xDABE #define SUN_LABEL_MAGIC 0xDABE
#define SUN_LABEL_MAGIC_SWAPPED 0xBEDA #define SUN_LABEL_MAGIC_SWAPPED 0xBEDA
#define SUN_SSWAP16(x) (sun_other_endian ? __swap16(x) : (uint16_t)(x)) #define SUN_SSWAP16(x) (sun_other_endian ? fdisk_swap16(x) : (uint16_t)(x))
#define SUN_SSWAP32(x) (sun_other_endian ? __swap32(x) : (uint32_t)(x)) #define SUN_SSWAP32(x) (sun_other_endian ? fdisk_swap32(x) : (uint32_t)(x))
/* Copied from linux/major.h */ /* Copied from linux/major.h */
#define FLOPPY_MAJOR 2 #define FLOPPY_MAJOR 2

View File

@ -439,7 +439,7 @@ struct ppathcnf {
short pc_name_max; short pc_name_max;
short pc_path_max; short pc_path_max;
short pc_pipe_buf; short pc_pipe_buf;
u_char pc_vdisable; uint8_t pc_vdisable;
char pc_xxx; char pc_xxx;
short pc_mask[2]; short pc_mask[2];
}; };