geom_vinum_share.c (190507) | geom_vinum_share.c (190881) |
---|---|
1/*- 2 * Copyright (c) 2004, 2007 Lukas Ertl 3 * Copyright (c) 1997, 1998, 1999 4 * Nan Yang Computer Services Limited. All rights reserved. 5 * 6 * Parts written by Greg Lehey 7 * 8 * This software is distributed under the so-called ``Berkeley --- 27 unchanged lines hidden (view full) --- 36 * otherwise) arising in any way out of the use of this software, even if 37 * advised of the possibility of such damage. 38 * 39 */ 40 41/* This file is shared between kernel and userland. */ 42 43#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2004, 2007 Lukas Ertl 3 * Copyright (c) 1997, 1998, 1999 4 * Nan Yang Computer Services Limited. All rights reserved. 5 * 6 * Parts written by Greg Lehey 7 * 8 * This software is distributed under the so-called ``Berkeley --- 27 unchanged lines hidden (view full) --- 36 * otherwise) arising in any way out of the use of this software, even if 37 * advised of the possibility of such damage. 38 * 39 */ 40 41/* This file is shared between kernel and userland. */ 42 43#include <sys/cdefs.h> |
44__FBSDID("$FreeBSD: head/sys/geom/vinum/geom_vinum_share.c 190507 2009-03-28 17:20:08Z lulf $"); | 44__FBSDID("$FreeBSD: head/sys/geom/vinum/geom_vinum_share.c 190881 2009-04-10 08:50:14Z lulf $"); |
45 46#include <sys/param.h> 47#ifdef _KERNEL 48#include <sys/malloc.h> 49#include <sys/systm.h> 50 51#include <geom/geom.h> 52#define iswhite(c) (((c) == ' ') || ((c) == '\t')) --- 309 unchanged lines hidden (view full) --- 362 return "S"; 363 case GV_PLEX_RAID5: 364 return "R5"; 365 default: 366 return "??"; 367 } 368} 369 | 45 46#include <sys/param.h> 47#ifdef _KERNEL 48#include <sys/malloc.h> 49#include <sys/systm.h> 50 51#include <geom/geom.h> 52#define iswhite(c) (((c) == ' ') || ((c) == '\t')) --- 309 unchanged lines hidden (view full) --- 362 return "S"; 363 case GV_PLEX_RAID5: 364 return "R5"; 365 default: 366 return "??"; 367 } 368} 369 |
370/* Get a new drive object. */ 371struct gv_drive * 372gv_new_drive(int max, char *token[]) | 370struct gv_sd * 371gv_alloc_sd(void) |
373{ | 372{ |
374 struct gv_drive *d; 375 int j, errors; 376 char *ptr; | 373 struct gv_sd *s; |
377 | 374 |
378 if (token[1] == NULL || *token[1] == '\0') | 375#ifdef _KERNEL 376 s = g_malloc(sizeof(struct gv_sd), M_NOWAIT); 377#else 378 s = malloc(sizeof(struct gv_sd)); 379#endif 380 if (s == NULL) |
379 return (NULL); | 381 return (NULL); |
382 bzero(s, sizeof(struct gv_sd)); 383 s->plex_offset = -1; 384 s->size = -1; 385 s->drive_offset = -1; 386 return (s); 387} |
|
380 | 388 |
389struct gv_drive * 390gv_alloc_drive(void) 391{ 392 struct gv_drive *d; 393 |
|
381#ifdef _KERNEL 382 d = g_malloc(sizeof(struct gv_drive), M_NOWAIT); 383#else 384 d = malloc(sizeof(struct gv_drive)); 385#endif 386 if (d == NULL) 387 return (NULL); 388 bzero(d, sizeof(struct gv_drive)); | 394#ifdef _KERNEL 395 d = g_malloc(sizeof(struct gv_drive), M_NOWAIT); 396#else 397 d = malloc(sizeof(struct gv_drive)); 398#endif 399 if (d == NULL) 400 return (NULL); 401 bzero(d, sizeof(struct gv_drive)); |
402 return (d); 403} |
|
389 | 404 |
405struct gv_volume * 406gv_alloc_volume(void) 407{ 408 struct gv_volume *v; 409 410#ifdef _KERNEL 411 v = g_malloc(sizeof(struct gv_volume), M_NOWAIT); 412#else 413 v = malloc(sizeof(struct gv_volume)); 414#endif 415 if (v == NULL) 416 return (NULL); 417 bzero(v, sizeof(struct gv_volume)); 418 return (v); 419} 420 421struct gv_plex * 422gv_alloc_plex(void) 423{ 424 struct gv_plex *p; 425 426#ifdef _KERNEL 427 p = g_malloc(sizeof(struct gv_plex), M_NOWAIT); 428#else 429 p = malloc(sizeof(struct gv_plex)); 430#endif 431 if (p == NULL) 432 return (NULL); 433 bzero(p, sizeof(struct gv_plex)); 434 return (p); 435} 436 437/* Get a new drive object. */ 438struct gv_drive * 439gv_new_drive(int max, char *token[]) 440{ 441 struct gv_drive *d; 442 int j, errors; 443 char *ptr; 444 445 if (token[1] == NULL || *token[1] == '\0') 446 return (NULL); 447 d = gv_alloc_drive(); 448 if (d == NULL) 449 return (NULL); |
|
390 errors = 0; 391 for (j = 1; j < max; j++) { 392 if (!strcmp(token[j], "state")) { 393 j++; 394 if (j >= max) { 395 errors++; 396 break; 397 } --- 31 unchanged lines hidden (view full) --- 429gv_new_volume(int max, char *token[]) 430{ 431 struct gv_volume *v; 432 int j, errors; 433 434 if (token[1] == NULL || *token[1] == '\0') 435 return (NULL); 436 | 450 errors = 0; 451 for (j = 1; j < max; j++) { 452 if (!strcmp(token[j], "state")) { 453 j++; 454 if (j >= max) { 455 errors++; 456 break; 457 } --- 31 unchanged lines hidden (view full) --- 489gv_new_volume(int max, char *token[]) 490{ 491 struct gv_volume *v; 492 int j, errors; 493 494 if (token[1] == NULL || *token[1] == '\0') 495 return (NULL); 496 |
437#ifdef _KERNEL 438 v = g_malloc(sizeof(struct gv_volume), M_NOWAIT); 439#else 440 v = malloc(sizeof(struct gv_volume)); 441#endif | 497 v = gv_alloc_volume(); |
442 if (v == NULL) 443 return (NULL); | 498 if (v == NULL) 499 return (NULL); |
444 bzero(v, sizeof(struct gv_volume)); | |
445 446 errors = 0; 447 for (j = 1; j < max; j++) { 448 if (!strcmp(token[j], "state")) { 449 j++; 450 if (j >= max) { 451 errors++; 452 break; --- 21 unchanged lines hidden (view full) --- 474gv_new_plex(int max, char *token[]) 475{ 476 struct gv_plex *p; 477 int j, errors; 478 479 if (token[1] == NULL || *token[1] == '\0') 480 return (NULL); 481 | 500 501 errors = 0; 502 for (j = 1; j < max; j++) { 503 if (!strcmp(token[j], "state")) { 504 j++; 505 if (j >= max) { 506 errors++; 507 break; --- 21 unchanged lines hidden (view full) --- 529gv_new_plex(int max, char *token[]) 530{ 531 struct gv_plex *p; 532 int j, errors; 533 534 if (token[1] == NULL || *token[1] == '\0') 535 return (NULL); 536 |
482#ifdef _KERNEL 483 p = g_malloc(sizeof(struct gv_plex), M_NOWAIT); 484#else 485 p = malloc(sizeof(struct gv_plex)); 486#endif | 537 p = gv_alloc_plex(); |
487 if (p == NULL) 488 return (NULL); | 538 if (p == NULL) 539 return (NULL); |
489 bzero(p, sizeof(struct gv_plex)); | |
490 491 errors = 0; 492 for (j = 1; j < max; j++) { 493 if (!strcmp(token[j], "name")) { 494 j++; 495 if (j >= max) { 496 errors++; 497 break; --- 43 unchanged lines hidden (view full) --- 541 if (errors) { 542 g_free(p); 543 return (NULL); 544 } 545 546 return (p); 547} 548 | 540 541 errors = 0; 542 for (j = 1; j < max; j++) { 543 if (!strcmp(token[j], "name")) { 544 j++; 545 if (j >= max) { 546 errors++; 547 break; --- 43 unchanged lines hidden (view full) --- 591 if (errors) { 592 g_free(p); 593 return (NULL); 594 } 595 596 return (p); 597} 598 |
599 600 |
|
549/* Get a new subdisk object. */ 550struct gv_sd * 551gv_new_sd(int max, char *token[]) 552{ 553 struct gv_sd *s; 554 int j, errors; 555 556 if (token[1] == NULL || *token[1] == '\0') 557 return (NULL); 558 | 601/* Get a new subdisk object. */ 602struct gv_sd * 603gv_new_sd(int max, char *token[]) 604{ 605 struct gv_sd *s; 606 int j, errors; 607 608 if (token[1] == NULL || *token[1] == '\0') 609 return (NULL); 610 |
559#ifdef _KERNEL 560 s = g_malloc(sizeof(struct gv_sd), M_NOWAIT); 561#else 562 s = malloc(sizeof(struct gv_sd)); 563#endif | 611 s = gv_alloc_sd(); |
564 if (s == NULL) 565 return (NULL); | 612 if (s == NULL) 613 return (NULL); |
566 bzero(s, sizeof(struct gv_sd)); | |
567 | 614 |
568 s->plex_offset = -1; 569 s->size = -1; 570 s->drive_offset = -1; | |
571 errors = 0; 572 for (j = 1; j < max; j++) { 573 if (!strcmp(token[j], "name")) { 574 j++; 575 if (j >= max) { 576 errors++; 577 break; 578 } --- 106 unchanged lines hidden --- | 615 errors = 0; 616 for (j = 1; j < max; j++) { 617 if (!strcmp(token[j], "name")) { 618 j++; 619 if (j >= max) { 620 errors++; 621 break; 622 } --- 106 unchanged lines hidden --- |