From b10aaefcd9de4e35b3e2a0753861468725d9c186 Mon Sep 17 00:00:00 2001 From: Kenneth D'souza Date: Thu, 21 Nov 2019 20:40:56 +0530 Subject: smb2-quota: Simplify code logic for quota entries. This patch changes the program name from smb2quota to smb2-quota and uses a simple code logic for quota entries. Signed-off-by: Kenneth D'souza Signed-off-by: Ronnie Sahlberg --- smb2-quota.py | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ smb2-quota.rst | 70 +++++++++++++++++++++ smb2quota.py | 195 --------------------------------------------------------- smb2quota.rst | 70 --------------------- 4 files changed, 260 insertions(+), 265 deletions(-) create mode 100755 smb2-quota.py create mode 100644 smb2-quota.rst delete mode 100755 smb2quota.py delete mode 100644 smb2quota.rst diff --git a/smb2-quota.py b/smb2-quota.py new file mode 100755 index 0000000..6d0b8a3 --- /dev/null +++ b/smb2-quota.py @@ -0,0 +1,190 @@ +#!/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(' + +The Linux CIFS Mailing list is the preferred place to ask questions +regarding these programs. diff --git a/smb2quota.py b/smb2quota.py deleted file mode 100755 index 21bf4ff..0000000 --- a/smb2quota.py +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 -# -# smb2quota 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 'smb2quota -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(' - -The Linux CIFS Mailing list is the preferred place to ask questions -regarding these programs. -- cgit v1.2.3