diff options
Diffstat (limited to 'meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0005-Improve-error-handling-in-the-btrfs-command.patch')
-rw-r--r-- | meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0005-Improve-error-handling-in-the-btrfs-command.patch | 510 |
1 files changed, 0 insertions, 510 deletions
diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0005-Improve-error-handling-in-the-btrfs-command.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0005-Improve-error-handling-in-the-btrfs-command.patch deleted file mode 100644 index e7e3fae332..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0005-Improve-error-handling-in-the-btrfs-command.patch +++ /dev/null | |||
@@ -1,510 +0,0 @@ | |||
1 | Upstream-Status: Inappropriate [Backport] | ||
2 | From b3007332100e01ca84c161b6c75f0a414ab4611b Mon Sep 17 00:00:00 2001 | ||
3 | From: Goffredo Baroncelli <kreijack@libero.it> | ||
4 | Date: Mon, 20 Dec 2010 20:06:19 +0000 | ||
5 | Subject: [PATCH 05/15] Improve error handling in the btrfs command | ||
6 | |||
7 | Hi Chris, | ||
8 | |||
9 | below is enclosed a trivial patch, which has the aim to improve the error | ||
10 | reporting of the "btrfs" command. | ||
11 | |||
12 | You can pull from | ||
13 | |||
14 | http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git | ||
15 | |||
16 | branch | ||
17 | |||
18 | strerror | ||
19 | |||
20 | I changed every printf("some-error") to something like: | ||
21 | |||
22 | e = errno; | ||
23 | fprintf(stderr, "ERROR: .... - %s", strerror(e)); | ||
24 | |||
25 | so: | ||
26 | |||
27 | 1) all the error are reported to standard error | ||
28 | 2) At the end of the message is printed the error as returned by the system. | ||
29 | |||
30 | The change is quite simple, I replaced every printf("some-error") to the line | ||
31 | above. I don't touched anything other. | ||
32 | I also integrated a missing "printf" on the basis of the Ben patch. | ||
33 | |||
34 | This patch leads the btrfs command to be more "user friendly" :-) | ||
35 | |||
36 | Regards | ||
37 | G.Baroncelli | ||
38 | |||
39 | btrfs-list.c | 40 ++++++++++++++++++++++-------- | ||
40 | btrfs_cmds.c | 77 ++++++++++++++++++++++++++++++++++++++++----------------- | ||
41 | utils.c | 6 ++++ | ||
42 | 3 files changed, 89 insertions(+), 34 deletions(-) | ||
43 | |||
44 | Signed-off-by: Chris Mason <chris.mason@oracle.com> | ||
45 | --- | ||
46 | btrfs-list.c | 40 ++++++++++++++++++++++-------- | ||
47 | btrfs_cmds.c | 77 ++++++++++++++++++++++++++++++++++++++++----------------- | ||
48 | utils.c | 6 ++++ | ||
49 | 3 files changed, 89 insertions(+), 34 deletions(-) | ||
50 | |||
51 | diff --git a/btrfs-list.c b/btrfs-list.c | ||
52 | index 93766a8..abcc2f4 100644 | ||
53 | --- a/btrfs-list.c | ||
54 | +++ b/btrfs-list.c | ||
55 | @@ -265,7 +265,7 @@ static int resolve_root(struct root_lookup *rl, struct root_info *ri) | ||
56 | static int lookup_ino_path(int fd, struct root_info *ri) | ||
57 | { | ||
58 | struct btrfs_ioctl_ino_lookup_args args; | ||
59 | - int ret; | ||
60 | + int ret, e; | ||
61 | |||
62 | if (ri->path) | ||
63 | return 0; | ||
64 | @@ -275,9 +275,11 @@ static int lookup_ino_path(int fd, struct root_info *ri) | ||
65 | args.objectid = ri->dir_id; | ||
66 | |||
67 | ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args); | ||
68 | + e = errno; | ||
69 | if (ret) { | ||
70 | - fprintf(stderr, "ERROR: Failed to lookup path for root %llu\n", | ||
71 | - (unsigned long long)ri->ref_tree); | ||
72 | + fprintf(stderr, "ERROR: Failed to lookup path for root %llu - %s\n", | ||
73 | + (unsigned long long)ri->ref_tree, | ||
74 | + strerror(e)); | ||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | @@ -320,15 +322,18 @@ static u64 find_root_gen(int fd) | ||
79 | unsigned long off = 0; | ||
80 | u64 max_found = 0; | ||
81 | int i; | ||
82 | + int e; | ||
83 | |||
84 | memset(&ino_args, 0, sizeof(ino_args)); | ||
85 | ino_args.objectid = BTRFS_FIRST_FREE_OBJECTID; | ||
86 | |||
87 | /* this ioctl fills in ino_args->treeid */ | ||
88 | ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_args); | ||
89 | + e = errno; | ||
90 | if (ret) { | ||
91 | - fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu\n", | ||
92 | - (unsigned long long)BTRFS_FIRST_FREE_OBJECTID); | ||
93 | + fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu - %s\n", | ||
94 | + (unsigned long long)BTRFS_FIRST_FREE_OBJECTID, | ||
95 | + strerror(e)); | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | @@ -351,8 +356,10 @@ static u64 find_root_gen(int fd) | ||
100 | |||
101 | while (1) { | ||
102 | ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); | ||
103 | + e = errno; | ||
104 | if (ret < 0) { | ||
105 | - fprintf(stderr, "ERROR: can't perform the search\n"); | ||
106 | + fprintf(stderr, "ERROR: can't perform the search - %s\n", | ||
107 | + strerror(e)); | ||
108 | return 0; | ||
109 | } | ||
110 | /* the ioctl returns the number of item it found in nr_items */ | ||
111 | @@ -407,14 +414,16 @@ static char *__ino_resolve(int fd, u64 dirid) | ||
112 | struct btrfs_ioctl_ino_lookup_args args; | ||
113 | int ret; | ||
114 | char *full; | ||
115 | + int e; | ||
116 | |||
117 | memset(&args, 0, sizeof(args)); | ||
118 | args.objectid = dirid; | ||
119 | |||
120 | ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args); | ||
121 | + e = errno; | ||
122 | if (ret) { | ||
123 | - fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu\n", | ||
124 | - (unsigned long long)dirid); | ||
125 | + fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu - %s\n", | ||
126 | + (unsigned long long)dirid, strerror(e) ); | ||
127 | return ERR_PTR(ret); | ||
128 | } | ||
129 | |||
130 | @@ -472,6 +481,7 @@ static char *ino_resolve(int fd, u64 ino, u64 *cache_dirid, char **cache_name) | ||
131 | struct btrfs_ioctl_search_header *sh; | ||
132 | unsigned long off = 0; | ||
133 | int namelen; | ||
134 | + int e; | ||
135 | |||
136 | memset(&args, 0, sizeof(args)); | ||
137 | |||
138 | @@ -490,8 +500,10 @@ static char *ino_resolve(int fd, u64 ino, u64 *cache_dirid, char **cache_name) | ||
139 | sk->nr_items = 1; | ||
140 | |||
141 | ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); | ||
142 | + e = errno; | ||
143 | if (ret < 0) { | ||
144 | - fprintf(stderr, "ERROR: can't perform the search\n"); | ||
145 | + fprintf(stderr, "ERROR: can't perform the search - %s\n", | ||
146 | + strerror(e)); | ||
147 | return NULL; | ||
148 | } | ||
149 | /* the ioctl returns the number of item it found in nr_items */ | ||
150 | @@ -550,6 +562,7 @@ int list_subvols(int fd) | ||
151 | char *name; | ||
152 | u64 dir_id; | ||
153 | int i; | ||
154 | + int e; | ||
155 | |||
156 | root_lookup_init(&root_lookup); | ||
157 | |||
158 | @@ -578,8 +591,10 @@ int list_subvols(int fd) | ||
159 | |||
160 | while(1) { | ||
161 | ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); | ||
162 | + e = errno; | ||
163 | if (ret < 0) { | ||
164 | - fprintf(stderr, "ERROR: can't perform the search\n"); | ||
165 | + fprintf(stderr, "ERROR: can't perform the search - %s\n", | ||
166 | + strerror(e)); | ||
167 | return ret; | ||
168 | } | ||
169 | /* the ioctl returns the number of item it found in nr_items */ | ||
170 | @@ -747,6 +762,7 @@ int find_updated_files(int fd, u64 root_id, u64 oldest_gen) | ||
171 | u64 found_gen; | ||
172 | u64 max_found = 0; | ||
173 | int i; | ||
174 | + int e; | ||
175 | u64 cache_dirid = 0; | ||
176 | u64 cache_ino = 0; | ||
177 | char *cache_dir_name = NULL; | ||
178 | @@ -773,8 +789,10 @@ int find_updated_files(int fd, u64 root_id, u64 oldest_gen) | ||
179 | max_found = find_root_gen(fd); | ||
180 | while(1) { | ||
181 | ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); | ||
182 | + e = errno; | ||
183 | if (ret < 0) { | ||
184 | - fprintf(stderr, "ERROR: can't perform the search\n"); | ||
185 | + fprintf(stderr, "ERROR: can't perform the search- %s\n", | ||
186 | + strerror(e)); | ||
187 | return ret; | ||
188 | } | ||
189 | /* the ioctl returns the number of item it found in nr_items */ | ||
190 | diff --git a/btrfs_cmds.c b/btrfs_cmds.c | ||
191 | index fffb423..775bfe1 100644 | ||
192 | --- a/btrfs_cmds.c | ||
193 | +++ b/btrfs_cmds.c | ||
194 | @@ -156,6 +156,7 @@ int do_defrag(int ac, char **av) | ||
195 | int verbose = 0; | ||
196 | int fancy_ioctl = 0; | ||
197 | struct btrfs_ioctl_defrag_range_args range; | ||
198 | + int e=0; | ||
199 | |||
200 | optind = 1; | ||
201 | while(1) { | ||
202 | @@ -219,19 +220,21 @@ int do_defrag(int ac, char **av) | ||
203 | } | ||
204 | if (!fancy_ioctl) { | ||
205 | ret = ioctl(fd, BTRFS_IOC_DEFRAG, NULL); | ||
206 | + e=errno; | ||
207 | } else { | ||
208 | ret = ioctl(fd, BTRFS_IOC_DEFRAG_RANGE, &range); | ||
209 | if (ret && errno == ENOTTY) { | ||
210 | - fprintf(stderr, "defrag range ioctl not " | ||
211 | + fprintf(stderr, "ERROR: defrag range ioctl not " | ||
212 | "supported in this kernel, please try " | ||
213 | "without any options.\n"); | ||
214 | errors++; | ||
215 | + close(fd); | ||
216 | break; | ||
217 | } | ||
218 | } | ||
219 | if (ret) { | ||
220 | - fprintf(stderr, "ioctl failed on %s ret %d errno %d\n", | ||
221 | - av[i], ret, errno); | ||
222 | + fprintf(stderr, "ERROR: defrag failed on %s - %s\n", | ||
223 | + av[i], strerror(e)); | ||
224 | errors++; | ||
225 | } | ||
226 | close(fd); | ||
227 | @@ -310,7 +313,7 @@ int do_subvol_list(int argc, char **argv) | ||
228 | int do_clone(int argc, char **argv) | ||
229 | { | ||
230 | char *subvol, *dst; | ||
231 | - int res, fd, fddst, len; | ||
232 | + int res, fd, fddst, len, e; | ||
233 | char *newname; | ||
234 | char *dstdir; | ||
235 | |||
236 | @@ -377,12 +380,14 @@ int do_clone(int argc, char **argv) | ||
237 | args.fd = fd; | ||
238 | strncpy(args.name, newname, BTRFS_PATH_NAME_MAX); | ||
239 | res = ioctl(fddst, BTRFS_IOC_SNAP_CREATE, &args); | ||
240 | + e = errno; | ||
241 | |||
242 | close(fd); | ||
243 | close(fddst); | ||
244 | |||
245 | if(res < 0 ){ | ||
246 | - fprintf( stderr, "ERROR: cannot snapshot '%s'\n",subvol); | ||
247 | + fprintf( stderr, "ERROR: cannot snapshot '%s' - %s\n", | ||
248 | + subvol, strerror(e)); | ||
249 | return 11; | ||
250 | } | ||
251 | |||
252 | @@ -392,7 +397,7 @@ int do_clone(int argc, char **argv) | ||
253 | |||
254 | int do_delete_subvolume(int argc, char **argv) | ||
255 | { | ||
256 | - int res, fd, len; | ||
257 | + int res, fd, len, e; | ||
258 | struct btrfs_ioctl_vol_args args; | ||
259 | char *dname, *vname, *cpath; | ||
260 | char *path = argv[1]; | ||
261 | @@ -438,11 +443,13 @@ int do_delete_subvolume(int argc, char **argv) | ||
262 | printf("Delete subvolume '%s/%s'\n", dname, vname); | ||
263 | strncpy(args.name, vname, BTRFS_PATH_NAME_MAX); | ||
264 | res = ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &args); | ||
265 | + e = errno; | ||
266 | |||
267 | close(fd); | ||
268 | |||
269 | if(res < 0 ){ | ||
270 | - fprintf( stderr, "ERROR: cannot delete '%s/%s'\n",dname, vname); | ||
271 | + fprintf( stderr, "ERROR: cannot delete '%s/%s' - %s\n", | ||
272 | + dname, vname, strerror(e)); | ||
273 | return 11; | ||
274 | } | ||
275 | |||
276 | @@ -452,7 +459,7 @@ int do_delete_subvolume(int argc, char **argv) | ||
277 | |||
278 | int do_create_subvol(int argc, char **argv) | ||
279 | { | ||
280 | - int res, fddst, len; | ||
281 | + int res, fddst, len, e; | ||
282 | char *newname; | ||
283 | char *dstdir; | ||
284 | struct btrfs_ioctl_vol_args args; | ||
285 | @@ -492,11 +499,13 @@ int do_create_subvol(int argc, char **argv) | ||
286 | printf("Create subvolume '%s/%s'\n", dstdir, newname); | ||
287 | strncpy(args.name, newname, BTRFS_PATH_NAME_MAX); | ||
288 | res = ioctl(fddst, BTRFS_IOC_SUBVOL_CREATE, &args); | ||
289 | + e = errno; | ||
290 | |||
291 | close(fddst); | ||
292 | |||
293 | if(res < 0 ){ | ||
294 | - fprintf( stderr, "ERROR: cannot create subvolume\n"); | ||
295 | + fprintf( stderr, "ERROR: cannot create subvolume - %s\n", | ||
296 | + strerror(e)); | ||
297 | return 11; | ||
298 | } | ||
299 | |||
300 | @@ -506,7 +515,7 @@ int do_create_subvol(int argc, char **argv) | ||
301 | |||
302 | int do_fssync(int argc, char **argv) | ||
303 | { | ||
304 | - int fd, res; | ||
305 | + int fd, res, e; | ||
306 | char *path = argv[1]; | ||
307 | |||
308 | fd = open_file_or_dir(path); | ||
309 | @@ -517,9 +526,11 @@ int do_fssync(int argc, char **argv) | ||
310 | |||
311 | printf("FSSync '%s'\n", path); | ||
312 | res = ioctl(fd, BTRFS_IOC_SYNC); | ||
313 | + e = errno; | ||
314 | close(fd); | ||
315 | if( res < 0 ){ | ||
316 | - fprintf(stderr, "ERROR: unable to fs-syncing '%s'\n", path); | ||
317 | + fprintf(stderr, "ERROR: unable to fs-syncing '%s' - %s\n", | ||
318 | + path, strerror(e)); | ||
319 | return 16; | ||
320 | } | ||
321 | |||
322 | @@ -528,7 +539,7 @@ int do_fssync(int argc, char **argv) | ||
323 | |||
324 | int do_scan(int argc, char **argv) | ||
325 | { | ||
326 | - int i, fd; | ||
327 | + int i, fd, e; | ||
328 | if(argc<=1){ | ||
329 | int ret; | ||
330 | |||
331 | @@ -560,10 +571,12 @@ int do_scan(int argc, char **argv) | ||
332 | * a btrfs filesystem from an I/O error !!! | ||
333 | */ | ||
334 | ret = ioctl(fd, BTRFS_IOC_SCAN_DEV, &args); | ||
335 | + e = errno; | ||
336 | |||
337 | if( ret < 0 ){ | ||
338 | close(fd); | ||
339 | - fprintf(stderr, "ERROR: unable to scan the device '%s'\n", argv[i]); | ||
340 | + fprintf(stderr, "ERROR: unable to scan the device '%s' - %s\n", | ||
341 | + argv[i], strerror(e)); | ||
342 | return 11; | ||
343 | } | ||
344 | } | ||
345 | @@ -577,7 +590,7 @@ int do_resize(int argc, char **argv) | ||
346 | { | ||
347 | |||
348 | struct btrfs_ioctl_vol_args args; | ||
349 | - int fd, res, len; | ||
350 | + int fd, res, len, e; | ||
351 | char *amount=argv[1], *path=argv[2]; | ||
352 | |||
353 | fd = open_file_or_dir(path); | ||
354 | @@ -595,9 +608,11 @@ int do_resize(int argc, char **argv) | ||
355 | printf("Resize '%s' of '%s'\n", path, amount); | ||
356 | strncpy(args.name, amount, BTRFS_PATH_NAME_MAX); | ||
357 | res = ioctl(fd, BTRFS_IOC_RESIZE, &args); | ||
358 | + e = errno; | ||
359 | close(fd); | ||
360 | if( res < 0 ){ | ||
361 | - fprintf(stderr, "ERROR: unable to resize '%s'\n", path); | ||
362 | + fprintf(stderr, "ERROR: unable to resize '%s' - %s\n", | ||
363 | + path, strerror(e)); | ||
364 | return 30; | ||
365 | } | ||
366 | return 0; | ||
367 | @@ -691,7 +706,7 @@ int do_add_volume(int nargs, char **args) | ||
368 | { | ||
369 | |||
370 | char *mntpnt = args[nargs-1]; | ||
371 | - int i, fdmnt, ret=0; | ||
372 | + int i, fdmnt, ret=0, e; | ||
373 | |||
374 | |||
375 | fdmnt = open_file_or_dir(mntpnt); | ||
376 | @@ -738,8 +753,10 @@ int do_add_volume(int nargs, char **args) | ||
377 | |||
378 | strncpy(ioctl_args.name, args[i], BTRFS_PATH_NAME_MAX); | ||
379 | res = ioctl(fdmnt, BTRFS_IOC_ADD_DEV, &ioctl_args); | ||
380 | + e = errno; | ||
381 | if(res<0){ | ||
382 | - fprintf(stderr, "ERROR: error adding the device '%s'\n", args[i]); | ||
383 | + fprintf(stderr, "ERROR: error adding the device '%s' - %s\n", | ||
384 | + args[i], strerror(e)); | ||
385 | ret++; | ||
386 | } | ||
387 | |||
388 | @@ -756,7 +773,7 @@ int do_add_volume(int nargs, char **args) | ||
389 | int do_balance(int argc, char **argv) | ||
390 | { | ||
391 | |||
392 | - int fdmnt, ret=0; | ||
393 | + int fdmnt, ret=0, e; | ||
394 | struct btrfs_ioctl_vol_args args; | ||
395 | char *path = argv[1]; | ||
396 | |||
397 | @@ -768,9 +785,11 @@ int do_balance(int argc, char **argv) | ||
398 | |||
399 | memset(&args, 0, sizeof(args)); | ||
400 | ret = ioctl(fdmnt, BTRFS_IOC_BALANCE, &args); | ||
401 | + e = errno; | ||
402 | close(fdmnt); | ||
403 | if(ret<0){ | ||
404 | - fprintf(stderr, "ERROR: balancing '%s'\n", path); | ||
405 | + fprintf(stderr, "ERROR: error during balancing '%s' - %s\n", | ||
406 | + path, strerror(e)); | ||
407 | |||
408 | return 19; | ||
409 | } | ||
410 | @@ -780,7 +799,7 @@ int do_remove_volume(int nargs, char **args) | ||
411 | { | ||
412 | |||
413 | char *mntpnt = args[nargs-1]; | ||
414 | - int i, fdmnt, ret=0; | ||
415 | + int i, fdmnt, ret=0, e; | ||
416 | |||
417 | fdmnt = open_file_or_dir(mntpnt); | ||
418 | if (fdmnt < 0) { | ||
419 | @@ -794,8 +813,10 @@ int do_remove_volume(int nargs, char **args) | ||
420 | |||
421 | strncpy(arg.name, args[i], BTRFS_PATH_NAME_MAX); | ||
422 | res = ioctl(fdmnt, BTRFS_IOC_RM_DEV, &arg); | ||
423 | + e = errno; | ||
424 | if(res<0){ | ||
425 | - fprintf(stderr, "ERROR: error removing the device '%s'\n", args[i]); | ||
426 | + fprintf(stderr, "ERROR: error removing the device '%s' - %s\n", | ||
427 | + args[i], strerror(e)); | ||
428 | ret++; | ||
429 | } | ||
430 | } | ||
431 | @@ -809,7 +830,7 @@ int do_remove_volume(int nargs, char **args) | ||
432 | |||
433 | int do_set_default_subvol(int nargs, char **argv) | ||
434 | { | ||
435 | - int ret=0, fd; | ||
436 | + int ret=0, fd, e; | ||
437 | u64 objectid; | ||
438 | char *path = argv[2]; | ||
439 | char *subvolid = argv[1]; | ||
440 | @@ -826,9 +847,11 @@ int do_set_default_subvol(int nargs, char **argv) | ||
441 | return 30; | ||
442 | } | ||
443 | ret = ioctl(fd, BTRFS_IOC_DEFAULT_SUBVOL, &objectid); | ||
444 | + e = errno; | ||
445 | close(fd); | ||
446 | if( ret < 0 ){ | ||
447 | - fprintf(stderr, "ERROR: unable to set a new default subvolume\n"); | ||
448 | + fprintf(stderr, "ERROR: unable to set a new default subvolume - %s\n", | ||
449 | + strerror(e)); | ||
450 | return 30; | ||
451 | } | ||
452 | return 0; | ||
453 | @@ -840,6 +863,7 @@ int do_df_filesystem(int nargs, char **argv) | ||
454 | u64 count = 0, i; | ||
455 | int ret; | ||
456 | int fd; | ||
457 | + int e; | ||
458 | char *path = argv[1]; | ||
459 | |||
460 | fd = open_file_or_dir(path); | ||
461 | @@ -856,7 +880,10 @@ int do_df_filesystem(int nargs, char **argv) | ||
462 | sargs->total_spaces = 0; | ||
463 | |||
464 | ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs); | ||
465 | + e = errno; | ||
466 | if (ret) { | ||
467 | + fprintf(stderr, "ERROR: couldn't get space info on '%s' - %s\n", | ||
468 | + path, strerror(e)); | ||
469 | free(sargs); | ||
470 | return ret; | ||
471 | } | ||
472 | @@ -874,7 +901,11 @@ int do_df_filesystem(int nargs, char **argv) | ||
473 | sargs->total_spaces = 0; | ||
474 | |||
475 | ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs); | ||
476 | + e = errno; | ||
477 | if (ret) { | ||
478 | + fprintf(stderr, "ERROR: couldn't get space info on '%s' - %s\n", | ||
479 | + path, strerror(e)); | ||
480 | + close(fd); | ||
481 | free(sargs); | ||
482 | return ret; | ||
483 | } | ||
484 | diff --git a/utils.c b/utils.c | ||
485 | index d8c3dcc..2a15d86 100644 | ||
486 | --- a/utils.c | ||
487 | +++ b/utils.c | ||
488 | @@ -821,6 +821,7 @@ void btrfs_register_one_device(char *fname) | ||
489 | struct btrfs_ioctl_vol_args args; | ||
490 | int fd; | ||
491 | int ret; | ||
492 | + int e; | ||
493 | |||
494 | fd = open("/dev/btrfs-control", O_RDONLY); | ||
495 | if (fd < 0) { | ||
496 | @@ -830,6 +831,11 @@ void btrfs_register_one_device(char *fname) | ||
497 | } | ||
498 | strncpy(args.name, fname, BTRFS_PATH_NAME_MAX); | ||
499 | ret = ioctl(fd, BTRFS_IOC_SCAN_DEV, &args); | ||
500 | + e = errno; | ||
501 | + if(ret<0){ | ||
502 | + fprintf(stderr, "ERROR: unable to scan the device '%s' - %s\n", | ||
503 | + fname, strerror(e)); | ||
504 | + } | ||
505 | close(fd); | ||
506 | } | ||
507 | |||
508 | -- | ||
509 | 1.7.2.3 | ||
510 | |||