[BACK]Return to remove.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sbin / gpt

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

Diff for /src/sbin/gpt/remove.c between version 1.2.2.2 and 1.6.2.1

version 1.2.2.2, 2008/04/08 20:32:38 version 1.6.2.1, 2014/05/22 11:37:28
Line 50  static off_t block, size;
Line 50  static off_t block, size;
 static unsigned int entry;  static unsigned int entry;
   
 const char removemsg1[] = "remove -a device ...";  const char removemsg1[] = "remove -a device ...";
 const char removemsg2[] = "remove [-b lba] [-i index] [-s lba] "  const char removemsg2[] = "remove [-b blocknr] [-i index] [-s sectors] "
         "[-t uuid] device ...";          "[-t type] device ...";
   
 static void  __dead static void
 usage_remove(void)  usage_remove(void)
 {  {
   
Line 112  rem(int fd)
Line 112  rem(int fd)
                 hdr = gpt->map_data;                  hdr = gpt->map_data;
                 ent = (void*)((char*)tbl->map_data + i *                  ent = (void*)((char*)tbl->map_data + i *
                     le32toh(hdr->hdr_entsz));                      le32toh(hdr->hdr_entsz));
                 le_uuid_dec(&ent->ent_type, &uuid);                  le_uuid_dec(ent->ent_type, &uuid);
                 if (!uuid_is_nil(&type, NULL) &&                  if (!uuid_is_nil(&type, NULL) &&
                     !uuid_equal(&type, &uuid, NULL))                      !uuid_equal(&type, &uuid, NULL))
                         continue;                          continue;
   
                 /* Remove the primary entry by clearing the partition type. */                  /* Remove the primary entry by clearing the partition type. */
                 uuid_create_nil((uuid_t *)&ent->ent_type, NULL);                  uuid_create_nil(&uuid, NULL);
                   le_uuid_enc(ent->ent_type, &uuid);
   
                 hdr->hdr_crc_table = htole32(crc32(tbl->map_data,                  hdr->hdr_crc_table = htole32(crc32(tbl->map_data,
                     le32toh(hdr->hdr_entries) * le32toh(hdr->hdr_entsz)));                      le32toh(hdr->hdr_entries) * le32toh(hdr->hdr_entsz)));
Line 132  rem(int fd)
Line 133  rem(int fd)
                 ent = (void*)((char*)lbt->map_data + i *                  ent = (void*)((char*)lbt->map_data + i *
                     le32toh(hdr->hdr_entsz));                      le32toh(hdr->hdr_entsz));
   
                 /* Remove the secundary entry. */                  /* Remove the secondary entry. */
                 uuid_create_nil((uuid_t *)&ent->ent_type, NULL);                  le_uuid_enc(ent->ent_type, &uuid);
   
                 hdr->hdr_crc_table = htole32(crc32(lbt->map_data,                  hdr->hdr_crc_table = htole32(crc32(lbt->map_data,
                     le32toh(hdr->hdr_entries) * le32toh(hdr->hdr_entsz)));                      le32toh(hdr->hdr_entries) * le32toh(hdr->hdr_entsz)));
Line 142  rem(int fd)
Line 143  rem(int fd)
   
                 gpt_write(fd, lbt);                  gpt_write(fd, lbt);
                 gpt_write(fd, tpg);                  gpt_write(fd, tpg);
 #ifdef __FreeBSD__  
                 printf("%sp%u removed\n", device_name, m->map_index);  
 #endif  
 #ifdef __NetBSD__  
                 printf("partition %d removed from %s\n", m->map_index,                  printf("partition %d removed from %s\n", m->map_index,
                     device_name);                      device_name);
 #endif  
         }          }
 }  }
   
Line 157  cmd_remove(int argc, char *argv[])
Line 153  cmd_remove(int argc, char *argv[])
 {  {
         char *p;          char *p;
         int ch, fd;          int ch, fd;
           int64_t human_num;
   
         /* Get the remove options */          /* Get the remove options */
         while ((ch = getopt(argc, argv, "ab:i:s:t:")) != -1) {          while ((ch = getopt(argc, argv, "ab:i:s:t:")) != -1) {
Line 169  cmd_remove(int argc, char *argv[])
Line 166  cmd_remove(int argc, char *argv[])
                 case 'b':                  case 'b':
                         if (block > 0)                          if (block > 0)
                                 usage_remove();                                  usage_remove();
                         block = strtoll(optarg, &p, 10);                          if (dehumanize_number(optarg, &human_num) < 0)
                         if (*p != 0 || block < 1)                                  usage_remove();
                           block = human_num;
                           if (block < 1)
                                 usage_remove();                                  usage_remove();
                         break;                          break;
                 case 'i':                  case 'i':

Legend:
Removed from v.1.2.2.2  
changed lines
  Added in v.1.6.2.1

CVSweb <webmaster@jp.NetBSD.org>