summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth D'souza <kdsouza@redhat.com>2019-11-21 20:40:56 +0530
committerPavel Shilovsky <pshilov@microsoft.com>2019-12-12 15:55:50 -0800
commitb10aaefcd9de4e35b3e2a0753861468725d9c186 (patch)
treef69cee962566a7c26c2b5e128de9bf5ee428c7df
parentbe37d3d1a9af2c9eddd5a11d7685655c18744053 (diff)
downloadcifs-utils-b10aaefcd9de4e35b3e2a0753861468725d9c186.tar.gz
cifs-utils-b10aaefcd9de4e35b3e2a0753861468725d9c186.tar.bz2
cifs-utils-b10aaefcd9de4e35b3e2a0753861468725d9c186.zip
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 <kdsouza@redhat.com> Signed-off-by: Ronnie Sahlberg <lsahlberg@redhat.com>
-rwxr-xr-xsmb2-quota.py (renamed from smb2quota.py)19
-rw-r--r--smb2-quota.rst (renamed from smb2quota.rst)8
2 files changed, 11 insertions, 16 deletions
diff --git a/smb2quota.py b/smb2-quota.py
index 21bf4ff..6d0b8a3 100755
--- a/smb2quota.py
+++ b/smb2-quota.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# coding: utf-8
#
-# smb2quota is a cmdline tool to display quota information for the
+# 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
@@ -34,7 +34,7 @@ ENDC = '\033[m' # Rest to defaults
def usage():
print("Usage: %s [-h] <options> <filename>" % sys.argv[0])
- print("Try 'smb2quota -h' for more information")
+ print("Try 'smb2-quota -h' for more information")
sys.exit()
@@ -120,18 +120,13 @@ class QuotaEntry:
class Quota:
def __init__(self, buf, flag):
self.quota = []
- s = struct.unpack_from('<I', buf, 0)[0]
- while s:
- qe = QuotaEntry(buf[0:s], flag)
+ while buf:
+ qe = QuotaEntry(buf, flag)
self.quota.append(qe)
- buf = buf[s:]
- a = s
s = struct.unpack_from('<I', buf, 0)[0]
if s == 0:
- s = a # Use the last value of s and process it.
- qe = QuotaEntry(buf[0:s], flag)
- self.quota.append(qe)
break
+ buf = buf[s:]
def __str__(self):
s = ''
@@ -158,7 +153,7 @@ def parser_check(path, flag):
fcntl.ioctl(f, CIFS_QUERY_INFO, buf, 1)
os.close(f)
if flag == 0:
- print(BBOLD + " %-7s | %-7s | %-7s | %-7s | %-12s | %s " + ENDC) % (titleused, titlelim, titlethr, titlepercent, titlestatus, titlesid)
+ print((BBOLD + " %-7s | %-7s | %-7s | %-7s | %-12s | %s " + ENDC) % (titleused, titlelim, titlethr, titlepercent, titlestatus, titlesid))
q = Quota(buf[24:24 + struct.unpack_from('<I', buf, 16)[0]], flag)
print(q)
except IOError as reason:
@@ -171,7 +166,7 @@ def main():
if len(sys.argv) < 2:
usage()
- parser = argparse.ArgumentParser(description="Please specify an action to perform.", prog="smb2quota")
+ parser = argparse.ArgumentParser(description="Please specify an action to perform.", prog="smb2-quota")
parser.add_argument("-t", "--tabular", action="store_true", help="print quota information in tabular format")
parser.add_argument("-c", "--csv", action="store_true", help="print quota information in csv format")
parser.add_argument("-l", "--list", action="store_true", help="print quota information in list format")
diff --git a/smb2quota.rst b/smb2-quota.rst
index 24caca8..508b874 100644
--- a/smb2quota.rst
+++ b/smb2-quota.rst
@@ -1,5 +1,5 @@
============
-smb2quota
+smb2-quota
============
-----------------------------------------------------------------------------------------------------
@@ -11,7 +11,7 @@ Userspace helper to display quota information for the Linux SMB client file syst
SYNOPSIS
********
- smb2quota [-h] {options} {file system object}
+ smb2-quota [-h] {options} {file system object}
***********
DESCRIPTION
@@ -19,7 +19,7 @@ DESCRIPTION
This tool is part of the cifs-utils suite.
-`smb2quota` is a userspace helper program for the Linux SMB
+`smb2-quota` is a userspace helper program for the Linux SMB
client file system (CIFS).
This tool works by making an CIFS_QUERY_INFO IOCTL call to the Linux
@@ -49,7 +49,7 @@ SID,Amount Used,Quota Limit,Warning Level
NOTES
*****
-Kernel support for smb2quota requires the CIFS_QUERY_INFO
+Kernel support for smb2-quota requires the CIFS_QUERY_INFO
IOCTL which was initially introduced in the 4.20 kernel and is only
implemented for mount points using SMB2 or above (see mount.cifs(8)
`vers` option).