#define DONT_NEED_WAIT
#include "sysincludes.h"
-#include "msdos.h"
#include "mtools.h"
-#include "mainloop.h"
#include "fsP.h"
#include "file.h"
#include "plain_io.h"
exit(ret);
}
-static void checkTotalSectors(unsigned long tot_sectors) {
- if(tot_sectors > UINT32_MAX) {
- fprintf(stderr, "Too many total sectors %ld\n",
- tot_sectors);
- exit(1);
- }
-}
-
void mpartition(int argc, char **argv, int dummy UNUSEDP) NORETURN;
void mpartition(int argc, char **argv, int dummy UNUSEDP)
{
break;
case 'l':
size_set = 1;
- length = strtoui(optarg, &endptr, 0);
+ length = parseSize(optarg);
break;
default:
tot_sectors = used_dev.tot_sectors;
/* read the partition table */
- if (READS(Stream, (char *) buf, 0, 512) != 512 && !initialize){
+ if (PREADS(Stream, (char *) buf, 0, 512) != 512 && !initialize){
#ifdef HAVE_SNPRINTF
snprintf(errmsg, sizeof(errmsg)-1,
"Error reading from '%s', wrong parameters?",
if(!used_dev.sectors && !used_dev.heads) {
if(tot_sectors) {
- checkTotalSectors(tot_sectors);
setsize0((uint32_t)tot_sectors,&dummy2,&used_dev.heads,
&used_dev.sectors);
} else {
if(create) {
unsigned int overlap;
if(!end_set && !size_set && tot_sectors) {
- checkTotalSectors(tot_sectors);
- end = (uint32_t) tot_sectors -
- (uint32_t) tot_sectors % sec_per_cyl;
+ end = tot_sectors - tot_sectors % sec_per_cyl;
end_set = 1;
}
printf("The following command will recreate the partition for drive %c:\n",
drive);
used_dev.tracks =
- (_DWORD(tpartition->nr_sects) +
+ (DWORD(tpartition->nr_sects) +
(BEGIN(tpartition) % sec_per_cyl)) /
sec_per_cyl;
printf("mpartition -c -b %d -l %d -t %d -h %d -s %d -b %u %c:\n",
/* write data back to the disk */
if(verbose>=2)
print_sector("Writing sector", buf, 512);
- if (WRITES(Stream, (char *) buf, 0, 512) != 512) {
+ if (PWRITES(Stream, (char *) buf, 0, 512) != 512) {
fprintf(stderr,"Error writing partition table");
exit(1);
}