geom_subr.c (108295) | geom_subr.c (109623) |
---|---|
1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * | 1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * |
35 * $FreeBSD: head/sys/geom/geom_subr.c 108295 2002-12-26 20:46:30Z phk $ | 35 * $FreeBSD: head/sys/geom/geom_subr.c 109623 2003-01-21 08:56:16Z alfred $ |
36 */ 37 38 39#include <sys/param.h> 40#include <sys/stdint.h> 41#ifndef _KERNEL 42#include <stdio.h> 43#include <unistd.h> --- 50 unchanged lines hidden (view full) --- 94 va_list ap; 95 struct sbuf *sb; 96 97 g_topology_assert(); 98 va_start(ap, fmt); 99 sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND); 100 sbuf_vprintf(sb, fmt, ap); 101 sbuf_finish(sb); | 36 */ 37 38 39#include <sys/param.h> 40#include <sys/stdint.h> 41#ifndef _KERNEL 42#include <stdio.h> 43#include <unistd.h> --- 50 unchanged lines hidden (view full) --- 94 va_list ap; 95 struct sbuf *sb; 96 97 g_topology_assert(); 98 va_start(ap, fmt); 99 sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND); 100 sbuf_vprintf(sb, fmt, ap); 101 sbuf_finish(sb); |
102 gp = g_malloc(sizeof *gp, M_WAITOK | M_ZERO); | 102 gp = g_malloc(sizeof *gp, M_ZERO); |
103 gp->protect = 0x020016601; | 103 gp->protect = 0x020016601; |
104 gp->name = g_malloc(sbuf_len(sb) + 1, M_WAITOK | M_ZERO); | 104 gp->name = g_malloc(sbuf_len(sb) + 1, M_ZERO); |
105 gp->class = mp; 106 gp->rank = 1; 107 LIST_INIT(&gp->consumer); 108 LIST_INIT(&gp->provider); 109 LIST_INSERT_HEAD(&mp->geom, gp, geom); 110 TAILQ_INSERT_HEAD(&geoms, gp, geoms); 111 strcpy(gp->name, sbuf_data(sb)); 112 sbuf_delete(sb); --- 24 unchanged lines hidden (view full) --- 137{ 138 struct g_consumer *cp; 139 140 g_topology_assert(); 141 KASSERT(gp->orphan != NULL, 142 ("g_new_consumer on geom(%s) (class %s) without orphan", 143 gp->name, gp->class->name)); 144 | 105 gp->class = mp; 106 gp->rank = 1; 107 LIST_INIT(&gp->consumer); 108 LIST_INIT(&gp->provider); 109 LIST_INSERT_HEAD(&mp->geom, gp, geom); 110 TAILQ_INSERT_HEAD(&geoms, gp, geoms); 111 strcpy(gp->name, sbuf_data(sb)); 112 sbuf_delete(sb); --- 24 unchanged lines hidden (view full) --- 137{ 138 struct g_consumer *cp; 139 140 g_topology_assert(); 141 KASSERT(gp->orphan != NULL, 142 ("g_new_consumer on geom(%s) (class %s) without orphan", 143 gp->name, gp->class->name)); 144 |
145 cp = g_malloc(sizeof *cp, M_WAITOK | M_ZERO); | 145 cp = g_malloc(sizeof *cp, M_ZERO); |
146 cp->protect = 0x020016602; 147 cp->geom = gp; 148 LIST_INSERT_HEAD(&gp->consumer, cp, consumer); 149 return(cp); 150} 151 152void 153g_destroy_consumer(struct g_consumer *cp) --- 17 unchanged lines hidden (view full) --- 171 struct sbuf *sb; 172 va_list ap; 173 174 g_topology_assert(); 175 va_start(ap, fmt); 176 sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND); 177 sbuf_vprintf(sb, fmt, ap); 178 sbuf_finish(sb); | 146 cp->protect = 0x020016602; 147 cp->geom = gp; 148 LIST_INSERT_HEAD(&gp->consumer, cp, consumer); 149 return(cp); 150} 151 152void 153g_destroy_consumer(struct g_consumer *cp) --- 17 unchanged lines hidden (view full) --- 171 struct sbuf *sb; 172 va_list ap; 173 174 g_topology_assert(); 175 va_start(ap, fmt); 176 sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND); 177 sbuf_vprintf(sb, fmt, ap); 178 sbuf_finish(sb); |
179 pp = g_malloc(sizeof *pp + sbuf_len(sb) + 1, M_WAITOK | M_ZERO); | 179 pp = g_malloc(sizeof *pp + sbuf_len(sb) + 1, M_ZERO); |
180 pp->protect = 0x020016603; 181 pp->name = (char *)(pp + 1); 182 strcpy(pp->name, sbuf_data(sb)); 183 sbuf_delete(sb); 184 LIST_INIT(&pp->consumers); 185 pp->error = ENXIO; 186 pp->geom = gp; 187 LIST_INSERT_HEAD(&gp->provider, pp, provider); --- 482 unchanged lines hidden (view full) --- 670 char *n; 671 672 if (p->len == 0) { 673 LIST_FOREACH(mp, &g_classes, class) 674 if ((uintptr_t)mp == p->u.id) 675 return (mp); 676 return (NULL); 677 } | 180 pp->protect = 0x020016603; 181 pp->name = (char *)(pp + 1); 182 strcpy(pp->name, sbuf_data(sb)); 183 sbuf_delete(sb); 184 LIST_INIT(&pp->consumers); 185 pp->error = ENXIO; 186 pp->geom = gp; 187 LIST_INSERT_HEAD(&gp->provider, pp, provider); --- 482 unchanged lines hidden (view full) --- 670 char *n; 671 672 if (p->len == 0) { 673 LIST_FOREACH(mp, &g_classes, class) 674 if ((uintptr_t)mp == p->u.id) 675 return (mp); 676 return (NULL); 677 } |
678 n = g_malloc(p->len + 1, M_WAITOK); | 678 n = g_malloc(p->len + 1, 0); |
679 if (copyin(p->u.name, n, p->len) == 0) { 680 n[p->len] = '\0'; 681 LIST_FOREACH(mp, &g_classes, class) 682 if (!bcmp(n, mp->name, p->len + 1)) { 683 g_free(n); 684 return (mp); 685 } 686 } --- 10 unchanged lines hidden (view full) --- 697 698 if (p->len == 0) { 699 LIST_FOREACH(mp, &g_classes, class) 700 LIST_FOREACH(gp, &mp->geom, geom) 701 if ((uintptr_t)gp == p->u.id) 702 return (gp); 703 return (NULL); 704 } | 679 if (copyin(p->u.name, n, p->len) == 0) { 680 n[p->len] = '\0'; 681 LIST_FOREACH(mp, &g_classes, class) 682 if (!bcmp(n, mp->name, p->len + 1)) { 683 g_free(n); 684 return (mp); 685 } 686 } --- 10 unchanged lines hidden (view full) --- 697 698 if (p->len == 0) { 699 LIST_FOREACH(mp, &g_classes, class) 700 LIST_FOREACH(gp, &mp->geom, geom) 701 if ((uintptr_t)gp == p->u.id) 702 return (gp); 703 return (NULL); 704 } |
705 n = g_malloc(p->len + 1, M_WAITOK); | 705 n = g_malloc(p->len + 1, 0); |
706 if (copyin(p->u.name, n, p->len) == 0) { 707 n[p->len] = '\0'; 708 LIST_FOREACH(mp, &g_classes, class) 709 LIST_FOREACH(gp, &mp->geom, geom) 710 if (!bcmp(n, gp->name, p->len + 1)) { 711 g_free(n); 712 return (gp); 713 } --- 13 unchanged lines hidden (view full) --- 727 if (p->len == 0) { 728 LIST_FOREACH(mp, &g_classes, class) 729 LIST_FOREACH(gp, &mp->geom, geom) 730 LIST_FOREACH(pp, &gp->provider, provider) 731 if ((uintptr_t)pp == p->u.id) 732 return (pp); 733 return (NULL); 734 } | 706 if (copyin(p->u.name, n, p->len) == 0) { 707 n[p->len] = '\0'; 708 LIST_FOREACH(mp, &g_classes, class) 709 LIST_FOREACH(gp, &mp->geom, geom) 710 if (!bcmp(n, gp->name, p->len + 1)) { 711 g_free(n); 712 return (gp); 713 } --- 13 unchanged lines hidden (view full) --- 727 if (p->len == 0) { 728 LIST_FOREACH(mp, &g_classes, class) 729 LIST_FOREACH(gp, &mp->geom, geom) 730 LIST_FOREACH(pp, &gp->provider, provider) 731 if ((uintptr_t)pp == p->u.id) 732 return (pp); 733 return (NULL); 734 } |
735 n = g_malloc(p->len + 1, M_WAITOK); | 735 n = g_malloc(p->len + 1, 0); |
736 if (copyin(p->u.name, n, p->len) == 0) { 737 n[p->len] = '\0'; 738 LIST_FOREACH(mp, &g_classes, class) 739 LIST_FOREACH(gp, &mp->geom, geom) 740 LIST_FOREACH(pp, &gp->provider, provider) 741 if (!bcmp(n, pp->name, p->len + 1)) { 742 g_free(n); 743 return (pp); 744 } 745 } 746 g_free(n); 747 return (NULL); 748} 749#endif /* _KERNEL */ | 736 if (copyin(p->u.name, n, p->len) == 0) { 737 n[p->len] = '\0'; 738 LIST_FOREACH(mp, &g_classes, class) 739 LIST_FOREACH(gp, &mp->geom, geom) 740 LIST_FOREACH(pp, &gp->provider, provider) 741 if (!bcmp(n, pp->name, p->len + 1)) { 742 g_free(n); 743 return (pp); 744 } 745 } 746 g_free(n); 747 return (NULL); 748} 749#endif /* _KERNEL */ |