From: Kenneth D'souza <kdsouza@redhat.com>
To: linux-cifs@vger.kernel.org
Cc: piastryyy@gmail.com, smfrench@gmail.com, lsahlber@redhat.com
Subject: [PATCH] smb2-quota: Simplify code logic for quota entries.
Date: Thu, 21 Nov 2019 20:40:56 +0530 [thread overview]
Message-ID: <20191121151056.19392-1-kdsouza@redhat.com> (raw)
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>
---
smb2quota.py => smb2-quota.py | 19 +++++++------------
smb2quota.rst => smb2-quota.rst | 8 ++++----
2 files changed, 11 insertions(+), 16 deletions(-)
rename smb2quota.py => smb2-quota.py (91%)
rename smb2quota.rst => smb2-quota.rst (89%)
diff --git a/smb2quota.py b/smb2-quota.py
similarity index 91%
rename from smb2quota.py
rename to 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
similarity index 89%
rename from smb2quota.rst
rename to 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).
--
2.21.0
next reply other threads:[~2019-11-21 15:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-21 15:10 Kenneth D'souza [this message]
2019-12-13 0:29 ` [PATCH] smb2-quota: Simplify code logic for quota entries Pavel Shilovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191121151056.19392-1-kdsouza@redhat.com \
--to=kdsouza@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=lsahlber@redhat.com \
--cc=piastryyy@gmail.com \
--cc=smfrench@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).