summaryrefslogtreecommitdiff
path: root/libbb/loop.c
diff options
context:
space:
mode:
authorRob Landley2005-12-21 16:53:57 +0000
committerRob Landley2005-12-21 16:53:57 +0000
commit90854679703217971ebeafe34836473b2e1fff9b (patch)
tree75f9f3ce7dcab8748775f7814c5f8758f0a05fdd /libbb/loop.c
parentbeb665a376d60493617ed7913531cb937a5aee4d (diff)
downloadbusybox-90854679703217971ebeafe34836473b2e1fff9b.zip
busybox-90854679703217971ebeafe34836473b2e1fff9b.tar.gz
Trying to losetup a device as a regular user shouldn't result in an endless
loop, and the error messages should display correctly now.
Diffstat (limited to 'libbb/loop.c')
-rw-r--r--libbb/loop.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libbb/loop.c b/libbb/loop.c
index 00e3d62..85aa372 100644
--- a/libbb/loop.c
+++ b/libbb/loop.c
@@ -89,7 +89,7 @@ int set_loop(char **device, const char *file, int offset)
char dev[20], *try;
bb_loop_info loopinfo;
struct stat statbuf;
- int i, dfd, ffd, mode, rc=1;
+ int i, dfd, ffd, mode, rc=-1;
/* Open the file. Barf if this doesn't work. */
if((ffd = open(file, mode=O_RDWR))<0 && (ffd = open(file,mode=O_RDONLY))<0)
@@ -107,7 +107,7 @@ int set_loop(char **device, const char *file, int offset)
/* Open the sucker and check its loopiness. */
if((dfd=open(try, mode))<0 && errno==EROFS)
dfd=open(try,mode=O_RDONLY);
- if(dfd<0) continue;
+ if(dfd<0) goto try_again;
rc=ioctl(dfd, BB_LOOP_GET_STATUS, &loopinfo);
@@ -128,6 +128,7 @@ int set_loop(char **device, const char *file, int offset)
} else if(strcmp(file,loopinfo.lo_file_name)
|| offset!=loopinfo.lo_offset) rc=-1;
close(dfd);
+try_again:
if(*device) break;
}
close(ffd);