libzfs_core_compat.c (248461) | libzfs_core_compat.c (248498) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 19 unchanged lines hidden (view full) --- 28#include "libzfs_core_compat.h" 29 30extern int zfs_ioctl_version; 31 32int 33lzc_compat_pre(zfs_cmd_t *zc, zfs_ioc_t *ioc, nvlist_t **source) 34{ 35 nvlist_t *nvl = NULL; | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 19 unchanged lines hidden (view full) --- 28#include "libzfs_core_compat.h" 29 30extern int zfs_ioctl_version; 31 32int 33lzc_compat_pre(zfs_cmd_t *zc, zfs_ioc_t *ioc, nvlist_t **source) 34{ 35 nvlist_t *nvl = NULL; |
36 nvpair_t *pair; 37 char *buf; | 36 nvpair_t *pair, *hpair; 37 char *buf, *val; |
38 zfs_ioc_t vecnum; 39 uint32_t type32; | 38 zfs_ioc_t vecnum; 39 uint32_t type32; |
40 int32_t cleanup_fd; |
|
40 int error = 0; 41 int pos; 42 43 if (zfs_ioctl_version >= ZFS_IOCVER_LZC) 44 return (0); 45 46 vecnum = *ioc; 47 --- 15 unchanged lines hidden (view full) --- 63 nvl = fnvlist_lookup_nvlist(*source, "snaps"); 64 pair = nvlist_next_nvpair(nvl, NULL); 65 if (pair != NULL) { 66 buf = nvpair_name(pair); 67 pos = strcspn(buf, "@"); 68 strlcpy(zc->zc_name, buf, pos + 1); 69 strlcpy(zc->zc_value, buf + pos + 1, MAXPATHLEN); 70 } else | 41 int error = 0; 42 int pos; 43 44 if (zfs_ioctl_version >= ZFS_IOCVER_LZC) 45 return (0); 46 47 vecnum = *ioc; 48 --- 15 unchanged lines hidden (view full) --- 64 nvl = fnvlist_lookup_nvlist(*source, "snaps"); 65 pair = nvlist_next_nvpair(nvl, NULL); 66 if (pair != NULL) { 67 buf = nvpair_name(pair); 68 pos = strcspn(buf, "@"); 69 strlcpy(zc->zc_name, buf, pos + 1); 70 strlcpy(zc->zc_value, buf + pos + 1, MAXPATHLEN); 71 } else |
71 error = EOPNOTSUPP; | 72 error = EINVAL; |
72 /* old kernel cannot create multiple snapshots */ 73 if (!error && nvlist_next_nvpair(nvl, pair) != NULL) 74 error = EOPNOTSUPP; 75 nvlist_free(nvl); 76 nvl = NULL; 77 nvlist_lookup_nvlist(*source, "props", &nvl); 78 *source = nvl; 79 break; 80 case ZFS_IOC_SPACE_SNAPS: 81 buf = fnvlist_lookup_string(*source, "firstsnap"); 82 strlcpy(zc->zc_value, buf, MAXPATHLEN); 83 break; 84 case ZFS_IOC_DESTROY_SNAPS: 85 nvl = fnvlist_lookup_nvlist(*source, "snaps"); 86 pair = nvlist_next_nvpair(nvl, NULL); 87 if (pair != NULL) { 88 buf = nvpair_name(pair); 89 pos = strcspn(buf, "@"); 90 strlcpy(zc->zc_name, buf, pos + 1); | 73 /* old kernel cannot create multiple snapshots */ 74 if (!error && nvlist_next_nvpair(nvl, pair) != NULL) 75 error = EOPNOTSUPP; 76 nvlist_free(nvl); 77 nvl = NULL; 78 nvlist_lookup_nvlist(*source, "props", &nvl); 79 *source = nvl; 80 break; 81 case ZFS_IOC_SPACE_SNAPS: 82 buf = fnvlist_lookup_string(*source, "firstsnap"); 83 strlcpy(zc->zc_value, buf, MAXPATHLEN); 84 break; 85 case ZFS_IOC_DESTROY_SNAPS: 86 nvl = fnvlist_lookup_nvlist(*source, "snaps"); 87 pair = nvlist_next_nvpair(nvl, NULL); 88 if (pair != NULL) { 89 buf = nvpair_name(pair); 90 pos = strcspn(buf, "@"); 91 strlcpy(zc->zc_name, buf, pos + 1); |
91 } | 92 } else 93 error = EINVAL; 94 /* old kernel cannot atomically destroy multiple snaps */ 95 if (!error && nvlist_next_nvpair(nvl, pair) != NULL) 96 error = EOPNOTSUPP; |
92 *source = nvl; 93 break; | 97 *source = nvl; 98 break; |
99 case ZFS_IOC_HOLD: 100 nvl = fnvlist_lookup_nvlist(*source, "holds"); 101 pair = nvlist_next_nvpair(nvl, NULL); 102 if (pair != NULL) { 103 buf = nvpair_name(pair); 104 pos = strcspn(buf, "@"); 105 strlcpy(zc->zc_name, buf, pos + 1); 106 strlcpy(zc->zc_value, buf + pos + 1, MAXPATHLEN); 107 if (nvpair_value_string(pair, &val) == 0) 108 strlcpy(zc->zc_string, val, MAXNAMELEN); 109 else 110 error = EINVAL; 111 } else 112 error = EINVAL; 113 /* old kernel cannot atomically create multiple holds */ 114 if (!error && nvlist_next_nvpair(nvl, pair) != NULL) 115 error = EOPNOTSUPP; 116 nvlist_free(nvl); 117 if (nvlist_lookup_int32(*source, "cleanup_fd", 118 &cleanup_fd) == 0) 119 zc->zc_cleanup_fd = cleanup_fd; 120 else 121 zc->zc_cleanup_fd = -1; 122 break; 123 case ZFS_IOC_RELEASE: 124 pair = nvlist_next_nvpair(*source, NULL); 125 if (pair != NULL) { 126 buf = nvpair_name(pair); 127 pos = strcspn(buf, "@"); 128 strlcpy(zc->zc_name, buf, pos + 1); 129 strlcpy(zc->zc_value, buf + pos + 1, MAXPATHLEN); 130 if (nvpair_value_nvlist(pair, &nvl) == 0) { 131 hpair = nvlist_next_nvpair(nvl, NULL); 132 if (hpair != NULL) 133 strlcpy(zc->zc_string, 134 nvpair_name(hpair), MAXNAMELEN); 135 else 136 error = EINVAL; 137 if (!error && nvlist_next_nvpair(nvl, 138 hpair) != NULL) 139 error = EOPNOTSUPP; 140 } else 141 error = EINVAL; 142 } else 143 error = EINVAL; 144 /* old kernel cannot atomically release multiple holds */ 145 if (!error && nvlist_next_nvpair(nvl, pair) != NULL) 146 error = EOPNOTSUPP; 147 break; |
|
94 } 95 96 return (error); 97} 98 99void 100lzc_compat_post(zfs_cmd_t *zc, const zfs_ioc_t ioc) 101{ --- 34 unchanged lines hidden --- | 148 } 149 150 return (error); 151} 152 153void 154lzc_compat_post(zfs_cmd_t *zc, const zfs_ioc_t ioc) 155{ --- 34 unchanged lines hidden --- |