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 (c) 2016 by Delphix. All rights reserved. 14-- 15 16arg = ... 17fs = arg["argv"][1] 18snap = arg["argv"][2] 19vol = arg["argv"][3] 20 21props = {} 22 23-- The values indicate whether or not a property should be returned, 24-- not the value of the property. A better approach might be to compare 25-- their values to the output of 'zfs get <prop>' 26 27-- prop filesystem snapshot volume 28props['used'] = {{true, nil}, {true, nil}, {true, nil}} 29props['available'] = {{true, nil}, {nil, nil}, {true, nil}} 30props['referenced'] = {{true, nil}, {true, nil}, {true, nil}} 31props['compressratio'] = {{true, nil}, {true, nil}, {true, nil}} 32props['refcompressratio'] = {{true, nil}, {true, nil}, {true, nil}} 33props['volblocksize'] = {{nil, nil}, {nil, nil}, {true, nil}} 34props['usedbysnapshots'] = {{true, nil}, {nil, nil}, {true, nil}} 35props['usedbydataset'] = {{true, nil}, {nil, nil}, {true, nil}} 36props['usedbychildren'] = {{true, nil}, {nil, nil}, {true, nil}} 37props['usedbyrefreservation'] = {{true, nil}, {nil, nil}, {true, nil}} 38props['userrefs'] = {{nil, nil}, {true, nil}, {nil, nil}} 39props['written'] = {{true, nil}, {true, nil}, {true, nil}} 40props['logicalused'] = {{true, nil}, {nil, nil}, {true, nil}} 41props['logicalreferenced'] = {{true, nil}, {true, nil}, {true, nil}} 42props['quota'] = {{true, 'default'}, {nil, nil}, {nil, nil}} 43props['reservation'] = {{true, 'default'}, {nil, nil}, {true, 'default'}} 44-- Note that OpenZFS allows volsize for snapshot 45-- props['volsize'] = {{nil, nil}, {nil, nil}, {true, vol}} 46props['refquota'] = {{true, 'default'}, {nil, nil}, {nil, nil}} 47props['refreservation'] = {{true, 'default'}, {nil, nil}, {true, vol}} 48props['filesystem_limit'] = {{true, fs}, {nil, nil}, {nil, nil}} 49props['snapshot_limit'] = {{true, fs}, {nil, nil}, {true, vol}} 50props['filesystem_count'] = {{true, nil}, {nil, nil}, {nil, nil}} 51props['snapshot_count'] = {{true, nil}, {nil, nil}, {true, nil}} 52props['recordsize'] = {{true, 'default'}, {nil, nil}, {nil, nil}} 53props['creation'] = {{true, nil}, {true, nil}, {true, nil}} 54-- hidden props 55props['createtxg'] = {{true, nil}, {true, nil}, {true, nil}} 56props['numclones'] = {{nil, nil}, {true, nil}, {nil, nil}} 57props['guid'] = {{true, nil}, {true, nil}, {true, nil}} 58props['useraccounting'] = {{true, nil}, {true, nil}, {true, nil}} 59props['unique'] = {{true, nil}, {true, nil}, {true, nil}} 60props['objsetid'] = {{true, nil}, {true, nil}, {true, nil}} 61props['inconsistent'] = {{true, nil}, {true, nil}, {true, nil}} 62 63 64fs_fails = {} 65snap_fails = {} 66vol_fails = {} 67 68function match(n, ans, src, expected) 69 if ((expected[n][1] == nil) and (ans ~= nil)) then 70 return false 71 end 72 73 if ((expected[n][1] == true) and (ans == nil)) then 74 return false 75 end 76 77 if (expected[n][2] ~= src) then 78 return false 79 end 80 81 return true 82end 83 84for prop, expected in pairs(props) do 85 ans, src = zfs.get_prop(fs, prop) 86 if not (match(1, ans, src, expected)) then 87 fs_fails[prop] = {ans, src} 88 end 89 90 ans, src = zfs.get_prop(snap, prop) 91 if not (match(2, ans, src, expected)) then 92 snap_fails[prop] = {ans, src} 93 end 94 95 ans, src = zfs.get_prop(vol, prop) 96 if not (match(3, ans, src, expected)) then 97 vol_fails[prop] = {ans, src} 98 end 99end 100 101return {fs_fails, snap_fails, vol_fails} 102