diff options
author | Rob Landley <rob@landley.net> | 2005-12-21 16:53:57 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2005-12-21 16:53:57 +0000 |
commit | 90854679703217971ebeafe34836473b2e1fff9b (patch) | |
tree | 75f9f3ce7dcab8748775f7814c5f8758f0a05fdd | |
parent | beb665a376d60493617ed7913531cb937a5aee4d (diff) | |
download | busybox-w32-90854679703217971ebeafe34836473b2e1fff9b.tar.gz busybox-w32-90854679703217971ebeafe34836473b2e1fff9b.tar.bz2 busybox-w32-90854679703217971ebeafe34836473b2e1fff9b.zip |
Trying to losetup a device as a regular user shouldn't result in an endless
loop, and the error messages should display correctly now.
-rw-r--r-- | libbb/loop.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libbb/loop.c b/libbb/loop.c index 00e3d6236..85aa37236 100644 --- a/libbb/loop.c +++ b/libbb/loop.c | |||
@@ -89,7 +89,7 @@ int set_loop(char **device, const char *file, int offset) | |||
89 | char dev[20], *try; | 89 | char dev[20], *try; |
90 | bb_loop_info loopinfo; | 90 | bb_loop_info loopinfo; |
91 | struct stat statbuf; | 91 | struct stat statbuf; |
92 | int i, dfd, ffd, mode, rc=1; | 92 | int i, dfd, ffd, mode, rc=-1; |
93 | 93 | ||
94 | /* Open the file. Barf if this doesn't work. */ | 94 | /* Open the file. Barf if this doesn't work. */ |
95 | if((ffd = open(file, mode=O_RDWR))<0 && (ffd = open(file,mode=O_RDONLY))<0) | 95 | 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) | |||
107 | /* Open the sucker and check its loopiness. */ | 107 | /* Open the sucker and check its loopiness. */ |
108 | if((dfd=open(try, mode))<0 && errno==EROFS) | 108 | if((dfd=open(try, mode))<0 && errno==EROFS) |
109 | dfd=open(try,mode=O_RDONLY); | 109 | dfd=open(try,mode=O_RDONLY); |
110 | if(dfd<0) continue; | 110 | if(dfd<0) goto try_again; |
111 | 111 | ||
112 | rc=ioctl(dfd, BB_LOOP_GET_STATUS, &loopinfo); | 112 | rc=ioctl(dfd, BB_LOOP_GET_STATUS, &loopinfo); |
113 | 113 | ||
@@ -128,6 +128,7 @@ int set_loop(char **device, const char *file, int offset) | |||
128 | } else if(strcmp(file,loopinfo.lo_file_name) | 128 | } else if(strcmp(file,loopinfo.lo_file_name) |
129 | || offset!=loopinfo.lo_offset) rc=-1; | 129 | || offset!=loopinfo.lo_offset) rc=-1; |
130 | close(dfd); | 130 | close(dfd); |
131 | try_again: | ||
131 | if(*device) break; | 132 | if(*device) break; |
132 | } | 133 | } |
133 | close(ffd); | 134 | close(ffd); |