summaryrefslogtreecommitdiff
path: root/cmds-quota.c
Commit message (Collapse)AuthorAge
* btrfs-progs: treewide: Replace strerror(errno) with %m.Rosen Penev2018-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As btrfs is specific to Linux, %m can be used instead of strerror(errno) in format strings. This has some size reduction benefits for embedded systems. glibc, musl, and uclibc-ng all support %m as a modifier to printf. A quick glance at the BIONIC libc source indicates that it has support for %m as well. BSDs and Windows do not but I do believe them to be beyond the scope of btrfs-progs. Compiled sizes on Ubuntu 16.04: Before: 3916512 btrfs 233688 libbtrfs.so.0.1 4899 bcp 2367672 btrfs-convert 2208488 btrfs-corrupt-block 13302 btrfs-debugfs 2152160 btrfs-debug-tree 2136024 btrfs-find-root 2287592 btrfs-image 2144600 btrfs-map-logical 2130760 btrfs-select-super 2152608 btrfstune 2131760 btrfs-zero-log 2277752 mkfs.btrfs 9166 show-blocks After: 3908744 btrfs 233256 libbtrfs.so.0.1 4899 bcp 2366560 btrfs-convert 2207432 btrfs-corrupt-block 13302 btrfs-debugfs 2151104 btrfs-debug-tree 2134968 btrfs-find-root 2281864 btrfs-image 2143536 btrfs-map-logical 2129704 btrfs-select-super 2151552 btrfstune 2130696 btrfs-zero-log 2276272 mkfs.btrfs 9166 show-blocks Total savings: 23928 (24 kilo)bytes Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: move help defines to own headerDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: quota: fix printing during wait modeJeff Mahoney2017-01-25
| | | | | | | | | | | | | | | If we call "btrfs quota rescan -w", it will attempt to start the rescan operation, wait for it, and then print the "quota rescan started" message. The wait could last an arbitrary amount of time, so printing it after the wait isn't very helpful. This patch reworks how we print the rescan started message as well as the printing of the messages, including adding an error message for status query failures (which could be EPERM/EFAULT/ENOMEM, not just no rescan in progress) and wait failures. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: do not set optind if not necessaryDavid Sterba2016-07-13
| | | | | | | In the subcommand callbacks that are called just once, we don't need to explicitly reset optind. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add getopt stubs where neededDavid Sterba2016-03-14
| | | | | | | | | Commands that do not take any options do not use getopt, which means the standard option separator "--" does not work. Update all command handlers that need it, argv needs to be referenced using the optind that is correctly pointed after the separator. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: cmd quota: switch to common error message wrapperDavid Sterba2016-01-12
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: quota: use btrfs_open_dir for btrfs quota commandZhao Lei2015-11-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | We can use btrfs_open_dir() to check whether target dir is in btrfs's mount point before open, instead of checking it in kernel space of ioctl, and return fuzzy error message. Before patch: # ./btrfs quota enable /mnt/tmp1 ERROR: quota command failed: Inappropriate ioctl for device # ./btrfs quota disable /mnt/tmp1 ERROR: quota command failed: Inappropriate ioctl for device # ./btrfs quota rescan /mnt/tmp1 ERROR: quota rescan failed: Inappropriate ioctl for device # After patch: # ./btrfs quota enable /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs quota disable /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs quota rescan /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add command group info stringsDavid Sterba2015-06-09
| | | | | | They're printed in the 'btrfs' command group summary. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: fix btrfs quota rescan failed on PPC64 archGeorge Wang2015-04-24
| | | | | | | | | | | | | | | | | | | | | | | | | PPC64 arch use such following IOC values " \#define _IOC_NONE 1U \#define _IOC_READ 2U \#define _IOC_WRITE 4U " comparing to the default IOC values " \#define _IOC_NONE 0U \#define _IOC_READ 2U \#define _IOC_WRITE 1U" This means the value "_IOW*" will be negative when we store it in the int variables. Such as the "BTRFS_IOC_QGROUP_CREATE", it will be "0x4010942e" on X86_64, but "0x8010942e" on PPC64. Notice that the IOC values are the "unsigned long" type, so we use the "unsigned long" to store it, and this can insure the comparison between the variable and BTRFS_IOC_* valid. Signed-off-by: George Wang <xuw2015@gmail.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> [manpage states that it's int, kernel uses unsigned int, glibc wants unsigned long int] Tested-by: Chandan Rajendra <chandan@linux.vnet.ibm.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: fix magic return value in cmds-quota.cWang Shilong2013-10-16
| | | | | | Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: use NULL instead of 0Zach Brown2013-09-03
| | | | | | | | | These were mostly in option structs but there were a few gross string pointer arguments given as 0. Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: mark static & remove unused from non-kernel codeEric Sandeen2013-09-03
| | | | | | | | Mark many functions as static, and remove any resulting dead code. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: added "btrfs quota rescan" -w switch (wait)Jan Schmidt2013-09-03
| | | | | | | | | | With -w one can wait for a rescan operation to finish. It can be used when starting a rescan operation or later to wait for the currently running rescan operation to finish. Waiting is interruptible. Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: fix closing of opendir()Wang Shilong2013-08-09
| | | | | | | | | | valgrind complains open_file_or_dir() causes a memory leak.That is because if we open a directoy by opendir(), and then we should call closedir() to free memory. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: quota rescanJan Schmidt2013-04-23
| | | | | | | | This adds the quota rescan command to be used if qgroup tracking should get out of sync. Can also be used to query the status of a running rescan operation. Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
* btrfs-progs: add quota-related info to usage messagesKoen De Wit2013-04-23
| | | | | | | | | | | Extending usage messages with some info on the quota functionality: - The -i option of "subvol create" and "subvol snapshot" was not documented - The -c option of "qgroup limit" is the default option - The "qouta rescan" command is not yet implemented, while it should be executed after enabling quota on a non-empty filesystem. Signed-off-by: Koen De Wit <koen.de.wit@oracle.com>
* Btrfs-progs: move open_file_or_dir() to utils.cAnand Jain2013-01-30
| | | | | | | | | | | The definition of the function open_file_or_dir() is moved from common.c to utils.c in order to be able to share some common code between scrub and the device stats in the following step. That common code uses open_file_or_dir(). Since open_file_or_dir() makes use of the function dirfd(3), the required XOPEN version was raised from 6 to 7. Signed-off-by: Anand Jain <anand.jain@oracle.com> Original-Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs progs: quota groups supportArne Jansen2012-09-04
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net> Signed-off-by: Arne Jansen <sensille@gmx.net>