Linux-CIFS Archive on lore.kernel.org
 help / color / Atom feed
From: Kenneth Dsouza <kdsouza@redhat.com>
To: "Aurélien Aptel" <aaptel@suse.com>
Cc: Pavel Shilovsky <piastryyy@gmail.com>,
	Steve French <smfrench@gmail.com>,
	CIFS <linux-cifs@vger.kernel.org>,
	Ronnie Sahlberg <lsahlber@redhat.com>
Subject: Re: [PATCH] smb2quota.py: Userspace helper to display quota information for the Linux SMB client file system (CIFS)
Date: Wed, 9 Oct 2019 19:27:40 +0530
Message-ID: <CAA_-hQL+2nn6N7ig13onQpnDdTC2Ceb1Z6TSnsJCRdJYLYCiFg@mail.gmail.com> (raw)
In-Reply-To: <87o8yqf4f6.fsf@suse.com>

Can you try the new updated patch?
Some of the suggested changes have been incorporated.
Pavel picked up the new changes from my github repo.
https://github.com/piastry/cifs-utils/commits/next

I will send a follow-on patch to work on the remaining changes.

On Wed, Oct 9, 2019 at 6:43 PM Aurélien Aptel <aaptel@suse.com> wrote:
>
>
> We now have 2 user scripts in the repo but the configure script doesn't
> know about them: they are not installed. If they are considered dev
> tools or experimental that's fine otherwise we should consider
> installing them on make install. I just wanted to point this out.
>
> A bit late but some comments on the script.
>
> Kenneth D'souza <kdsouza@redhat.com> writes:
> > +#!/usr/bin/env python
>
> We should script for python3 at this point I think. Python2 is on the
> way out.
>
> > +def usage():
> > +    print("Usage: %s [-h] <options>  <filename>" % sys.argv[0])
> > +    print("Try 'smb2quota -h' for more information")
> > +    sys.exit()
>
> argparse already generates usage message from its conf.
>
> > +
> > +def parser_check(path, flag):
> > +    titleused = "Amount Used"
> > +    titlelim = "Quota Limit"
> > +    titlethr = "Warning Level"
> > +    titlesid = "SID"
> > +    buf = array.array('B', [0] * 16384)
> > +    struct.pack_into('<I', buf, 0, 4)  # InfoType: Quota
> > +    struct.pack_into('<I', buf, 16, 16384)  # InputBufferLength
> > +    struct.pack_into('<I', buf, 20, 16)  # OutputBufferLength
> > +    struct.pack_into('b', buf, 24, 0)  # return single
> > +    struct.pack_into('b', buf, 25, 1)  # return single
> > +    try:
> > +        f = os.open(path, os.O_RDONLY)
> > +        fcntl.ioctl(f, CIFS_QUERY_INFO, buf, 1)
> > +        os.close(f)
> > +        if flag == 0:
> > +            print(BBOLD + " %-7s | %-7s | %-7s | %s " + ENDC) % (titleused, titlelim, titlethr, titlesid)
> > +        q = Quota(buf[24:24 + struct.unpack_from('<I', buf, 16)[0]], flag)
> > +        print(q)
> > +    except IOError as reason:
> > +        print("ioctl failed: %s" % reason)
> > +    except OSError as reason:
> > +        print("ioctl failed: %s" % reason)
> > +
> > +
> > +def main():
> > +    if len(sys.argv) < 2:
> > +        usage()
> > +
> > +    parser = argparse.ArgumentParser(description="Please specify an action to perform.", prog="smb2quota")
>
> description is used to generate a useful help/usage message. Maybe use
> "tool to display quota information for the Linux SMB client file system (CIFS)"
>
> > +    parser.add_argument("-tabular", "-t", metavar="", help="Print quota information in tabular format")
> > +    parser.add_argument("-csv", "-c", metavar="", help="Print quota information in csv format")
> > +    parser.add_argument("-list", "-l", metavar="", help="Print quota information in list format")
>
> * I think we should use 2 dashes (i.e. "--tabular") for long options.
> * For boolean flags, action="store_true" is what you want
> * You can put let argparse know about the path arg, and then use args.path
>
>     parser.add_argument("--tabular", "-t", action="store_true", help="Print quota information in tabular format")
>     parser.add_argument("--csv", "-c", action="store_true", help="Print quota information in csv format")
>     parser.add_argument("--list", "-l", action="store_true", help="Print quota information in list format")
>     parser.add_argument("path", help="Path to query")
>
> Cheers,
> --
> Aurélien Aptel / SUSE Labs Samba Team
> GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
> SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
> GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)

  reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-24  4:56 Kenneth D'souza
2019-10-04 18:43 ` Pavel Shilovsky
2019-10-09 13:13 ` Aurélien Aptel
2019-10-09 13:57   ` Kenneth Dsouza [this message]
     [not found]   ` <CAA_-hQL8MpS9YEcaQpuiQnbsuJwerutnbxWhE-Fyk1X4jpvwcw@mail.gmail.com>
2019-10-09 14:31     ` Aurélien Aptel
2019-10-09 23:29       ` ronnie sahlberg
2019-10-10  0:51         ` Steve French
2019-10-10  7:22         ` Aurélien Aptel

Reply instructions:

You may reply publically 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=CAA_-hQL+2nn6N7ig13onQpnDdTC2Ceb1Z6TSnsJCRdJYLYCiFg@mail.gmail.com \
    --to=kdsouza@redhat.com \
    --cc=aaptel@suse.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

Linux-CIFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-cifs/0 linux-cifs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-cifs linux-cifs/ https://lore.kernel.org/linux-cifs \
		linux-cifs@vger.kernel.org linux-cifs@archiver.kernel.org
	public-inbox-index linux-cifs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-cifs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox