Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/gpt - dump all partitions, not just ones that are in use



details:   https://anonhg.NetBSD.org/src/rev/7ec53392c083
branches:  trunk
changeset: 802329:7ec53392c083
user:      jnemeth <jnemeth%NetBSD.org@localhost>
date:      Wed Sep 10 10:49:44 2014 +0000

description:
- dump all partitions, not just ones that are in use
- while here, squash a memory leak

     It shouldn't be necessary to backup unused partitions, however
the partition GUID is created at the time the GPT is created and
is never changed.  It shouldn't matter if the GUID of an unused
partition changes, but there may be some special case where it
does.  Since it isn't a big deal to record the unused partitions,
might as well do it.

diffstat:

 sbin/gpt/backup.c |  22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diffs (59 lines):

diff -r e4b2566bd172 -r 7ec53392c083 sbin/gpt/backup.c
--- a/sbin/gpt/backup.c Wed Sep 10 09:55:09 2014 +0000
+++ b/sbin/gpt/backup.c Wed Sep 10 10:49:44 2014 +0000
@@ -29,7 +29,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: backup.c,v 1.2 2014/09/09 06:30:09 jnemeth Exp $");
+__RCSID("$NetBSD: backup.c,v 1.3 2014/09/10 10:49:44 jnemeth Exp $");
 #endif
 
 #include <sys/bootblock.h>
@@ -216,12 +216,11 @@
                        type_dict = prop_dictionary_create();
                        PROP_ERR(type_dict);
                        ent = m->map_data;
-                       gpt_array = NULL;
+                       gpt_array = prop_array_create();
+                       PROP_ERR(gpt_array);
                        for (i = 1, ent = m->map_data;
                            (char *)ent < (char *)(m->map_data) +
                            m->map_size * secsz; i++, ent++) {
-                               if (uuid_is_nil((uuid_t *)&ent->ent_type, NULL))
-                                       continue;
                                gpt_dict = prop_dictionary_create();
                                PROP_ERR(gpt_dict);
                                propnum = prop_number_create_integer(i);
@@ -267,19 +266,13 @@
                                            "name", propstr);
                                        PROP_ERR(rc);
                                }
-                               if (gpt_array == NULL) {
-                                       gpt_array = prop_array_create();
-                                       PROP_ERR(gpt_array);
-                               }
                                rc = prop_array_add(gpt_array, gpt_dict);
                                PROP_ERR(rc);
                        }
-                       if (gpt_array != NULL) {
-                               rc = prop_dictionary_set(type_dict,
-                                   "gpt_array", gpt_array);
-                               PROP_ERR(rc);
-                               prop_object_release(gpt_array);
-                       }
+                       rc = prop_dictionary_set(type_dict,
+                           "gpt_array", gpt_array);
+                       PROP_ERR(rc);
+                       prop_object_release(gpt_array);
                        rc = prop_dictionary_set(props, "GPT_TBL", type_dict);
                        PROP_ERR(rc);
                        prop_object_release(type_dict);
@@ -291,6 +284,7 @@
        PROP_ERR(propext);
        prop_object_release(props);
        fputs(propext, stdout);
+       free(propext);
 }
 
 int



Home | Main Index | Thread Index | Old Index