path: root/cmds-inspect.c
Commit message (Collapse)AuthorAge
* 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 <> Signed-off-by: David Sterba <> Signed-off-by: Chris Mason <>
* Btrfs-progs: add function to map subvol ID to pathStefan Behrens2013-04-23
| | | | | | | | | | | | | | | | Several tools like btrfs-send and btrfs-receive need to map a subvolume ID to a filesystem path. The so far existing methods in btrfs-list.c cause a horrible effort when performing this operation (and the effort is dependent on the number of existing subvolumes with quadratic effort). This commit adds a function that is able to map a subvolume ID to a filesystem path with an effort that is independent of the number of existing subvolumes. In addition to this function, a command line frontend is added as well: btrfs inspect-internal subvolid-resolve <subvolid> <path> Signed-off-by: Stefan Behrens <>
* btrfs-progs: Fix pointer math in __ino_to_path_fdMark Fasheh2013-02-19
| | | | | | | | | We are casting an array of u64 values into a char ** array so when we dereference this array (as a char **) on a 32 bit system we're then re-casting that back to a 32 bit value. This causes problems when we try to print those strings. Signed-off-by: Mark Fasheh <>
* btrfs-progs: zero out inspect ioctl argsEric Sandeen2013-02-05
| | | | | | | | Mostly just to keep things like coverity happy about potentially uninitialized structure members, since it doesn't grok the ioctl. Signed-off-by: Eric Sandeen <> Signed-off-by: Zach Brown <>
* btrfs-progs: don't leak fds in logical resolveZach Brown2013-02-05
| | | | Signed-off-by: Zach Brown <>
* btrfs-progs: close fd in inode resolveZach Brown2013-02-05
| | | | Signed-off-by: Zach Brown <>
* 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 <> Original-Signed-off-by: Stefan Behrens <>
* btrfs-progs: fix 32bit int/pointer cast warningsZach Brown2013-01-17
| | | | | | | | | | | | This uses uintptr_t to cast pointers to u64 ioctl arguments to silence some 32bit build warnings: cmds-inspect.c: In function ‘__ino_to_path_fd’: cmds-inspect.c:47:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] cmds-inspect.c: In function ‘cmd_logical_resolve’: cmds-inspect.c:171:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] Signed-off-by: Zach Brown <>
* Cast args to min to fix compiler warningsChris Mason2012-10-04
* Btrfs-progs: add options to change bufsize in logical to inode translationLiu Bo2012-10-04
| | | | | | | | | Add an option 's' to set bufsize in logical to inode transition, then we are able to read all the refs to the logical address. Meanwhile, set a max value 64k for the bufsize. Signed-off-by: Liu Bo <> Signed-off-by: Chris Mason <>
* Btrfs-progs: restructure list_subvolumesMiao Xie2012-10-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current code of list_subvols() has very bad scalability, if we want to add new filter conditions or new sort methods, we have to modify lots of code. Beside that, the most code of list_snapshots() is similar to list_subvols(), So I restructure list_subvols(), and split the subvolume filter function, the subvolume sort function and the output function from list_subvols(). In order to implement it, we defined some importtant structures: struct btrfs_list_filter { btrfs_list_filter_func filter_func; void *data; }; struct btrfs_list_comparer { btrfs_list_comp_func comp_func; int is_descending; }; struct { char *name; char *column_name; int need_print; } btrfs_list_columns[]; If we want to add a new filter condition, we can choose a suitable filter function, or implement a new filter function[1], and add it into a set of the filters, and then pass the filter set into list_subvols(). We also can mix several filters (just add those filters into the set, and pass the set into list_subvols()) if the users specify two or more filter conditions. The subvolume sort function is similar to the subvolume filter function. The differentiation is the order of comparers in the array which is passed into list_subvols() show us the priority of the sort methods. The output function is different with the above two functions, we define a array to manage all the columns that can be outputed, and use a member variant (->need_print) to control the output of the relative column. Some columns are outputed by default. But we can change it according to the requirement of the users. After appling this patch, we needn't implement a independent list_snapshots() function, just pass a filter function which is used to identify the snapshot into list_subvols(). [1]: If we implement new filter functions or compare functions, we must add them into the array all_filter_funcs or the array all_comp_funcs, and modify the relative enum variants(btrfs_list_filter_enum, btrfs_list_comp_enum). Signed-off-by: Miao Xie <>
* Btrfs-progs: move the function declarations to a new head fileZhou Bo2012-10-04
| | | | | | Move the function declarations to a new head file. Signed-off-by: Zhou Bo <>
* Btrfs-progs: allow multi-line command group synopsisIlya Dryomov2012-02-08
| | | | Signed-off-by: Ilya Dryomov <>
* 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 <>
* 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 <>