[BACK]Return to autoconf.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / i386 / i386

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/arch/i386/i386/autoconf.c between version 1.56 and 1.56.4.3

version 1.56, 2001/05/05 17:53:59 version 1.56.4.3, 2001/10/01 12:39:42
Line 71 
Line 71 
 static int match_harddisk __P((struct device *, struct btinfo_bootdisk *));  static int match_harddisk __P((struct device *, struct btinfo_bootdisk *));
 static void matchbiosdisks __P((void));  static void matchbiosdisks __P((void));
 static void findroot __P((void));  static void findroot __P((void));
   static int is_valid_disk __P((struct device *));
   
 extern struct disklist *i386_alldisks;  extern struct disklist *i386_alldisks;
 extern int i386_ndisks;  extern int i386_ndisks;
Line 148  matchbiosdisks()
Line 149  matchbiosdisks()
         int i, ck, error, m, n;          int i, ck, error, m, n;
         struct vnode *tv;          struct vnode *tv;
         char mbr[DEV_BSIZE];          char mbr[DEV_BSIZE];
           int  dklist_size;
   
         big = lookup_bootinfo(BTINFO_BIOSGEOM);          big = lookup_bootinfo(BTINFO_BIOSGEOM);
   
Line 158  matchbiosdisks()
Line 160  matchbiosdisks()
          * First, count all native disks           * First, count all native disks
          */           */
         for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next)          for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next)
                 if (dv->dv_class == DV_DISK &&                  if (is_valid_disk(dv))
                     (!strcmp(dv->dv_cfdata->cf_driver->cd_name, "sd") ||  
                      !strcmp(dv->dv_cfdata->cf_driver->cd_name, "wd") ||  
                      !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ld") ||  
                      !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ed")))  
                         i386_ndisks++;                          i386_ndisks++;
   
         if (i386_ndisks == 0)          if (i386_ndisks == 0)
                 return;                  return;
   
           dklist_size = sizeof (struct disklist) + (i386_ndisks - 1) *
               sizeof (struct nativedisk_info);
   
         /* XXX M_TEMP is wrong */          /* XXX M_TEMP is wrong */
         i386_alldisks = malloc(sizeof (struct disklist) + (i386_ndisks - 1) *          i386_alldisks = malloc(dklist_size, M_TEMP, M_NOWAIT);
                                 sizeof (struct nativedisk_info),  
                                 M_TEMP, M_NOWAIT);  
         if (i386_alldisks == NULL)          if (i386_alldisks == NULL)
                 return;                  return;
   
           memset(i386_alldisks, 0, dklist_size);
   
         i386_alldisks->dl_nnativedisks = i386_ndisks;          i386_alldisks->dl_nnativedisks = i386_ndisks;
         i386_alldisks->dl_nbiosdisks = big->num;          i386_alldisks->dl_nbiosdisks = big->num;
         for (i = 0; i < big->num; i++) {          for (i = 0; i < big->num; i++) {
Line 197  matchbiosdisks()
Line 198  matchbiosdisks()
                 printf("matchbiosdisks: trying to match (%s) %s\n",                  printf("matchbiosdisks: trying to match (%s) %s\n",
                     dv->dv_xname, dv->dv_cfdata->cf_driver->cd_name);                      dv->dv_xname, dv->dv_cfdata->cf_driver->cd_name);
 #endif  #endif
                 if (!strcmp(dv->dv_cfdata->cf_driver->cd_name, "sd") ||                  if (is_valid_disk(dv)) {
                     !strcmp(dv->dv_cfdata->cf_driver->cd_name, "wd") ||  
                     !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ld") ||  
                     !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ed")) {  
                         n++;                          n++;
                         sprintf(i386_alldisks->dl_nativedisks[n].ni_devname,                          sprintf(i386_alldisks->dl_nativedisks[n].ni_devname,
                             "%s%d", dv->dv_cfdata->cf_driver->cd_name,                              "%s%d", dv->dv_cfdata->cf_driver->cd_name,
Line 216  matchbiosdisks()
Line 214  matchbiosdisks()
                             &tv))                              &tv))
                                 panic("matchbiosdisks: can't alloc vnode");                                  panic("matchbiosdisks: can't alloc vnode");
   
                         error = VOP_OPEN(tv, FREAD, NOCRED, 0);                          vn_lock(tv, LK_EXCLUSIVE | LK_RETRY);
                           error = VOP_OPEN(tv, FREAD, NOCRED, 0, NULL);
                         if (error) {                          if (error) {
                                 vput(tv);                                  vput(tv);
                                 continue;                                  continue;
Line 229  matchbiosdisks()
Line 228  matchbiosdisks()
                                 printf("matchbiosdisks: %s: MBR read failure\n",                                  printf("matchbiosdisks: %s: MBR read failure\n",
                                     dv->dv_xname);                                      dv->dv_xname);
 #endif  #endif
                                   vput(tv);
                                 continue;                                  continue;
                         }                          }
   
Line 304  match_harddisk(dv, bid)
Line 304  match_harddisk(dv, bid)
          */           */
         if (bdevvp(MAKEDISKDEV(i->d_maj, dv->dv_unit, bid->partition), &tmpvn))          if (bdevvp(MAKEDISKDEV(i->d_maj, dv->dv_unit, bid->partition), &tmpvn))
                 panic("findroot can't alloc vnode");                  panic("findroot can't alloc vnode");
         error = VOP_OPEN(tmpvn, FREAD, NOCRED, 0);          error = VOP_OPEN(tmpvn, FREAD, NOCRED, 0, NULL);
         if (error) {          if (error) {
 #ifndef DEBUG  #ifndef DEBUG
                 /*                  /*
Line 398  findroot(void)
Line 398  findroot(void)
                                 goto found;                                  goto found;
                         }                          }
   
                         if (!strcmp(dv->dv_cfdata->cf_driver->cd_name, "sd") ||                          if (is_valid_disk(dv)) {
                             !strcmp(dv->dv_cfdata->cf_driver->cd_name, "wd") ||  
                             !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ld") ||  
                             !strcmp(dv->dv_cfdata->cf_driver->cd_name, "ed")) {  
                                 /*                                  /*
                                  * Don't trust BIOS device numbers, try                                   * Don't trust BIOS device numbers, try
                                  * to match the information passed by the                                   * to match the information passed by the
Line 532  found:
Line 529  found:
         }          }
         booted_device = dev;          booted_device = dev;
 }  }
   
   static int
   is_valid_disk(struct device *dv)
   {
           const char *name;
   
           if (dv->dv_class != DV_DISK)
                   return (0);
   
           name = dv->dv_cfdata->cf_driver->cd_name;
   
           return (strcmp(name, "sd") == 0 || strcmp(name, "wd") == 0 ||
               strcmp(name, "ld") == 0 || strcmp(name, "ed") == 0);
   }

Legend:
Removed from v.1.56  
changed lines
  Added in v.1.56.4.3

CVSweb <webmaster@jp.NetBSD.org>