. release fixes

. added OPENCT ioctl to at driver, which returns the number of times
  a device is opened. if it's not opened exactly once, new partition info
  will not be read in (at the next open after this close). included
  this check in autopart.
This commit is contained in:
Ben Gras 2005-08-25 09:47:31 +00:00
parent ae5f1f2286
commit 647e179038
5 changed files with 88 additions and 86 deletions

View file

@ -59,7 +59,7 @@ Num Sort Type
#define DEV_FD0 0x200 /* Device number of /dev/fd0 */
#define DEV_C0D0 0x300 /* Device number of /dev/c0d0 */
#define MIN_REGION_MB 180
#define MIN_REGION_MB 160
#define MIN_REGION_SECTORS (1024*1024*MIN_REGION_MB/SECTOR_SIZE)
#define MAX_REGION_MB 4095
@ -103,7 +103,19 @@ void type2col(int type)
}
}
int probing = 0, autopartmode = 0;
int open_ct_ok(int fd)
{
int c = -1;
if(ioctl(fd, DIOCOPENCT, &c) < 0) {
printf("Warning: couldn't verify opencount, continuing\n");
return 1;
}
if(c == 1) return 1;
if(c < 1) { printf("Error: open count %d\n", c); }
return 0;
}
void report(const char *label)
{
@ -1786,7 +1798,7 @@ void regionize(void)
}
/* Sanity check. */
if(autopartmode && si > 1) {
if(si > 1) {
if(table[i].lowsec < table[sort_order[si-1]].lowsec ||
table[i].lowsec < table[sort_order[si-1]].lowsec + table[sort_order[si-1]].size) {
printf("\nSanity check failed on %s - partitions overlap.\n"
@ -1841,18 +1853,12 @@ void m_read(int ev, object_t *op)
fflush(stdout);
if ((device= open(curdev->name, mode= O_RDWR, 0666)) < 0) {
stat_start(1);
if(!probing)
printf("%s: %s", curdev->name, strerror(errno));
stat_end(5);
if (device >= 0) { close(device); device= -1; }
return;
}
if(probing) {
v = 2*HZ;
ioctl(device, DIOCTIMEOUT, &v);
}
v = 2*HZ;
ioctl(device, DIOCTIMEOUT, &v);
/* Assume up to five lines of kernel messages. */
statusrow+= 5-1;
@ -1869,39 +1875,34 @@ void m_read(int ev, object_t *op)
if (n <= 0) stat_start(1);
if (n < 0) {
if(!probing)
printf("%s: %s", curdev->name, strerror(errno));
close(device);
device= -1;
} else
if (n < SECTOR_SIZE) {
if(probing) {
close(device);
device= -1;
return;
}
printf("%s: Unexpected EOF", curdev->subname);
close(device);
device= -1;
return;
}
if (n <= 0) stat_end(5);
if (n < SECTOR_SIZE) n= SECTOR_SIZE;
if(!open_ct_ok(device)) {
printf("\n%s: device in use! skipping it.", curdev->subname);
fflush(stdout);
close(device);
device= -1;
return;
}
memcpy(table+1, bootblock+PART_TABLE_OFF,
NR_PARTITIONS * sizeof(table[1]));
for (i= 1; i <= NR_PARTITIONS; i++) {
if ((table[i].bootind & ~ACTIVE_FLAG) != 0) break;
}
if (i <= NR_PARTITIONS || bootblock[510] != 0x55
|| bootblock[511] != 0xAA) {
if (bootblock[510] != 0x55 || bootblock[511] != 0xAA) {
/* Invalid boot block, install bootstrap, wipe partition table.
*/
memset(bootblock, 0, sizeof(bootblock));
installboot(bootblock, MASTERBOOT);
memset(table+1, 0, NR_PARTITIONS * sizeof(table[1]));
stat_start(1);
if(!probing)
printf("%s: Invalid partition table (reset)", curdev->subname);
stat_end(5);
}
/* Fix an extended partition table up to something mere mortals can
@ -1944,13 +1945,6 @@ void m_write(int ev, object_t *op)
return;
}
if (bootblock[510] != 0x55 || bootblock[511] != 0xAA) {
/* Invalid boot block, warn user. */
stat_start(1);
if(!autopartmode) printf("Warning: About to write a new table on %s",
curdev->subname);
stat_end(5);
}
if (extbase != 0) {
/* Will this stop him? Probably not... */
stat_start(1);
@ -1958,19 +1952,6 @@ void m_write(int ev, object_t *op)
stat_end(5);
}
if(!autopartmode) {
stat_start(1);
putstr("Save partition table? (y/n) ");
fflush(stdout);
while ((c= getchar()) != 'y' && c != 'n' && c != ctrl('?')) {}
if (c == ctrl('?')) putstr("DEL"); else putchr(c);
stat_end(5);
if (c == 'n' && ev == E_WRITE) dirty= 0;
if (c != 'y') return;
}
memcpy(new_table, table+1, NR_PARTITIONS * sizeof(table[1]));
for (pe= new_table; pe < new_table + NR_PARTITIONS; pe++) {
if (pe->sysind == NO_PART) {
@ -2491,7 +2472,8 @@ select_disk(void)
}
printf(" Probing done.\n");
printf("The following disk%s were found on your system:\n\n", SORNOT(drives));
printf("The following disk%s %s found on your system:\n\n", SORNOT(drives),
drives == 1 ? "was" : "were");
for(i = 0; i < drives; i++) {
printf(" ");
@ -2595,6 +2577,14 @@ sanitycheck_failed(char *dev, struct part_entry *pe)
return 1;
}
if(!open_ct_ok(fd)) {
printf("Autopart error: the disk is in use. This means that although a\n"
"new table has been written, it won't be in use by the system\n"
"until it's no longer in use (or a reboot is done). Just in case,\n"
"I'm not going to continue.\n\n");
return 1;
}
close(fd);
it_lowsec = div64u(part.base, SECTOR_SIZE);
@ -2620,8 +2610,6 @@ do_autopart(int resultfd)
int region, disk;
nordonly = 1;
probing = 1;
autopartmode = 1;
do {
curdev = select_disk();

View file

@ -434,9 +434,12 @@ echo "rootdev=$root; ramimagedev=$root; $disable; save" >$pfile || exit
umount /dev/$usr
sync
bios="`echo $primary | sed 's/d./dX/g'`"
echo "
Please type 'shutdown' to exit MINIX 3 and enter the boot monitor. At the
boot monitor prompt, type 'boot $primary' to try your new MINIX system.
Please type 'shutdown' to exit MINIX 3 and enter the boot monitor. At
the boot monitor prompt, type 'boot $bios', where X is the bios drive
number of the drive you installed on, to try your new MINIX system.
This ends the MINIX setup script. After booting your newly set up system,
you can run the test suites as indicated in the setup manual. You also

View file

@ -1388,43 +1388,54 @@ message *m;
{
int r, timeout, prev;
if(m->m_type != DEV_IOCTL || m->REQUEST != DIOCTIMEOUT) {
if(m->m_type != DEV_IOCTL ) {
return EINVAL;
}
if((r=sys_datacopy(m->PROC_NR, (vir_bytes)m->ADDRESS,
SELF, (vir_bytes)&timeout, sizeof(timeout))) != OK)
return r;
if(timeout == 0) {
/* Restore defaults. */
timeout_ticks = DEF_TIMEOUT_TICKS;
max_errors = MAX_ERRORS;
wakeup_ticks = WAKEUP;
w_silent = 0;
} else if(timeout < 0) {
return EINVAL;
} else {
prev = wakeup_ticks;
if(!w_standard_timeouts) {
/* Set (lower) timeout, lower error
* tolerance and set silent mode.
*/
wakeup_ticks = timeout;
max_errors = 3;
w_silent = 1;
if(timeout_ticks > timeout)
timeout_ticks = timeout;
}
if((r=sys_datacopy(SELF, (vir_bytes)&prev,
m->PROC_NR, (vir_bytes)m->ADDRESS, sizeof(prev))) != OK)
if(m->REQUEST == DIOCTIMEOUT) {
if((r=sys_datacopy(m->PROC_NR, (vir_bytes)m->ADDRESS,
SELF, (vir_bytes)&timeout, sizeof(timeout))) != OK)
return r;
if(timeout == 0) {
/* Restore defaults. */
timeout_ticks = DEF_TIMEOUT_TICKS;
max_errors = MAX_ERRORS;
wakeup_ticks = WAKEUP;
w_silent = 0;
} else if(timeout < 0) {
return EINVAL;
} else {
prev = wakeup_ticks;
if(!w_standard_timeouts) {
/* Set (lower) timeout, lower error
* tolerance and set silent mode.
*/
wakeup_ticks = timeout;
max_errors = 3;
w_silent = 1;
if(timeout_ticks > timeout)
timeout_ticks = timeout;
}
if((r=sys_datacopy(SELF, (vir_bytes)&prev,
m->PROC_NR, (vir_bytes)m->ADDRESS, sizeof(prev))) != OK)
return r;
}
return OK;
} else if(m->REQUEST == DIOCOPENCT) {
int count;
if(w_prepare(m->DEVICE) == NIL_DEV) return ENXIO;
count = w_wn->open_ct;
if((r=sys_datacopy(SELF, (vir_bytes)&count,
m->PROC_NR, (vir_bytes)m->ADDRESS, sizeof(count))) != OK)
return r;
return OK;
}
return OK;
return EINVAL;
}

View file

@ -12,5 +12,6 @@
#define DIOCGETP _IOR('d', 4, struct partition)
#define DIOCEJECT _IO ('d', 5)
#define DIOCTIMEOUT _IOW('d', 6, int)
#define DIOCOPENCT _IOR('c', 7, int)
#endif /* _S_I_DISK_H */

View file

@ -158,7 +158,6 @@ if [ "$HDEMU" -ne 0 ]; then hdemu_root_changes; fi
umount $TMPDISK || exit
umount $RAM || exit
dd if=$RAM of=$ROOTIMAGE bs=$BS count=$ROOTBLOCKS
make programs image
(cd ../boot && make)
make image || exit 1
sh mkboot cdfdboot