Commit Graph

30 Commits

Author SHA1 Message Date
Jim Meyering 54e345b5c2 avoid several strncpy-induced buffer overruns
* 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>
2012-06-05 19:56:20 +01:00
Anton Blanchard fa81a569ac btrfs-progs: cast u64 to long long to avoid printf warnings
When building on ppc64 I hit a number of warnings in printf:

btrfs-map-logical.c:69: error: format ‘%Lu’ expects type ‘long long
unsigned int’, but argument 4 has type ‘u64’

Fix them.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2011-10-25 09:18:57 -04:00
Goffredo Baroncelli 002d021c5f Deprecate btrfsctl, btrfs-show, btrfs-vol
Hi all,

the patch below deprecates the following programs

* btrfsctl
* btrfs-vol
* btrfs-show

the reason is simple, these programs are superseded by the btrfs utility,
both in terms of documentation, usability and bug. The goal is to avoid
to duplicate codes and avoid update two programs.

The patch adds a warning in the man pages, in the INSTALL file and in the
programs.

$ ./btrfsctl
**
** WARNING: this program is considered deprecated
** Please consider to switch to the btrfs utility
**
no valid commands given
usage: btrfsctl [ -d file|dir] [ -s snap_name subvol|tree ]
                [-r size] [-A device] [-a] [-c] [-D dir .]
        -d filename: defragments one file
        -d directory: defragments the entire Btree
        -s snap_name dir: creates a new snapshot of dir
        -S subvol_name dir: creates a new subvolume
        -r [+-]size[gkm]: resize the FS by size amount
        -A device: scans the device file for a Btrfs filesystem
        -a: scans all devices for Btrfs filesystems
        -c: forces a single FS sync
        -D: delete snapshot
        -m [tree id] directory: set the default mounted subvolume to the [tree
id] or the
directory

Below the patch, but it is possible to pull the changes from:

 	http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git

branch

	btrfs-deprecated

Comments are welcome.

G.Baroncelli

 INSTALL             |    5 +++++
 btrfs-show.c        |    5 +++++
 btrfs-vol.c         |    5 +++++
 btrfsctl.c          |    5 +++++
 man/btrfs-show.8.in |    3 +++
 man/btrfsctl.8.in   |    3 +++
 6 files changed, 26 insertions(+), 0 deletions(-)

the tool to create a new snapshot for the filesystem.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-10-25 09:18:31 -04:00
Eduardo Silva 16261f09c4 Btrfs-progs use safe string manipulation functions
Signed-off-by: Eduardo Silva <eduardo.silva@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-10-25 09:18:31 -04:00
Miao Xie 2d428975f2 fix wrong return value
btrfsctl returns 1 if it does something successfully.
this patch fixes this problem.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
2010-09-23 20:26:49 -04:00
TARUISI Hiroaki 48f16a69d7 check slash in deleting subvolumes
For now, btrfsctl does not check whether subvolume name contains slash
or not. If someone specify subvolume with trailing slash (in case
using shell completion), ioctl returns with EINVAL and this error
may confuse some careless users like me. So, this patch adds check
slashes in subvolume name in deletion same as snapshot/subvolume
creating. But considering shell completion, this fix allows trailing
slash.

Signed-off-by: TARUISI Hiroaki <taruishi.hiroak@jp.fujitsu.com>
2010-09-23 20:26:49 -04:00
Josef Bacik 7b14bc0f4f Btrfs-progs: add command to set default subvol
This introduces a new btrfsctl option, -m, to allow you to set the default'ly
mounted subvolume.  You can do

btrfsctl -m /your/subvolume

and that will make that subvolume the subvolume that is mounted by default, or
you can do

btrfsctl -m <treeid> /any/subvolume

and this will make the subvolume with tree id <treeid> the default'ly mounted
subvolume.  You can get the treeid by using the listing option.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2010-02-28 19:24:25 -05:00
Yan, Zheng 45195b216d btrfsctl: add snapshot/subvolume destroy ioctl
resend Aaron Straus's patch

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-09-21 16:03:57 -04:00
Wang Cong 86179a0507 btrfs-progs: make several functions static
Make several functions static, and make one argument const.

