cam_xpt.c (721fc9d8ec8347cdc7ac9f1aefb44dff3eeb2220) cam_xpt.c (ab3e89f1ab134186362abe9848a855d5077fbd40)
1/*-
2 * Implementation of the Common Access Method Transport (XPT) layer.
3 *
4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs.
5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

3692 return (-1);
3693 }
3694 return (retval);
3695}
3696
3697void
3698xpt_print_path(struct cam_path *path)
3699{
1/*-
2 * Implementation of the Common Access Method Transport (XPT) layer.
3 *
4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs.
5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

3692 return (-1);
3693 }
3694 return (retval);
3695}
3696
3697void
3698xpt_print_path(struct cam_path *path)
3699{
3700 struct sbuf sb;
3701 char buffer[XPT_PRINT_LEN];
3700
3702
3701 if (path == NULL)
3702 printf("(nopath): ");
3703 else {
3704 if (path->periph != NULL)
3705 printf("(%s%d:", path->periph->periph_name,
3706 path->periph->unit_number);
3707 else
3708 printf("(noperiph:");
3709
3710 if (path->bus != NULL)
3711 printf("%s%d:%d:", path->bus->sim->sim_name,
3712 path->bus->sim->unit_number,
3713 path->bus->sim->bus_id);
3714 else
3715 printf("nobus:");
3716
3717 if (path->target != NULL)
3718 printf("%d:", path->target->target_id);
3719 else
3720 printf("X:");
3721
3722 if (path->device != NULL)
3723 printf("%jx): ", (uintmax_t)path->device->lun_id);
3724 else
3725 printf("X): ");
3726 }
3703 sbuf_new(&sb, buffer, XPT_PRINT_LEN, SBUF_FIXEDLEN);
3704 xpt_path_sbuf(path, &sb);
3705 sbuf_finish(&sb);
3706 printf("%s", sbuf_data(&sb));
3707 sbuf_delete(&sb);
3727}
3728
3729void
3730xpt_print_device(struct cam_ed *device)
3731{
3732
3733 if (device == NULL)
3734 printf("(nopath): ");

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

3740 (uintmax_t)device->lun_id);
3741 }
3742}
3743
3744void
3745xpt_print(struct cam_path *path, const char *fmt, ...)
3746{
3747 va_list ap;
3708}
3709
3710void
3711xpt_print_device(struct cam_ed *device)
3712{
3713
3714 if (device == NULL)
3715 printf("(nopath): ");

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

3721 (uintmax_t)device->lun_id);
3722 }
3723}
3724
3725void
3726xpt_print(struct cam_path *path, const char *fmt, ...)
3727{
3728 va_list ap;
3748 xpt_print_path(path);
3729 struct sbuf sb;
3730 char buffer[XPT_PRINT_MAXLEN];
3731
3732 sbuf_new(&sb, buffer, XPT_PRINT_MAXLEN, SBUF_FIXEDLEN);
3733
3734 xpt_path_sbuf(path, &sb);
3749 va_start(ap, fmt);
3735 va_start(ap, fmt);
3750 vprintf(fmt, ap);
3736 sbuf_vprintf(&sb, fmt, ap);
3751 va_end(ap);
3737 va_end(ap);
3738
3739 sbuf_finish(&sb);
3740 printf("%s", sbuf_data(&sb));
3741 sbuf_delete(&sb);
3752}
3753
3754int
3755xpt_path_string(struct cam_path *path, char *str, size_t str_len)
3756{
3757 struct sbuf sb;
3742}
3743
3744int
3745xpt_path_string(struct cam_path *path, char *str, size_t str_len)
3746{
3747 struct sbuf sb;
3748 int len;
3758
3759 sbuf_new(&sb, str, str_len, 0);
3749
3750 sbuf_new(&sb, str, str_len, 0);
3751 len = xpt_path_sbuf(path, &sb);
3752 sbuf_finish(&sb);
3753 return (len);
3754}
3760
3755
3756int
3757xpt_path_sbuf(struct cam_path *path, struct sbuf *sb)
3758{
3759
3761 if (path == NULL)
3760 if (path == NULL)
3762 sbuf_printf(&sb, "(nopath): ");
3761 sbuf_printf(sb, "(nopath): ");
3763 else {
3764 if (path->periph != NULL)
3762 else {
3763 if (path->periph != NULL)
3765 sbuf_printf(&sb, "(%s%d:", path->periph->periph_name,
3764 sbuf_printf(sb, "(%s%d:", path->periph->periph_name,
3766 path->periph->unit_number);
3767 else
3765 path->periph->unit_number);
3766 else
3768 sbuf_printf(&sb, "(noperiph:");
3767 sbuf_printf(sb, "(noperiph:");
3769
3770 if (path->bus != NULL)
3768
3769 if (path->bus != NULL)
3771 sbuf_printf(&sb, "%s%d:%d:", path->bus->sim->sim_name,
3770 sbuf_printf(sb, "%s%d:%d:", path->bus->sim->sim_name,
3772 path->bus->sim->unit_number,
3773 path->bus->sim->bus_id);
3774 else
3771 path->bus->sim->unit_number,
3772 path->bus->sim->bus_id);
3773 else
3775 sbuf_printf(&sb, "nobus:");
3774 sbuf_printf(sb, "nobus:");
3776
3777 if (path->target != NULL)
3775
3776 if (path->target != NULL)
3778 sbuf_printf(&sb, "%d:", path->target->target_id);
3777 sbuf_printf(sb, "%d:", path->target->target_id);
3779 else
3778 else
3780 sbuf_printf(&sb, "X:");
3779 sbuf_printf(sb, "X:");
3781
3782 if (path->device != NULL)
3780
3781 if (path->device != NULL)
3783 sbuf_printf(&sb, "%jx): ",
3782 sbuf_printf(sb, "%jx): ",
3784 (uintmax_t)path->device->lun_id);
3785 else
3783 (uintmax_t)path->device->lun_id);
3784 else
3786 sbuf_printf(&sb, "X): ");
3785 sbuf_printf(sb, "X): ");
3787 }
3786 }
3788 sbuf_finish(&sb);
3789
3787
3790 return(sbuf_len(&sb));
3788 return(sbuf_len(sb));
3791}
3792
3793path_id_t
3794xpt_path_path_id(struct cam_path *path)
3795{
3796 return(path->bus->path_id);
3797}
3798

--- 1657 unchanged lines hidden ---
3789}
3790
3791path_id_t
3792xpt_path_path_id(struct cam_path *path)
3793{
3794 return(path->bus->path_id);
3795}
3796

--- 1657 unchanged lines hidden ---