[BACK]Return to disks.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.sbin / sysinst

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

Diff for /src/usr.sbin/sysinst/disks.c between version 1.16 and 1.17

version 1.16, 2018/06/03 13:18:06 version 1.17, 2018/11/05 19:45:56
Line 36 
Line 36 
   
   
 #include <errno.h>  #include <errno.h>
   #include <inttypes.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <unistd.h>  #include <unistd.h>
Line 109  static void fixsb(const char *, const ch
Line 110  static void fixsb(const char *, const ch
 static bool is_gpt(const char *);  static bool is_gpt(const char *);
 static int incoregpt(pm_devs_t *, partinfo *);  static int incoregpt(pm_devs_t *, partinfo *);
   
 #ifndef DISK_NAMES  
 #define DISK_NAMES "wd", "sd", "ld", "raid"  
 #endif  
   
 static const char *disk_names[] = { DISK_NAMES,  
                                     "vnd", "cgd", "dk:no_part", NULL };  
   
 static bool tmpfs_on_var_shm(void);  static bool tmpfs_on_var_shm(void);
   
Line 510  is_ffs_wedge(const char *dev)
Line 505  is_ffs_wedge(const char *dev)
 static int  static int
 get_disks(struct disk_desc *dd, bool with_non_partitionable)  get_disks(struct disk_desc *dd, bool with_non_partitionable)
 {  {
         const char **xd;          static const int mib[] = { CTL_HW, HW_DISKNAMES };
         char *cp;          static const unsigned int miblen = __arraycount(mib);
           const char *xd;
         struct disklabel l;          struct disklabel l;
         int i;  
         int numdisks;          int numdisks;
           size_t len;
           char *disk_names;
   
         /* initialize */          /* initialize */
         numdisks = 0;          numdisks = 0;
   
         for (xd = disk_names; *xd != NULL; xd++) {          if (sysctl(mib, miblen, NULL, &len, NULL, 0) == -1)
                 for (i = 0; i < MAX_DISKS; i++) {                  return 0;
                         strlcpy(dd->dd_name, *xd, sizeof dd->dd_name - 2);          disk_names = malloc(len);
                         cp = strchr(dd->dd_name, ':');          if (disk_names == NULL)
                         if (cp != NULL) {                  return 0;
                                 dd->dd_no_mbr = !strcmp(cp, ":no_mbr");  
                                 dd->dd_no_part = !strcmp(cp, ":no_part");  
                         } else {  
                                 dd->dd_no_mbr = false;  
                                 dd->dd_no_part = false;  
                                 cp = strchr(dd->dd_name, 0);  
                         }  
                         if (dd->dd_no_part && !with_non_partitionable)  
                                 continue;  
   
                         snprintf(cp, 2 + 1, "%d", i);          if (sysctl(mib, miblen, disk_names, &len, NULL, 0) == -1) {
                         if (!get_geom(dd->dd_name, &l)) {                  free(disk_names);
                                 if (errno == ENOENT)                  return 0;
                                         break;          }
                                 if (errno != ENOTTY || !dd->dd_no_part)  
                                         /*  
                                          * Allow plain partitions,  
                                          * like already existing wedges  
                                          * (like dk0) if marked as  
                                          * non-partitioning device.  
                                          * For all other cases, continue  
                                          * with the next disk.  
                                          */  
                                         continue;  
                                 if (!is_ffs_wedge(dd->dd_name))  
                                         continue;  
                         }  
   
                         /*          for (xd = strtok(disk_names, " "); xd != NULL; xd = strtok(NULL, " ")) {
                          * Exclude a disk mounted as root partition,                  strlcpy(dd->dd_name, xd, sizeof dd->dd_name - 2);
                          * in case of install-image on a USB memstick.                  dd->dd_no_mbr = false;
                          */                  dd->dd_no_part = false;
                         if (is_active_rootpart(dd->dd_name, 0))  
                   if (strncmp(xd, "dk", 2) == 0) {
                           char *endp;
                           int e;
   
                           /* if this device is dkNNNN, no partitioning is possible */
                           strtou(xd+2, &endp, 10, 0, INT_MAX, &e);
                           if (endp && *endp == 0 && e == 0)
                                   dd->dd_no_part = true;
                   }
                   if (dd->dd_no_part && !with_non_partitionable)
                           continue;
   
                   if (!get_geom(dd->dd_name, &l)) {
                           if (errno == ENOENT)
                                   break;
                           if (errno != ENOTTY || !dd->dd_no_part)
                                   /*
                                    * Allow plain partitions,
                                    * like already existing wedges
                                    * (like dk0) if marked as
                                    * non-partitioning device.
                                    * For all other cases, continue
                                    * with the next disk.
                                    */
                                   continue;
                           if (!is_ffs_wedge(dd->dd_name))
                                 continue;                                  continue;
                   }
   
                         if (!dd->dd_no_part) {                  /*
                                 dd->dd_cyl = l.d_ncylinders;                   * Exclude a disk mounted as root partition,
                                 dd->dd_head = l.d_ntracks;                   * in case of install-image on a USB memstick.
                                 dd->dd_sec = l.d_nsectors;                   */
                                 dd->dd_secsize = l.d_secsize;                  if (is_active_rootpart(dd->dd_name, 0))
                                 dd->dd_totsec = l.d_secperunit;                          continue;
                         }  
                         if (dd->dd_no_part)                  if (!dd->dd_no_part) {
                                 get_wedge_descr(dd);                          dd->dd_cyl = l.d_ncylinders;
                         else                          dd->dd_head = l.d_ntracks;
                                 get_descr(dd);                          dd->dd_sec = l.d_nsectors;
                         dd++;                          dd->dd_secsize = l.d_secsize;
                         numdisks++;                          dd->dd_totsec = l.d_secperunit;
                         if (numdisks >= MAX_DISKS)  
                                 return numdisks;  
                 }                  }
                   if (dd->dd_no_part)
                           get_wedge_descr(dd);
                   else
                           get_descr(dd);
                   dd++;
                   numdisks++;
                   if (numdisks == MAX_DISKS)
                           break;
         }          }
           free(disk_names);
         return numdisks;          return numdisks;
 }  }
   

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

CVSweb <webmaster@jp.NetBSD.org>