Deleted Added
full compact
ctl_backend.c (256281) ctl_backend.c (268143)
1/*-
2 * Copyright (c) 2003 Silicon Graphics International Corp.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 */
32/*
33 * CTL backend driver registration routines
34 *
35 * Author: Ken Merry <ken@FreeBSD.org>
36 */
37
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003 Silicon Graphics International Corp.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 */
32/*
33 * CTL backend driver registration routines
34 *
35 * Author: Ken Merry <ken@FreeBSD.org>
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_backend.c 249410 2013-04-12 16:25:03Z trasz $");
39__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_backend.c 268143 2014-07-02 10:35:06Z mav $");
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/kernel.h>
44#include <sys/types.h>
45#include <sys/malloc.h>
46#include <sys/lock.h>
47#include <sys/mutex.h>

--- 120 unchanged lines hidden (view full) ---

168 }
169 }
170
171 mtx_unlock(&ctl_softc->ctl_lock);
172
173 return (NULL);
174}
175
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/kernel.h>
44#include <sys/types.h>
45#include <sys/malloc.h>
46#include <sys/lock.h>
47#include <sys/mutex.h>

--- 120 unchanged lines hidden (view full) ---

168 }
169 }
170
171 mtx_unlock(&ctl_softc->ctl_lock);
172
173 return (NULL);
174}
175
176/*
177 * vim: ts=8
178 */
176void
177ctl_init_opts(struct ctl_be_lun *be_lun, struct ctl_lun_req *req)
178{
179 struct ctl_be_lun_option *opt;
180 int i;
181
182 STAILQ_INIT(&be_lun->options);
183 for (i = 0; i < req->num_be_args; i++) {
184 opt = malloc(sizeof(*opt), M_CTL, M_WAITOK);
185 opt->name = malloc(strlen(req->kern_be_args[i].kname) + 1, M_CTL, M_WAITOK);
186 strcpy(opt->name, req->kern_be_args[i].kname);
187 opt->value = malloc(strlen(req->kern_be_args[i].kvalue) + 1, M_CTL, M_WAITOK);
188 strcpy(opt->value, req->kern_be_args[i].kvalue);
189 STAILQ_INSERT_TAIL(&be_lun->options, opt, links);
190 }
191}
192
193void
194ctl_free_opts(struct ctl_be_lun *be_lun)
195{
196 struct ctl_be_lun_option *opt;
197
198 while ((opt = STAILQ_FIRST(&be_lun->options)) != NULL) {
199 STAILQ_REMOVE_HEAD(&be_lun->options, links);
200 free(opt->name, M_CTL);
201 free(opt->value, M_CTL);
202 free(opt, M_CTL);
203 }
204}
205
206char *
207ctl_get_opt(struct ctl_be_lun *be_lun, const char *name)
208{
209 struct ctl_be_lun_option *opt;
210
211 STAILQ_FOREACH(opt, &be_lun->options, links) {
212 if (strcmp(opt->name, name) == 0) {
213 return (opt->value);
214 }
215 }
216 return (NULL);
217}