diff options
Diffstat (limited to 'meta/recipes-devtools/btrfs-tools/btrfs-tools/mkfs-xin-fixes.patch')
-rw-r--r-- | meta/recipes-devtools/btrfs-tools/btrfs-tools/mkfs-xin-fixes.patch | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/mkfs-xin-fixes.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/mkfs-xin-fixes.patch new file mode 100644 index 0000000000..47fc97725a --- /dev/null +++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/mkfs-xin-fixes.patch | |||
@@ -0,0 +1,183 @@ | |||
1 | Upstream-Status: Pending | ||
2 | |||
3 | This patch is made by xin.zhong@intel.com to implement these supported | ||
4 | features in mkfs.btrfs: | ||
5 | * populate fs image from a directory while creating it | ||
6 | * reduce minimum size of the created image from 256MB to around 24MB | ||
7 | * while creating image use the specified device name rather than output.img | ||
8 | |||
9 | Patch tested and incorporated in poky by: | ||
10 | Nitin A Kamble <nitin.a.kamble@intel.com> 2011/06/20 | ||
11 | |||
12 | diff --git a/file-item.c b/file-item.c | ||
13 | index 9732282..aed42c3 100644 | ||
14 | --- a/file-item.c | ||
15 | +++ b/file-item.c | ||
16 | @@ -193,7 +193,7 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans, | ||
17 | struct btrfs_root *root, u64 alloc_end, | ||
18 | u64 bytenr, char *data, size_t len) | ||
19 | { | ||
20 | - int ret; | ||
21 | + int ret = 0; | ||
22 | struct btrfs_key file_key; | ||
23 | struct btrfs_key found_key; | ||
24 | u64 next_offset = (u64)-1; | ||
25 | diff --git a/mkfs.c b/mkfs.c | ||
26 | index 57c88f9..e953a33 100644 | ||
27 | --- a/mkfs.c | ||
28 | +++ b/mkfs.c | ||
29 | @@ -36,7 +36,7 @@ | ||
30 | #include <uuid/uuid.h> | ||
31 | #include <linux/fs.h> | ||
32 | #include <ctype.h> | ||
33 | -#include <attr/xattr.h> | ||
34 | +#include <sys/xattr.h> | ||
35 | #include "kerncompat.h" | ||
36 | #include "ctree.h" | ||
37 | #include "disk-io.h" | ||
38 | @@ -517,7 +517,6 @@ static int add_inode_items(struct btrfs_trans_handle *trans, | ||
39 | fail: | ||
40 | return ret; | ||
41 | } | ||
42 | - | ||
43 | static int add_xattr_item(struct btrfs_trans_handle *trans, | ||
44 | struct btrfs_root *root, u64 objectid, | ||
45 | const char *file_name) | ||
46 | @@ -532,8 +531,10 @@ static int add_xattr_item(struct btrfs_trans_handle *trans, | ||
47 | |||
48 | ret = llistxattr(file_name, xattr_list, XATTR_LIST_MAX); | ||
49 | if (ret < 0) { | ||
50 | - fprintf(stderr, "get a list of xattr failed for %s\n", | ||
51 | - file_name); | ||
52 | + if(errno == ENOTSUP) | ||
53 | + return 0; | ||
54 | + fprintf(stderr, "get a list of xattr failed for %s errno %d\n", | ||
55 | + file_name, errno); | ||
56 | return ret; | ||
57 | } | ||
58 | if (ret == 0) | ||
59 | @@ -546,8 +547,11 @@ static int add_xattr_item(struct btrfs_trans_handle *trans, | ||
60 | |||
61 | ret = getxattr(file_name, cur_name, cur_value, XATTR_SIZE_MAX); | ||
62 | if (ret < 0) { | ||
63 | - fprintf(stderr, "get a xattr value failed for %s\n", | ||
64 | - cur_name); | ||
65 | + if(errno == ENOTSUP) | ||
66 | + return 0; | ||
67 | + fprintf(stderr, "get a xattr value failed for %s attr %s errno %d\n", | ||
68 | + file_name, cur_name, errno); | ||
69 | + return ret; | ||
70 | } | ||
71 | |||
72 | ret = btrfs_insert_xattr_item(trans, root, cur_name, | ||
73 | @@ -563,7 +567,6 @@ static int add_xattr_item(struct btrfs_trans_handle *trans, | ||
74 | |||
75 | return ret; | ||
76 | } | ||
77 | - | ||
78 | static int custom_alloc_extent(struct btrfs_root *root, u64 num_bytes, | ||
79 | u64 hint_byte, struct btrfs_key *ins) | ||
80 | { | ||
81 | @@ -923,27 +926,27 @@ static int traverse_directory(struct btrfs_trans_handle *trans, | ||
82 | fprintf(stderr, "add_inode_items failed\n"); | ||
83 | goto fail; | ||
84 | } | ||
85 | - | ||
86 | ret = add_xattr_item(trans, root, | ||
87 | cur_inum, cur_file->d_name); | ||
88 | if (ret) { | ||
89 | fprintf(stderr, "add_xattr_item failed\n"); | ||
90 | - goto fail; | ||
91 | + if(ret != -ENOTSUP) | ||
92 | + goto fail; | ||
93 | } | ||
94 | - | ||
95 | if (S_ISDIR(st.st_mode)) { | ||
96 | dir_entry = malloc(sizeof(struct directory_name_entry)); | ||
97 | dir_entry->dir_name = cur_file->d_name; | ||
98 | dir_entry->path = make_path(parent_dir_entry->path, | ||
99 | cur_file->d_name); | ||
100 | dir_entry->inum = cur_inum; | ||
101 | - list_add_tail(&dir_entry->list, &dir_head->list); | ||
102 | + list_add_tail(&dir_entry->list, &dir_head->list); | ||
103 | } else if (S_ISREG(st.st_mode)) { | ||
104 | ret = add_file_items(trans, root, &cur_inode, | ||
105 | cur_inum, parent_inum, &st, | ||
106 | cur_file->d_name, out_fd); | ||
107 | if (ret) { | ||
108 | - fprintf(stderr, "add_file_items failed\n"); | ||
109 | + fprintf(stderr, "add_file_items failed %s\n", | ||
110 | + cur_file->d_name); | ||
111 | goto fail; | ||
112 | } | ||
113 | } else if (S_ISLNK(st.st_mode)) { | ||
114 | @@ -987,7 +990,7 @@ static int create_chunks(struct btrfs_trans_handle *trans, | ||
115 | u64 chunk_size; | ||
116 | u64 meta_type = BTRFS_BLOCK_GROUP_METADATA; | ||
117 | u64 data_type = BTRFS_BLOCK_GROUP_DATA; | ||
118 | - u64 minimum_data_chunk_size = 64 * 1024 * 1024; | ||
119 | + u64 minimum_data_chunk_size = 8 * 1024 * 1024; | ||
120 | u64 i; | ||
121 | int ret; | ||
122 | |||
123 | @@ -1062,7 +1065,6 @@ static u64 size_sourcedir(char *dir_name, u64 sectorsize, | ||
124 | char path[512]; | ||
125 | char *file_name = "temp_file"; | ||
126 | FILE *file; | ||
127 | - u64 minimum_data_size = 256 * 1024 * 1024; /* 256MB */ | ||
128 | u64 default_chunk_size = 8 * 1024 * 1024; /* 8MB */ | ||
129 | u64 allocated_meta_size = 8 * 1024 * 1024; /* 8MB */ | ||
130 | u64 allocated_total_size = 20 * 1024 * 1024; /* 20MB */ | ||
131 | @@ -1101,9 +1103,6 @@ static u64 size_sourcedir(char *dir_name, u64 sectorsize, | ||
132 | |||
133 | *num_of_meta_chunks_ret = num_of_meta_chunks; | ||
134 | |||
135 | - if (total_size < minimum_data_size) | ||
136 | - total_size = minimum_data_size; | ||
137 | - | ||
138 | return total_size; | ||
139 | } | ||
140 | |||
141 | @@ -1158,9 +1157,9 @@ int main(int ac, char **av) | ||
142 | |||
143 | char *source_dir = NULL; | ||
144 | int source_dir_set = 0; | ||
145 | - char *output = "output.img"; | ||
146 | u64 num_of_meta_chunks = 0; | ||
147 | u64 size_of_data = 0; | ||
148 | + u64 source_dir_size = 0; | ||
149 | |||
150 | while(1) { | ||
151 | int c; | ||
152 | @@ -1224,8 +1223,6 @@ int main(int ac, char **av) | ||
153 | fprintf(stderr, "Illegal nodesize %u\n", nodesize); | ||
154 | exit(1); | ||
155 | } | ||
156 | - if (source_dir_set) | ||
157 | - ac++; | ||
158 | ac = ac - optind; | ||
159 | if (ac == 0) | ||
160 | print_usage(); | ||
161 | @@ -1257,17 +1254,19 @@ int main(int ac, char **av) | ||
162 | block_count = dev_block_count; | ||
163 | } else { | ||
164 | ac = 0; | ||
165 | - fd = open_target(output); | ||
166 | + file = av[optind++]; | ||
167 | + fd = open_target(file); | ||
168 | if (fd < 0) { | ||
169 | fprintf(stderr, "unable to open the %s\n", file); | ||
170 | exit(1); | ||
171 | } | ||
172 | |||
173 | - file = output; | ||
174 | first_fd = fd; | ||
175 | first_file = file; | ||
176 | - block_count = size_sourcedir(source_dir, sectorsize, | ||
177 | + source_dir_size = size_sourcedir(source_dir, sectorsize, | ||
178 | &num_of_meta_chunks, &size_of_data); | ||
179 | + if(block_count < source_dir_size) | ||
180 | + block_count = source_dir_size; | ||
181 | ret = zero_output_file(fd, block_count, sectorsize); | ||
182 | if (ret) { | ||
183 | fprintf(stderr, "unable to zero the output file\n"); | ||