1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  14  */
  15 
  16 #include <sys/types.h>
  17 
  18 #include "krrp_ioctl_common.h"
  19 
  20 #define KRRP_IOCTL_EXPAND(enum_name) \
  21         {KRRP_IOCTL_##enum_name, "KRRP_IOCTL_"#enum_name},
  22 static struct {
  23         krrp_ioctl_cmd_t        cmd;
  24         const char                      *cmd_str;
  25 } ioctl_cmds[] = {
  26         KRRP_IOCTL_MAP(KRRP_IOCTL_EXPAND)
  27 };
  28 #undef KRRP_IOCTL_EXPAND
  29 
  30 static size_t ioctl_cmds_sz = sizeof (ioctl_cmds) / sizeof (ioctl_cmds[0]);
  31 
  32 const char *
  33 krrp_ioctl_cmd_to_str(krrp_ioctl_cmd_t cmd)
  34 {
  35         size_t i;
  36 
  37         for (i = 0; i < ioctl_cmds_sz; i++) {
  38                 if (ioctl_cmds[i].cmd == cmd)
  39                         return (ioctl_cmds[i].cmd_str);
  40         }
  41 
  42         return ("KRRP_IOCTL_UNKNOWN");
  43 }