diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2013-08-21 03:32:13 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-09-01 08:16:36 -0400 |
commit | ed84885d1e03839b8508ab707657d8d1002edea6 (patch) | |
tree | 8e5ec12b50c51e9f92554c180b8e00927554b1ab /fs/btrfs | |
parent | e57138b3e96e45a63124492e736612378096290f (diff) |
btrfs: reuse kbasename helper
To get name of the file from a pathname let's use kbasename() helper. It allows
to simplify code a bit.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/send.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index cbe92da5f33b..b4b15467426b 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/radix-tree.h> | 26 | #include <linux/radix-tree.h> |
27 | #include <linux/crc32c.h> | 27 | #include <linux/crc32c.h> |
28 | #include <linux/vmalloc.h> | 28 | #include <linux/vmalloc.h> |
29 | #include <linux/string.h> | ||
29 | 30 | ||
30 | #include "send.h" | 31 | #include "send.h" |
31 | #include "backref.h" | 32 | #include "backref.h" |
@@ -2601,7 +2602,6 @@ static int record_ref(struct list_head *head, u64 dir, | |||
2601 | u64 dir_gen, struct fs_path *path) | 2602 | u64 dir_gen, struct fs_path *path) |
2602 | { | 2603 | { |
2603 | struct recorded_ref *ref; | 2604 | struct recorded_ref *ref; |
2604 | char *tmp; | ||
2605 | 2605 | ||
2606 | ref = kmalloc(sizeof(*ref), GFP_NOFS); | 2606 | ref = kmalloc(sizeof(*ref), GFP_NOFS); |
2607 | if (!ref) | 2607 | if (!ref) |
@@ -2611,20 +2611,14 @@ static int record_ref(struct list_head *head, u64 dir, | |||
2611 | ref->dir_gen = dir_gen; | 2611 | ref->dir_gen = dir_gen; |
2612 | ref->full_path = path; | 2612 | ref->full_path = path; |
2613 | 2613 | ||
2614 | tmp = strrchr(ref->full_path->start, '/'); | 2614 | ref->name = (char *)kbasename(ref->full_path->start); |
2615 | if (!tmp) { | 2615 | ref->name_len = ref->full_path->end - ref->name; |
2616 | ref->name_len = ref->full_path->end - ref->full_path->start; | 2616 | ref->dir_path = ref->full_path->start; |
2617 | ref->name = ref->full_path->start; | 2617 | if (ref->name == ref->full_path->start) |
2618 | ref->dir_path_len = 0; | 2618 | ref->dir_path_len = 0; |
2619 | ref->dir_path = ref->full_path->start; | 2619 | else |
2620 | } else { | ||
2621 | tmp++; | ||
2622 | ref->name_len = ref->full_path->end - tmp; | ||
2623 | ref->name = tmp; | ||
2624 | ref->dir_path = ref->full_path->start; | ||
2625 | ref->dir_path_len = ref->full_path->end - | 2620 | ref->dir_path_len = ref->full_path->end - |
2626 | ref->full_path->start - 1 - ref->name_len; | 2621 | ref->full_path->start - 1 - ref->name_len; |
2627 | } | ||
2628 | 2622 | ||
2629 | list_add_tail(&ref->list, head); | 2623 | list_add_tail(&ref->list, head); |
2630 | return 0; | 2624 | return 0; |