@@ -182,7 +182,8 @@
int
main(int argc, char **argv){
- int fd, i, j, k, n, op, off, arg;
+ int i, j, k, n, op, off, arg;
+ int fd = -1;
struct slice all;
struct pt *ptp;
enum action what = LIST;
@@ -342,8 +343,10 @@
printf("%s: %d slices\n", ptp->type, n);
#endif
- if (n > 0)
+ if (n > 0) {
close(fd);
+ fd = -1;
+ }
else
continue;
@@ -371,15 +374,6 @@
slices[j].size, device,
slices[j].start);
}
- if (loopcreated && S_ISREG (buf.st_mode)) {
- if (del_loop(device)) {
- if (verbose)
- printf("can't del loop : %s\n",
- device);
- exit(1);
- }
- printf("loop deleted : %s\n", device);
- }
break;
case DELETE:
@@ -457,6 +451,17 @@
if (n > 0)
break;
}
+ if (what == LIST && loopcreated && S_ISREG (buf.st_mode)) {
+ if (fd != -1)
+ close(fd);
+ if (del_loop(device)) {
+ if (verbose)
+ printf("can't del loop : %s\n",
+ device);
+ exit(1);
+ }
+ printf("loop deleted : %s\n", device);
+ }
dm_lib_release();
dm_lib_exit();