#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
"""This module implements the "zfs userspace" and "zfs groupspace" subcommands.
The only public interface is the zfs.userspace.do_userspace() function."""
import sys
import pwd
import grp
import errno
# map from property name prefix -> (field name, isgroup)
props = {
}
"""Return True if this property (eg "userquota@") should be skipped."""
return True
return True
return True
return False
"""Return a dict("field": value) for this domain (string) + rid (int)"""
if domain:
else:
return None
v = dict()
v["type"] = typename
try:
except KeyError:
pass
if "name" not in v:
v["name"] = idstr
if not domain:
# it's just a number, so pad it with spaces so
# that it will sort numerically
# fill in default values
v["used"] = "0"
v["used.sort"] = 0
v["quota"] = "none"
v["quota.sort"] = 0
return v
"""Update the acct dict to incorporate the
information from this elem from Dataset.userspace(prop)."""
try:
not isgroup)
domain = None
except KeyError:
pass;
try:
except KeyError:
if not v:
return
# Add our value to an existing value, which may be present if
# options.translate is set.
else:
def do_userspace():
"""Implements the "zfs userspace" and "zfs groupspace" subcommands."""
if msg:
print
else:
defaulttypes = "posixuser,smbuser"
else:
defaulttypes = "posixgroup,smbgroup"
u += _(" [-t type[,...]] <filesystem|snapshot>")
help=_("translate SID to posix (possibly ephemeral) ID"))
help=_("no headers, tab delimited output"))
help=_("exact (parsable) numeric output"))
default="type,name,used,quota",
help=_("print only these fields (eg type,name,used,quota)"))
help=_("sort field"))
help=_("reverse sort field"))
help=_("print only these types (eg posixuser,smbuser,posixgroup,smbgroup,all)"))
usage(_("wrong number of arguments"))
if f not in fields:
usage(_("invalid field %s") % f)
if t not in types:
usage(_("invalid type %s") % t)
if not options.sortfields:
print(_("Initializing accounting information on old filesystem, please wait..."))
# gather and process accounting information
# Due to -i, we need to keep a dict, so we can potentially add
# together the posix ID and SID's usage. Grr.
continue;
l = list()
try:
except KeyError:
if opt == "-S":
# reverse sorting
try:
n = -n
except TypeError:
# it's a string; decompose it
# into an array of integers,
# each one the negative of that
# character
n = [-ord(c) for c in n]
l.append(n)
return l