Print this page
5253 kmem_alloc/kmem_zalloc won't fail with KM_SLEEP
5254 getrbuf won't fail with KM_SLEEP


 102                 return (NULL);
 103 
 104         /* Validate resulting vnode */
 105         if ((vp) && (vp->v_type == VCHR))
 106                 rdev = vp->v_rdev;
 107         else
 108                 rdev = (dev_t)NULL;
 109 
 110         /* Release vnode */
 111         if (vp)
 112                 VN_RELE(vp);
 113 
 114         return (rdev);
 115 }
 116 
 117 int
 118 _nsc_init_raw(int maxdevs)
 119 {
 120         _nsc_raw_files =
 121             kmem_zalloc(sizeof (*_nsc_raw_files) * maxdevs, KM_SLEEP);
 122         if (!_nsc_raw_files)
 123                 return (ENOMEM);
 124 
 125         _nsc_raw_maxdevs = maxdevs;
 126         _nsc_raw_majors = NULL;
 127 
 128         mutex_init(&_nsc_raw_lock, NULL, MUTEX_DRIVER, NULL);
 129         return (0);
 130 }
 131 
 132 
 133 void
 134 _nsc_deinit_raw(void)
 135 {
 136         raw_maj_t *maj = _nsc_raw_majors;
 137         raw_maj_t *next;
 138 
 139         /*  Free the memory allocated for strategy pointers */
 140         while (maj != NULL) {
 141                 next = maj->next;
 142                 kmem_free(maj, sizeof (*maj));
 143                 maj = next;


 287         struct cred *cred;
 288         raw_dev_t *cdi = NULL;
 289         char *spath;
 290         dev_t rdev;
 291         int rc, cd, the_cd;
 292         int plen;
 293         ldi_ident_t     li;
 294 
 295         if (proc_nskernd == NULL) {
 296                 cmn_err(CE_WARN, "nskern: no nskernd daemon running!");
 297                 return (ENXIO);
 298         }
 299 
 300         if (_nsc_raw_maxdevs == 0) {
 301                 cmn_err(CE_WARN, "nskern: _raw_open() before _nsc_init_raw()!");
 302                 return (ENXIO);
 303         }
 304 
 305         plen = strlen(path) + 1;
 306         spath = kmem_alloc(plen, KM_SLEEP);
 307         if (spath == NULL) {
 308                 cmn_err(CE_WARN,
 309                     "nskern: unable to alloc memory in _raw_open()");
 310                 return (ENOMEM);
 311         }
 312 
 313         (void) strcpy(spath, path);
 314 
 315         /*
 316          * Lookup the vnode to extract the dev_t info,
 317          * then release the vnode.
 318          */
 319         if ((rdev = ldi_get_dev_t_from_path(path)) == 0) {
 320                 kmem_free(spath, plen);
 321                 return (ENXIO);
 322         }
 323 
 324         /*
 325          * See if this device is already opened
 326          */
 327 
 328         the_cd = -1;
 329 
 330         mutex_enter(&_nsc_raw_lock);
 331 




 102                 return (NULL);
 103 
 104         /* Validate resulting vnode */
 105         if ((vp) && (vp->v_type == VCHR))
 106                 rdev = vp->v_rdev;
 107         else
 108                 rdev = (dev_t)NULL;
 109 
 110         /* Release vnode */
 111         if (vp)
 112                 VN_RELE(vp);
 113 
 114         return (rdev);
 115 }
 116 
 117 int
 118 _nsc_init_raw(int maxdevs)
 119 {
 120         _nsc_raw_files =
 121             kmem_zalloc(sizeof (*_nsc_raw_files) * maxdevs, KM_SLEEP);


 122 
 123         _nsc_raw_maxdevs = maxdevs;
 124         _nsc_raw_majors = NULL;
 125 
 126         mutex_init(&_nsc_raw_lock, NULL, MUTEX_DRIVER, NULL);
 127         return (0);
 128 }
 129 
 130 
 131 void
 132 _nsc_deinit_raw(void)
 133 {
 134         raw_maj_t *maj = _nsc_raw_majors;
 135         raw_maj_t *next;
 136 
 137         /*  Free the memory allocated for strategy pointers */
 138         while (maj != NULL) {
 139                 next = maj->next;
 140                 kmem_free(maj, sizeof (*maj));
 141                 maj = next;


 285         struct cred *cred;
 286         raw_dev_t *cdi = NULL;
 287         char *spath;
 288         dev_t rdev;
 289         int rc, cd, the_cd;
 290         int plen;
 291         ldi_ident_t     li;
 292 
 293         if (proc_nskernd == NULL) {
 294                 cmn_err(CE_WARN, "nskern: no nskernd daemon running!");
 295                 return (ENXIO);
 296         }
 297 
 298         if (_nsc_raw_maxdevs == 0) {
 299                 cmn_err(CE_WARN, "nskern: _raw_open() before _nsc_init_raw()!");
 300                 return (ENXIO);
 301         }
 302 
 303         plen = strlen(path) + 1;
 304         spath = kmem_alloc(plen, KM_SLEEP);





 305 
 306         (void) strcpy(spath, path);
 307 
 308         /*
 309          * Lookup the vnode to extract the dev_t info,
 310          * then release the vnode.
 311          */
 312         if ((rdev = ldi_get_dev_t_from_path(path)) == 0) {
 313                 kmem_free(spath, plen);
 314                 return (ENXIO);
 315         }
 316 
 317         /*
 318          * See if this device is already opened
 319          */
 320 
 321         the_cd = -1;
 322 
 323         mutex_enter(&_nsc_raw_lock);
 324