]> Zhao Yanbai Git Server - minix.git/commitdiff
. release fixes
authorBen Gras <ben@minix3.org>
Thu, 25 Aug 2005 09:47:31 +0000 (09:47 +0000)
committerBen Gras <ben@minix3.org>
Thu, 25 Aug 2005 09:47:31 +0000 (09:47 +0000)
. 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.

commands/ibm/autopart.c
commands/scripts/setup.sh
drivers/at_wini/at_wini.c
include/sys/ioc_disk.h
tools/release.sh

index a16957d46d185f8fc65f58ab71c147c626e32783..9c44edbdd948aaf8107100e83abb12388cd48f48 100755 (executable)
@@ -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();
index b818b6ae61cd632f312291b4b3ffa5ce353db9ee..8243ebc88e574d8fed99537d368bc5ffa8abdd28 100755 (executable)
@@ -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 
index abc0a7ca81f9b666bfae9e1f237c62fbaf309797..4af57dc035b3de60d2623a9b66739b267ee58cf3 100644 (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(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;
                }
-
-               if((r=sys_datacopy(SELF, (vir_bytes)&prev, 
-                       m->PROC_NR, (vir_bytes)m->ADDRESS, sizeof(prev))) != OK)
+       
+               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;
 }
 
 
index 6127a270f8529dc8b5b4953a7824470966e160e5..2f9250c3597c92eddbfb47f602c1d5badc96acbb 100755 (executable)
@@ -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 */
index 0d5e40a4b1711f26c40e4fe0d23c48128cd14034..c4e06bb6408f616502802a2f631781ee0e719a06 100755 (executable)
@@ -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