summaryrefslogtreecommitdiff
path: root/cmds-device.c
Commit message (Collapse)AuthorAge
* btrfs-progs: fix minor grammar issuesMitchel Humpherys2014-01-31
| | | | | | | | Remove the extraneous `to' from `Can't access to X'. Signed-off-by: Mitchel Humpherys <mitch.special@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: handle error in the btrfs_prepare_deviceAnand Jain2014-01-31
| | | | | | | | | this patch will handle the strerror reporting of the error instead of printing errno, and also replaced the BUG_ON with the error handling Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: add sanity checks for btrfs device operationsWang Shilong2014-01-31
| | | | | | | | | Make sure we are a block device firstly, this can avoid some unnecessary ioctls operations. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: make sure we return an error when we can't add a deviceJosef Bacik2013-10-24
| | | | | | | | | | I noticed xfstests was failing in a weird way but it was because our device add was failing but not actually returning an error so we were failing further down the test. Fix this by making sure we return an error if we fail the mkfs tests. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: use the marco BTRFS_UPDATE_KERNEL where neededAnand Jain2013-10-16
| | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: device scan use BTRFS_SCAN_LBLKID by defaultAnand Jain2013-10-16
| | | | | | | | | | | | | | | | | with this patch, BTRFS_SCAN_LBLKID (which leverages lblkid to look for btrfs disks) would be the default scan method to look for the btrfs disks. And thus the output as seen in the latest btrfs fi show and btrfs fi show -m for the mounted disks will have the consistent disks path. (it was inconsistent (across disks) because btrfs dev scan provided a different path from the mount command eg. below) devid 1 size 1.98GiB used 435.00MiB path /dev/mapper/mpatha devid 2 size 2.00GiB used 415.00MiB path /dev/dm-1 Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: device add should check existing FS before addingAnand Jain2013-10-16
| | | | | | | | | | | | | | | as of now, when 'btrfs device add' adds a device it doesn't check if the given device contains an existing FS. This patch will change that to check the same. which when true add will fail, and ask user to use -f option to overwrite. further, since now we have test_dev_for_mkfs() function to check if a disk can be used, so this patch will also use this function to test the given device before adding. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: add nodiscard option to device addDavid Sterba2013-10-16
| | | | | | | Same as for mkfs. Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: fix magic return value in cmds-device.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: fix shadow symbolsZach Brown2013-09-03
| | | | | | | | | | | | | | | This fixes all the instances of warnings that symbols declared in blocks shadow symbols with the same name in surrounding scopes: cmds-device.c:341:22: warning: symbol 'path' shadows an earlier one cmds-device.c:285:14: originally declared here I just renamed or removed the risky shadow symbols instead of pulling their blocks out into functions. 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: remove __CHECKER__ from main codeZach Brown2013-09-03
| | | | | | | | | | | | __CHECKER__ is only for the type juggling used to tell sparse which types need conversion between address spaces. It is not OK to use to change the code that gets checked to avoid bugs elsewhere in the build infrastructure. We want to check the code that builds when the checker isn't enabled. 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: device delete to get errors from the kernelAnand Jain2013-08-09
| | | | | | | | | | | | | | | | | | when user runs command btrfs dev del the raid requisite error if any goes to the /var/log/messages, its not good idea to clutter messages with these user (knowledge) errors, further user don't have to review the system messages to know problem with the cli it should be dropped to the user as part of the cli return. to bring this feature created a set of the ERROR defined BTRFS_ERROR_DEV* error codes and created their error string. I expect this enum to be added with other error which we might want to communicate to the user land Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: congregate dev scanAnand Jain2013-08-09
| | | | | | | | | | | | | | | | the dev scan to find btrfs is performed at two locations all most the same way one at filesystem show and another at device scan. They both follow the same steps. This patch does not alter anything except that it brings these two same logic into the function scan_for_btrfs so that we can play tweaking it. the patch which recommends to use /dev/mapper will also need it Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: update device scan usageAnand Jain2013-08-09
| | | | | | | | | the btrfs device scan usage didnt publish --all-devices option so add it Signed-off-by: Anand Jain <anand.jain@oracle.com> 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: Fix getopt on arm/ppc platformsDavid Sterba2013-08-09
| | | | | | | | | (same as commit bb0eabc383e9a3fde7cdb02591ca88243f3e31fb) There, 'char' is unsigned, so once assigned '-1' from getopt, it gets the value 255. Then, it compared to '-1' gives false. Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: rework get_fs_info to remove side effectsEric Sandeen2013-03-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | get_fs_info() has been silently switching from a device to a mounted path as needed; the caller's filehandle was unexpectedly closed & reopened outside the caller's scope. Not so great. The callers do want "fdmnt" to be the filehandle for the mount point in all cases, though - the various ioctls act on this (not on an fd for the device). But switching it in the local scope of get_fs_info is incorrect; it just so happens that *usually* the fd number is unchanged. So - use the new helpers to detect when an argument is a block device, and open the the mounted path more obviously / explicitly for ioctl use, storing the filehandle in fdmnt. Then, in get_fs_info, ignore the fd completely, and use the path on the argument to determine if the caller wanted to act on just that device, or on all devices for the filesystem. Affects those commands which are documented to accept either a block device or a path: * btrfs device stats * btrfs replace start * btrfs scrub start * btrfs scrub status Signed-off-by: Eric Sandeen <sandeen@redhat.com>
* btrfs-progs: Remove write-only var fdres in cmd_dev_stats()Eric Sandeen2013-02-27
| | | | | | | fdres is initialized to -1, then later tested, but never set. Just remove it. Signed-off-by: Eric Sandeen <sandeen@redhat.com>
* btrfs-progs: simplify ioctl name copy and null terminationEric Sandeen2013-02-05
| | | | | | | | | | | | | | | | | | | | | | | | | In the places where we copy a string into the name member of btrfs_ioctl_vol_args or btrfs_ioctl_vol_args_v2, we use strncopy (to not overflow the name array) and then set the last position to the null character. Howver, in both cases the arrays are defined with: char name[MAX+1]; hence the last array position is name[MAX]. In most cases, we now insert the null at name[MAX-1] which deprives us of one useful character. Even the above isn't consistent through the code, so make some helper code to make it simple, i.e. strncpy_null(dest, src) which automatically does the right thing based on the size of dest. Thanks to Zach Brown for the macro suggestion. Signed-off-by: Eric Sandeen <sandeen@redhat.com>
* btrfs-progs: check for open failure, don't closeZach Brown2013-02-05
| | | | | | | Check for failure by testing for a negative file descriptor, not a descriptor of 0. And if it failed we have nothing to close(). Signed-off-by: Zach Brown <zab@redhat.com>
* Btrfs-progs: add command to get/reset device stats via ioctlStefan Behrens2013-01-31
| | | | | | | | "btrfs device stats" is used to retrieve and print the device stats. "btrfs device stats -z" is used to atomically retrieve, reset and print the stats. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: add btrfs device ready commandJosef Bacik2013-01-23
| | | | | | | | | | | This command will be used by things like dracut that wish to know very simply if all of the devices have been added to the kernel cache yet for the device to be fully mounted. This keeps initrd's from constantly having to try to mount the file system until it succeeds every time a device is added to the system. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Gene Czarcinski <gene@czarc.net>
* Btrfs-progs: only enforce a maximum size if we specify oneJosef Bacik2012-10-02
| | | | | | | | | | | | | | My patch 04609add88ef8428d725de6ef60f46a3ff0dbc8e introduced a regression where if you mkfs'ed a group of disks with different sizes it limited the disks to the size of the first one that is specified. This was not the intent of my patch, I only want it to limit the size based on the -b option, so I've reworked the code to pass in a max block count and that fixes the issue. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
* avoid several strncpy-induced buffer overrunsJim Meyering2012-06-05
| | | | | | | | | | | | | | * restore.c (main): Ensure strncpy-copied dir_name is NUL-terminated. * btrfsctl.c (main): Likewise, for a command-line argument. * utils.c (multiple functions): Likewise. * btrfs-list.c (add_root): Likewise. * btrfslabel.c (change_label_unmounted): Likewise. * cmds-device.c (cmd_add_dev, cmd_rm_dev, cmd_scan_dev): Likewise. * cmds-filesystem.c (cmd_resize): Likewise. * cmds-subvolume.c (cmd_subvol_create, cmd_subvol_delete, cmd_snapshot): Likewise. Reviewed-by: Josef Bacik <josef@redhat.com>
* Btrfs-progs: allow multi-line command group synopsisIlya Dryomov2012-02-08
| | | | Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* Btrfs-progs: switch all existing commands to a new parserIlya Dryomov2012-02-03
| | | | | | | The new infrastructure offloads checking number of arguments passed to a command to individual command handlers. Fix them up accordingly. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* Btrfs-progs: rearrange files in the repoIlya Dryomov2012-02-03
Separate every command group into its own file (cmds_<group>.c) and rearrange includes. Remove btrfs_cmds.c. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>