#!/usr/bin/env python # coding: utf-8 # # smb2-quota is a cmdline tool to display quota information for the # Linux SMB client file system (CIFS) # # Copyright (C) Ronnie Sahlberg (lsahlberg@redhat.com) 2019 # Copyright (C) Kenneth D'souza (kdsouza@redhat.com) 2019 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import array import fcntl import os import struct import sys import argparse CIFS_QUERY_INFO = 0xc018cf07 BBOLD = '\033[1;30;47m' # Bold black text with white background. ENDC = '\033[m' # Rest to defaults def usage(): print("Usage: %s [-h] " % sys.argv[0]) print("Try 'smb2-quota -h' for more information") sys.exit() class SID: def __init__(self, buf): self.sub_authority_count = buf[1] self.buffer = buf[:8 + self.sub_authority_count * 4] self.revision = self.buffer[0] if self.revision != 1: raise ValueError('SID Revision %d not supported' % self.revision) self.identifier_authority = 0 for x in self.buffer[2:8]: self.identifier_authority = self.identifier_authority * 256 + x self.sub_authority = [] for i in range(self.sub_authority_count): self.sub_authority.append(struct.unpack_from(' limit: return "Above Limit" elif warn < used < limit: return "Warning" else: return "Ok" class QuotaEntry: def __init__(self, buf, flag): sl = struct.unpack_from('