Print this page
NEX-15328 libdiskmgt: memleak in findevs()
Reviewed by: Alexander Eremin <alexander.eremin@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-15328 libdiskmgt: memleak in findevs()
Reviewed by: Alexander Eremin <alexander.eremin@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-14951 teach libdiskmgt about nvme, sata and xen
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>


 134 /*
 135  * The functions in this file do a dev tree walk to build up a model of the
 136  * disks, controllers and paths on the system.  This model is returned in the
 137  * args->disk_listp and args->controller_listp members of the args param.
 138  * There is no global data for this file so it is thread safe.  It is up to
 139  * the caller to merge the resulting model with any existing model that is
 140  * cached.  The caller must also free the memory for this model when it is
 141  * no longer needed.
 142  */
 143 void
 144 findevs(struct search_args *args)
 145 {
 146         di_node_t               di_root;
 147 
 148         args->bus_listp = NULL;
 149         args->controller_listp = NULL;
 150         args->disk_listp = NULL;
 151 
 152         args->dev_walk_status = 0;
 153         args->handle = di_devlink_init(NULL, 0);

 154 
 155         /*
 156          * Have to make several passes at this with the new devfs caching.
 157          * First, we find non-mpxio devices. Then we find mpxio/multipath
 158          * devices.
 159          */
 160         di_root = di_init("/", DINFOCACHE);
 161         args->ph = di_prom_init();
 162         (void) di_walk_minor(di_root, NULL, 0, args, add_devs);
 163         di_fini(di_root);
 164 
 165         di_root = di_init("/", DINFOCPYALL|DINFOPATH);
 166         (void) di_walk_minor(di_root, NULL, 0, args, add_devs);
 167         di_fini(di_root);
 168 


 169         (void) di_devlink_fini(&(args->handle));
 170 
 171         clean_paths(args);
 172 }
 173 
 174 /*
 175  * Definitions of private functions
 176  */
 177 
 178 static bus_t *
 179 add_bus(struct search_args *args, di_node_t node, di_minor_t minor,
 180     controller_t *cp)
 181 {
 182         char            *btype;
 183         char            *devpath;
 184         bus_t           *bp;
 185         char            kstat_name[MAXPATHLEN];
 186         di_node_t       pnode;
 187 
 188         if (node == DI_NODE_NIL) {




 134 /*
 135  * The functions in this file do a dev tree walk to build up a model of the
 136  * disks, controllers and paths on the system.  This model is returned in the
 137  * args->disk_listp and args->controller_listp members of the args param.
 138  * There is no global data for this file so it is thread safe.  It is up to
 139  * the caller to merge the resulting model with any existing model that is
 140  * cached.  The caller must also free the memory for this model when it is
 141  * no longer needed.
 142  */
 143 void
 144 findevs(struct search_args *args)
 145 {
 146         di_node_t               di_root;
 147 
 148         args->bus_listp = NULL;
 149         args->controller_listp = NULL;
 150         args->disk_listp = NULL;
 151 
 152         args->dev_walk_status = 0;
 153         args->handle = di_devlink_init(NULL, 0);
 154         args->ph = di_prom_init();
 155 
 156         /*
 157          * Have to make several passes at this with the new devfs caching.
 158          * First, we find non-mpxio devices. Then we find mpxio/multipath
 159          * devices.
 160          */
 161         di_root = di_init("/", DINFOCACHE);

 162         (void) di_walk_minor(di_root, NULL, 0, args, add_devs);
 163         di_fini(di_root);
 164 
 165         di_root = di_init("/", DINFOCPYALL|DINFOPATH);
 166         (void) di_walk_minor(di_root, NULL, 0, args, add_devs);
 167         di_fini(di_root);
 168 
 169         if (args->ph != DI_PROM_HANDLE_NIL)
 170                 di_prom_fini(args->ph);
 171         (void) di_devlink_fini(&(args->handle));
 172 
 173         clean_paths(args);
 174 }
 175 
 176 /*
 177  * Definitions of private functions
 178  */
 179 
 180 static bus_t *
 181 add_bus(struct search_args *args, di_node_t node, di_minor_t minor,
 182     controller_t *cp)
 183 {
 184         char            *btype;
 185         char            *devpath;
 186         bus_t           *bp;
 187         char            kstat_name[MAXPATHLEN];
 188         di_node_t       pnode;
 189 
 190         if (node == DI_NODE_NIL) {