summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
...
| * btrfs-progs: don't close(-1)Zach Brown2013-02-05
| | | | | | | | | | | | | | When opening the fd fails just return instead of taking the shared error path that tries to close() the fd. Signed-off-by: Zach Brown <zab@redhat.com>
| * btrfs-progs: break after printing FREE_INOZach Brown2013-02-05
| | | | | | | | | | | | | | The free inode objectid would be printed as "FREE_INOQUOTA_TREE" because of a missing break. Signed-off-by: Zach Brown <zab@redhat.com>
| * btrfs-progs: don't free null pathZach Brown2013-02-05
| | | | | | | | | | | | | | btrfs_free_path() derefs the path before freeing it. It can't be passed a null pointer when allocation fails. Signed-off-by: Zach Brown <zab@redhat.com>
| * btrfs-progs: remove dead code that checks null ebZach Brown2013-02-05
| | | | | | | | | | | | | | 'next' can never be non-null in the body of these loops. It's initialized to NULL and the loop is terminated the moment it is set. Signed-off-by: Zach Brown <zab@redhat.com>
| * btrfs-progs: fix copy-n-paste error checkingZach Brown2013-02-05
| | | | | | | | | | | | | | | | copy_one_inline() meant to test the return of pwrite() with ram_size. Presumably the comparison with len was copied from the test earlier in the function. Signed-off-by: Zach Brown <zab@redhat.com>
| * btrfs-progs: remove unused info_fdZach Brown2013-02-05
| | | | | | | | | | | | finish_subvol() initializes and tests info_fd but it is never used. Signed-off-by: Zach Brown <zab@redhat.com>
| * btrfs-progs: use ftw() unstead of system("du")Zach Brown2013-02-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | size_sourcedir() uses shockingly bad code to try and estimate the size of the files and directories in a subtree. - Its use of snprintf(), strcat(), and sscanf() with arbitrarily small on-stack buffers manages to overflow the stack a few times when given long file names. $ BIG=$(perl -e 'print "a" x 200') $ mkdir -p /tmp/$BIG/$BIG/$BIG/$BIG/$BIG $ mkfs.btrfs /tmp/img -r /tmp/$BIG/$BIG/$BIG/$BIG/$BIG *** stack smashing detected ***: mkfs.btrfs terminated - It passes raw paths to system() allowing interpreting file names as shell control characters. $ mkfs.btrfs /tmp/img -r /tmp/spacey\ dir/ du: cannot access `/tmp/spacey': No such file or directory du: cannot access `dir/': No such file or directory - It redirects du output to "temp_file" in the current directory, allowing overwriting of files through symlinks. $ echo hi > target $ ln -s target temp_file $ mkfs.btrfs /tmp/img -r /tmp/somedir/ $ cat target 3 /tmp/somedir/ This fixes the worst problems while maintaining -r functionality by tearing out the system() code and using ftw() to walk the source tree and sum up st.st_size. Signed-off-by: Zach Brown <zab@redhat.com>
| * btrfs-progs: more carefully check eb backrefsZach Brown2013-02-05
| | | | | | | | | | | | | | | | | | | | | | | | | | check_owner_ref() could deref a null path node if btrfs_search_slot() fails or simply doesn't find a tree tall enough to get to the parent of the desired block. This was flagged by static analysis warning that btrfs_search_slot()'s return value wasn't being checked. Signed-off-by: Zach Brown <zab@redhat.com> Again: caught by static analysis.
| * btrfs-progs: return error from commit_tree_roots()Zach Brown2013-02-05
| | | | | | | | | | | | | | | | Errors cow-ing the root block are silently being dropped. This is just a step towards error handling because both the caller and calee assert on errors. Signed-off-by: Zach Brown <zab@redhat.com>
| * btrfs-progs: treat super.magic as an le64Zach Brown2013-02-05
| | | | | | | | | | | | | | | | | | | | | | | | The super block magic is a le64 whose value looks like an unterminated string in memory. The lack of null termination leads to clumsy use of string functions and causes static analysis tools to warn that the string will be unterminated. So let's just treat it as the le64 that it is. Endian wrappers are used on the constant so that they're compiled into run-time constants. Signed-off-by: Zach Brown <zab@redhat.com>
* | Merge branch 'for-chris' of git://repo.or.cz/btrfs-progs-unstable/devel into ↵Chris Mason2013-02-06
|\| | | | | | | | | | | | | | | | | raid56 Conflicts: ctree.h Signed-off-by: Chris Mason <chris.mason@fusionio.com>
| * Btrfs-progs: use btrfs_lookup_first_block_group when fixing accountingJosef Bacik2013-02-01
| | | | | | | | | | | | | | | | | | | | | | This was a bug from long time ago that never actually got fixed. We start with bytenr 0 when looping through all of the block groups, but btrfs_lookup_block_group will bail out since it couldn't find a block group with 0 as the bytenr. Btrfs_lookup_first_block_group will be nice and adjust the start up to the right value, so this way we reset all the block groups properly and not screw up the users block group accounting. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
| * Btrfs-progs: dont print uuid unless -u option is givenAnand Jain2013-02-01
| | | | | | | | | | | | | | | | unless it was intentional to include uuid when -s option is (show snapshot only) given, we would need this break statement. Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * btrfs-progs: btrfsck: Print which filesystem to be checked to stdoutDieter Ries2013-02-01
| | | | | | | | | | | | | | | | | | This patch makes btrfsck print the filesystem, which is to be checked, to stdout, as well as the UUID of the corresponding partition. This should be helpful when analyzing (copied and pasted) output of btrfsck. Signed-off-by: Dieter Ries <mail@dieterries.net>
| * btrfs-progs: update man pages of subvol listDavid Sterba2013-02-01
| | | | | | | | | | | | | | | | | | - rename to match code where applicable - add missing options - unify the help strings in short and detailed sections - fix a few typos Signed-off-by: David Sterba <dsterba@suse.cz>
| * btrfs-progs: add option c to show ogenerationDavid Sterba2013-02-01
| | | | | | | | | | | | This will also pair the 'C' filter. Signed-off-by: David Sterba <dsterba@suse.cz>
| * btrfs-progs: add option g to show generationDavid Sterba2013-02-01
| | | | | | | | | | | | Add 'g' to pair the 'G' filter. Signed-off-by: David Sterba <dsterba@suse.cz>
| * btrfs-progs: upcase filter optionsDavid Sterba2013-02-01
| | | | | | | | | | | | | | | | Rename filter options in 'subvol list' subcommand, that way we can distinguish them from the options that just show some option in the output and can have a matching uppercase filter. Signed-off-by: David Sterba <dsterba@suse.cz>
| * Btrfs-progs: add subvol flags to printAnand Jain2013-02-01
| | | | | | | | | | | | | | This patch adds the flags row which as of now will show if the subvol/snapshot is readonly. Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: Fix a small memory leak in managing the btrfs list filterAnand Jain2013-02-01
| | | | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: update btrfs_get_subvol to be inline with resolve_root ret changesAnand Jain2013-02-01
| | | | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: filter the deleted subvolumes when listing snapshotsWang Shilong2013-02-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | btrfs snapshot list command will stop by the deleted subvolumes. The problem may happen by two ways: 1. a subvolume deletion is not commited, that is ROOT_BACKREF has been deleted, but ROOT_ITEM still exists. The command will fail to fill the path of the deleted subvolumes because we can not get the parent fs/file tree. 2. a subvolume is possibly deleted when we fill the path, For example, Fs tree |->subv0 |->subv1 We may fill the path of subv1 firstly, after that, some user deletes subv1 and subv0, and then we fill the path of subv0. The command will fail to fill the path of subv0 because we can not get path of subv0. And the command also will fail to make the full path of subv1 because we don't have the path of subv0. Since these subvolumes have been deleted, we should filter them. This patch fixed the above problem by this way. For the 1st case, ->ref_tree of the deleted subvolumes are 0. For the 2nd case, if we found the error number that ioctl() returns is ENOENT, we will set ->ref_tree to 0. And when we make the full path of the subvolumes, we will check ->ref_tree of them and their parent. If someone's ->ref_tree or its parent's ->ref_tree is 0, we will filter it. Reported-by: Stefan Priebe <s.priebe@profihost.ag> Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com> Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: add show subcommand to subvol cliAnand Jain2013-02-01
| | | | | | | | | | | | | | | | This adds show sub-command to the btrfs subvol cli to display detailed inforamtion of the given subvol or snapshot. Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: make get_subvol_name non cmds-send specificAnand Jain2013-02-01
| | | | | | | | | | | | | | | | get_subvol_name can be used other than the just with in cmds-send.c so this patch will make it possible with out changing the original intentions. Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: make printing subvol extensible to newer layoutsAnand Jain2013-02-01
| | | | | | | | | | | | | | | | Currently you can print subvol in a list or table format. This patch will provide a way to extend this to other formats like the upcoming raw format. Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: put find_mount_root() in commands.hAnand Jain2013-02-01
| | | | | | | | | | | | A useful function need to define it in a header file. Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: add method to filter snapshots by parent uuidAnand Jain2013-02-01
| | | | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: add function btrfs_get_subvol to get root_info of a subvolAnand Jain2013-02-01
| | | | | | | | | | | | | | | | We need a function which can get the root_info of a given subvol. This is in preparation to add support for the show sub-cli. Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: move struct root_info to btrfs-list.hAnand Jain2013-02-01
| | | | | | | | | | | | | | | | As we would add more ways to list and manage the subvols and snapshots, its better if we have struct root_info defined in the header file. Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: add parent uuid for snapshotsAnand Jain2013-02-01
| | | | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: move printing subvol list outside of btrfs_list_subvolsAnand Jain2013-02-01
| | | | | | | | | | | | | | To improve the code reuse its better to have btrfs_list_subvols just return list of subvols witout printing Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * Btrfs-progs: List all subvolumes by defaultLukas Czerner2013-02-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit a1e89891eb6af5381539d9875b85c196150171b6 changed subvolume list command so that we list only subvolumes under the specified directory. However this is confusing and unnecessary obstacle, because one usually want to see all subvolumes in the file system. It was introduced with the notion the full_path may be invalid which is not exactly true as the full_path is always relative to the root subvolume which makes perfect sense. Simply making option '-a' default is not enough since it introduces the relative/absolute path distinction effectively obfuscating the subvolume nesting. This commit returns the subvolume list command behaviour before commit a1e89891eb6af5381539d9875b85c196150171b6 where we list all subvolumes in the filesystem with path naming from root subovolume. IMO this is the best default as it is well understood and gives all the important information about file system subvolumes including subvolume nesting without the need to parse additional information. Signed-off-by: Lukas Czerner <lczerner@redhat.com>
| * Btrfs-progs: add '-o' option into subvolume list commandLukas Czerner2013-02-01
| | | | | | | | | | | | | | | | This commit introduces new option '-o' to list only subvolumes under the specified path. This does not change subvolume list behaviour. It has been default in the past and it is even with this commit. Signed-off-by: Lukas Czerner <lczerner@redhat.com>
| * Btrfs-progs: move path modification to filtersLukas Czerner2013-02-01
| | | | | | | | | | | | | | | | | | | | | | | | Commit 8e8e019e910f20947fea7eff5da40753639d8870 introduces -a option which will list all subvolumes with distinguishing between relative and absolute by prepending absolute patch with "<FS_TREE>". This commit moves the path modification to a filter code rather than doing so in path construction in resolve_root(). This gives us more flexibility in formatting path output. Signed-off-by: Lukas Czerner <lczerner@redhat.com>
| * Btrfs-progs: Complete the help information of btrfs send/receiveChen Yang2013-02-01
| | | | | | | | | | | | | | | | | | | | When typing command "btrfs send --help" or "btrfs receive --help", the help information of the commands is incomplete, which only shows a short usage. This patch helps to display the complete infomation of the commands. Signed-off-by: Cheng Yang <chenyang.fnst@cn.fujitsu.com>
| * Update the man page with the new prefixes.Goffredo Baroncelli2013-02-01
| | | | | | | | Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
| * btrfs-progs: mkfs support for extended inode refsMark Fasheh2013-01-31
| | | | | | | | | | | | | | This patch turns on the BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF superblock flag when creating a new file system in mkfs, enabling extended inode refs. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs-progs: add extended inode ref support to btrfsckMark Fasheh2013-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a function, process_inode_extref() to be called from process_one_leaf() when an item type of BTRFS_INODE_EXTREF_KEY is encountered. Similarly to process_inode_ref(), process_inode_extref() walks an extref and adds an inode_backref structure for each reference found within. I modified fsck's inode_backref to get a type field (ref_type) which helps us internally track the exact type of backrefs found. Of course this field could be overwritten in case of disk corruption (duplicate refs) but duplicate refs themselves are tracked by btrfsck so that should not be an issue as btrfsck is written today. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs-progs: Basic support for extended inode refsMark Fasheh2013-01-31
| | | | | | | | | | | | | | | | This patch syncs the extended inode ref definitions from kernels ctree.h and adds support in btrfs-debug-tree for visualizing the state of extended refs on disk. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * Btrfs-prog/send: fix wrong dump_fd check in cmd_send_start()Chen Yang2013-01-31
| | | | | | | | | | | | | | | | In cmd_send_start(), there is a check to make sure dump_fd is not a tty before parsing command options. So if we use the option "-f file", it doesn't work for the dump_fd has not been created. So fix it. Signed-off-by: Cheng Yang <chenyang.fnst@cn.fujitsu.com>
| * Btrfs-progs: man btrfs: subcommands must be grouped togetherAnand Jain2013-01-31
| | | | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com>
| * btrfs-progs: fix parallel buildDavid Sterba2013-01-31
| | | | | | | | | | | | | | | | Parallel build may fail due to late creation of version.h, fix the rule name that does not match the filename. Signed-off-by: David Sterba <dsterba@suse.cz> Reviewed-by: Eri Sandeen <sandeen@redhat.com>
| * btrfs-progs: fix mkfs.btrfs -r optionEric Sandeen2013-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 605e806166847872bb91831b397d58f95027975a broke the mkfs.btrfs -r option, because it calls make_btrfs without ever setting dev_block_count, in the -r case, so we tell it to make a filesystem of size 0. Then we wander into ENOSPC land and segfault. As a quick one-line-fix, just set the dev_block_count to the size of the destination image file. Signed-off-by: Eric Sandeen <sandeen@redhat.com>
| * Btrfs-progs: add support for device replace procedureStefan Behrens2013-01-31
| | | | | | | | | | | | | | | | | | | | | | This is the user mode part of the device replace patch series. The command group "btrfs replace" is added with three commands: - btrfs replace start srcdev|srcdevid targetdev [-Bfr] mount_point - btrfs replace status mount_point [-1] - btrfs replace cancel mount_point Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
| * 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: make two utility functions globally availableStefan Behrens2013-01-30
| | | | | | | | | | | | | | | | Two convenient utility functions that have so far been local to scrub are moved to utils.c. They will be used in the device stats code in a following commit. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
| * 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: fix build warnings in btrfslabel.cDavid Sterba2013-01-30
| | | | | | | | Signed-off-by: David Sterba <dsterba@suse.cz>
| * btrfs-progs: fix unaligned accesses v2Ben Peddell2013-01-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gcc optimizes out the memcpy calls at -O2 and -Os. Replacing memcpy with memmove does't work - gcc treats memmove the same way it treats memcpy. This patch brings in {get|put}_unaligned_le{16|32|64} (using the packed struct method), and uses them in the failing get/set calls. On architectures where unaligned accesses are cheap, these unaligned macros should be optimized out by the compiler. Signed-off-by: Ben Peddell <klightspeed@killerwolves.net>
| * Btrfs-progs: Fix trival compiler error in cmds-qgroup.cGene Czarcinski2013-01-28
| | | | | | | | | | | | | | The compiler does not realize that usage() never returns. Initializing the variable keeps it quiet. Signed-off-by: Gene Czarcinski <gene@czarc.net>