#define DEV_FD0 0x200 /* Device number of /dev/fd0 */
#define DEV_C0D0 0x300 /* Device number of /dev/c0d0 */
-#define MIN_REGION_MB 500
-#define MIN_REGION_SECTORS (1024*1024*MIN_REGION_MB/SECTOR_SIZE)
+int min_region_mb = 500;
+
+#define MIN_REGION_SECTORS (1024*1024*min_region_mb/SECTOR_SIZE)
#define MAX_REGION_MB 4095
#define MAX_REGION_SECTORS (1024*(1024/SECTOR_SIZE)*MAX_REGION_MB)
}
int
-scribble_region(region_t *reg, struct part_entry **pe)
+scribble_region(region_t *reg, struct part_entry **pe, int *made_new)
{
int ex, trunc = 0, changed = 0, i;
struct part_entry *newpart;
changed = 1;
cylinderalign(reg);
}
- }
+ if(made_new) *made_new = 1;
+ } else if(made_new) *made_new = 0;
#if 0
if(trunc) {
printf("\nWill only use %dMB.\n", MAX_REGION_MB);
struct part_entry *pe;
char sure[50];
struct part_entry orig_table[1 + NR_PARTITIONS];
- int region, disk;
+ int region, disk, newp;
nordonly = 1;
} while(!r); /* Back to step 2. */
/* Write things. */
- if(scribble_region(r, &pe)) {
+ if(scribble_region(r, &pe, &newp)) {
char *name;
int i, found = -1;
char partbuf[100], devname[100];
struct part_entry *tpe;
-
printstep(3, "Confirm your choices");
region = (int)(r-regions);
fprintf(stderr, "Autopart internal error (disk sanity check failed).\n");
exit(1);
}
+
+ if(newp) {
+ int fd;
+ if((fd=open(devname, O_WRONLY)) < 0) {
+ perror(devname);
+ } else {
+ /* Clear any subpartitioning. */
+ static char sub[2048];
+ write(fd, sub, sizeof(sub));
+ close(fd);
+ }
+ }
return 0;
}
} else {
int c;
/* autopart uses getopt() */
- while((c = getopt(argc, argv, "f:")) != EOF) {
+ while((c = getopt(argc, argv, "m:f:")) != EOF) {
switch(c) {
+ case 'm':
+ min_region_mb = atoi(optarg);
+ break;
case 'f':
/* Make sure old data file is gone. */
unlink(optarg);