Signed-off-by: WANG Cong <wangcong@zeuux.org>
2009-01-21 13:22:49 -05:00
Calvin Walton 901314f070 Fix misleading error message in btrfsctl
This updates Peter Klotz's original patch to use perror instead of fprintf
when it fails to open /dev/btrfs-control
2009-01-21 13:22:49 -05:00
Chris Mason 6c771595af Modify the subvol and snapshot creation ioctls to work anywhere in the tree
This changes the snapshot and subvol ioctl API and command lines so
that new snapshots and subvols can be created anywhere.

Subvolume creation hasn't changed much:

btrfsctl -S subvol_name directory

This creates a new subvolume under 'directory'

Snapshot creation looks the same, but is actually different:

btrfsctl -s full_path_to_new_snapshot file_or_dir

For example: btrfsctl -s /mnt/new_snap /mnt/subvol

Will create a new snapshot named new_snap under /mnt of the root
found in /mnt/subvol.  It always snapshots the entire root regardless of
which file or directory inside the root you give it.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-11-18 11:26:35 -05:00
email.ahmedkamal@googlemail.com e9fa78e2ec Cleanup btrfsctl help message
Many options were not mentioned in the usage message, fix that and
cleaning up the brackets

Signed-Off-By: Ahmed Kamal <email.ahmedkamal@googlemail.com>
2008-07-30 13:29:28 -04:00
Ahmed 26641e8d32 Fix: btrfsctl arguments handling
btrfsctl -A
in the current -unstable branch, does not result in the error message
designated for it, namely "-A requires an arg\n"
2008-07-30 09:17:21 -04:00
Chris Mason 9864c90760 Print the version string in a few programs 2008-07-24 12:13:30 -04:00
Chris Mason 969c548acb Add sync and transaction ioctl defs
btrfsctl -c forces a single FS sync

The transaction ioctls are unsafe for general use because they can lead
to deadlocks if the application is not very careful.  But, ceph is
experimenting with btrfs as a backing store, and these ioctls are required
for testing.
2008-06-10 10:09:18 -04:00
Linda Knippers d8d4df9474 btrfsctl: print usage when called with bad args 2008-06-09 22:23:13 -04:00
Chris Mason b327761ead Add btrfs-vol command to balance, add and (eventually) remove devices 2008-04-28 16:44:22 -04:00
Chris Mason 9462e711a7 Fix a few casts for 32 bit compile 2008-04-11 12:18:46 -04:00
Chris Mason 0dcfa3b827 Walk all block devices looking for btrfs 2008-03-24 15:05:44 -04:00
Chris Mason 26afd0f31d ioctls to scan for btrfs filesystems 2008-03-24 15:04:49 -04:00
Chris Mason 7e03dadf20 Add online resizing ioctls
btrfsctl -r size mount_point
2007-12-21 16:25:35 -05:00
Chris Mason 0528b69c15 add defrag ioctl 2007-08-07 16:15:59 -04:00
Chris Mason d9f1317c7d add GPLv2 2007-06-12 09:07:11 -04:00
Chris Mason 9ea6a6fd92 no slashes in subvolume names 2007-06-12 08:21:28 -04:00
Chris Mason 38ef945266 printf cleanups 2007-06-12 08:08:04 -04:00
Chris Mason b53a236c3e remove device tree 2007-06-09 09:22:37 -04:00
Chris Mason 832427bdba cleanup warnings found with -O2 2007-05-22 10:07:10 -04:00
Chris Mason 98baacc623 add disk ioctl 2007-04-12 10:51:51 -04:00
Chris Mason 88e3e66570 btrfsctl detects dir/file of args 2007-04-10 14:12:24 -04:00
Chris Mason 43f6ab83bf btrfsctl 2007-04-10 09:27:30 -04:00